Cocos2d-x how to do 2 rotate on a sprite

I am implementing a game where the Sprite behaves like the following:
When user taps the screen, the Sprite jump and rotate by 360.
It works very well if user only tap once during the rotate action. However, when user tap twice, things get messy.

For example, the rotation takes 0.5s to finish. When it is 0.3ns, user did another tap which triggers another 0.5 rotation. When all the rotation ends, the sprite is rotated by a certain degree. I am expecting 0 degree rotation after the action since both rotation are 360.

Anyone has experienced the same issue? Or knows how to implement this more elegantly ?

Thanks so much in advance.

Start with reviewing this chapter in our Programmers Guide. Also, Actions would be helpful here

Yes, I was using the action for the jump and rotate. See code below.

auto rotate = RotateBy::create(0.4, 360);
rotate->setTag(PLAYER_ROTATE_TAG);
auto jump = Sequence::create(JumpBy::create(0.5, Point(0,0), _jumpHeight, 1),callbackJump,NULL);
jump->setTag(PLAYER_JUMP_TAG);
this->runAction(rotate);
this->runAction(jump);

if the same code got executed the second time while the previous action is not finished yet. The finial rotation degree seems undefined or I can still expect it be 0 (since both rotation are 360 degree)??

Ah How stupid I was. I found the solution. Just set the rotation to 0 after the rotation action. User won’t even notice the difference…

or stop the actions when the user touches the second time?

I still need the previous one to finish because previous rotate action is coupled with a jump action. I do want the sprite to rotate while jumping. Second touch will make the sprite jump higher.

use Spawn instead of Sequence .