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 ?
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)??
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.