Author Topic: How to negate one component of a FlxPoint.  (Read 907 times)

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
How to negate one component of a FlxPoint.
« on: Sun, Aug 12, 2012 »
Hi,

For calculating Acceleration on going left and going up, I need to negate that component of my Acceleration variable, like: acceleration.x = - accelerationRun.x but I prefer to do it in a more simple and clear way like: acceleration = - accelerationRun but that doesn't work.

I know what I'm saying may make some sense but that's the whole idea I'm trying to do here, mostly refactoring some junk code.
blog, twitter, Check out my award winning game, Rot Gut:

goshki

  • Active Member
  • ***
  • Posts: 172
  • Karma: +0/-0
    • View Profile
    • Vigeo Games
Re: How to negate one component of a FlxPoint.
« Reply #1 on: Mon, Aug 13, 2012 »
To achieve that you'd need operator overloading (so that Flash knows what does it mean to negate a vector object) but unfortunately Flash doesn't has such a functionality.

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: How to negate one component of a FlxPoint.
« Reply #2 on: Tue, Aug 14, 2012 »
Thanks man.
blog, twitter, Check out my award winning game, Rot Gut: