0
\$\begingroup\$

I'm creating a top-down 2D space game in LIBGDX for android.

When spaceship is going forward it will look like this:

enter image description here

when it goes upward I want to change it's direction with a nice animation so it seems like a real spaceship. A between frame would be like this:

enter image description here

I have rendered the spaceship in different Z axis degrees from ship0 to ship90. Calculating rotation on XY plane wouldn't be so hard, but I don't know how to calculate the rotation on Z axis so I can choose the right sprite to use.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

When you starts going upwards you can start counting X from 0 to 90. For example you can increase X by 1 every 16 ms (for example). Then you can use X to use appropriate shipX frame.

When you stop going upward then decrease X from current value to 0 (for example 2 by every 16 ms). Then the ship should back to its prime position softly.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .