2D sprite rotation and RotateBy animation

2D sprite rotation and RotateBy animation
0.0 0



Since I had issues with using SetRotation3D to be able to use the X,Y and Z axis for a 2D rotation (because it caused sprites being displayed in a perspective instead of orthopgrapihic view)

I tried to use the SetRotationY and X, but is there also a SetRotationZ? i couldn’t find any SetRotationZ function so far.

And for RotateBy i have the issue, that using only X and Y (because the 3 axis verison doesn work with 2d rotation) makes a weired rotation:

//Rotate on Y axis to flip the card to the side
float x = 0.f;
float y = 90.f

this rotates the sprite on the Y and Z axis, seems like it uses SkewY internally which uses a Y_Z axis?

can anyone help for direct rotations on X ,Y or Z and animations with X,Y and/or Z.

In other engines I were always able to just use SetRot(x-axis,y-axis,z-axis), SetRotX,SetRotY,SetRotZ for 2D, but with cocos those only work with 3D, would be great if someone could help.


i still couldn’t find the right rotations and rotation animations.
would still need help on this


One thing to note is that we have always been a 2D game engine with 3D being added just a few years ago. I don’t feel that we have quite as mature 3D support as other engines.

Here is our API Ref: http://www.cocos2d-x.org/docs/api-ref/cplusplus/v3x/

Here is RotateBy: http://www.cocos2d-x.org/docs/api-ref/cplusplus/v3x/d0/d28/classcocos2d_1_1_rotate_by.html

We also have RotateTo: http://www.cocos2d-x.org/docs/api-ref/cplusplus/v3x/d0/d71/classcocos2d_1_1_rotate_to.html

Have you checked cpp-tests to see what it offers for an example?


Oh alright.
I’m already so used to think about x,y,z Rotation even in 2d only.

I’ve checked those links already and and the Ratation Code it self, but still unsure to get the simple Rotation like backwards, and side rotations done.


i am somehow not able to generate a simple left/right rotation with RotateBy or RotateTo, would need help there


post code.