PDA

View Full Version : Coordinate space orientation problems.



zeefoes
August 24th, 2009, 04:53 PM
Hey I'm trying to make destructible car bodies. The destructible body is nested within the car chassis (which is the black portion underneath the body, the wheels are part of chassis).

stage > Bullet
stage > Car chassis > Car body

The problem is that as the Chassis rotates... the coordinate space of the Body also seems to rotate. When the car is at 0 degrees everything works as it should, but if the car turns 90 degrees the x and y coordinates reverse. It's hard to explain.


See for yourself - http://filebox.me/view/63fjv6cuu
Step1 : Click anywhere on the screen to spawn a bullet. Drag the bullet through the car. It will erase portions of the car as it should.

Step2 : Now refresh the page.

Step3 : Rotate the car 90 degrees (Shift key is gas, arrow keys are controls, space is brake) and try step 1 again. You'll notice that x and y are reversed.


I'm not sure what I can do to fix this...

FizixMan
August 24th, 2009, 05:20 PM
All the coordinates are relative to their parent container. That's just how Flash is. You can hack your way around it using the globalToLocal and localToGlobal methods. Otherwise you can rethink your car hierarchy and logic. Also, I'm assuming you're using the xmouse and ymouse properties probably from the Root clip. Try using the xmouse/ymouse properties of the Chassis or Car Body clip -- it will give you the local coordinates of those to use.