Trying to Rotation a sprite, simple enoughm, I placed it into a movieClip and it flies, putting tweening in place, slides it nicely,
Now I am Rotating the sprite and want to move in the direction the front of the sprit eis facing. and I am getting a little mixed up.
For example. I have the rotation example:
dragon:setRotation(75)
Then I have the position
dragon:setPosition(100,100)
Whats the best way to update the X,Y with the new position based on the Angle? is there a Tweening way to do this? or do I need to place the value updates into an event? and whats the best method to update the X,Y coordinates based on Angular calculation?
Regards
REAL programmers type copy con filename.exe
---------------------------------------
Comments
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
---------------------------------------
If so the process is a little different, as you already know the position, it's the angle you need to calculate.
What you do is pick a position on screen relative to your current position, then use the math.atan2() function with the relative offset, this will return the angle from where you are now to where you want to go.
You should be able to plug these numbers into a MovieClip object and have your sprite automatically update itself as the MovieClip runs, failing that you just perform the movement each step as above.
Note - Once you know the x,y offsets you only need to calculate the direction angle once (it'll never change - although the "facing" direction will if you want to rotate smoothly) and also the x,y frame step value is simply the offset (distance to move) / number of frames to give a constant speed across the distance.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill