Today, I was troubled by a runAction problem for a while. Later, I found that most of the actions in Cocos2dx are executed asynchronously. If you want to execute subsequent programs after the action ends completely, the desired effect is often not obtained. The Sequence action is required. Class: mySprite-runAction (Sequence: create (MoveTo:
Today, I was troubled by a runAction problem for a while. Later, I found that most of the actions in Cocos2dx are executed asynchronously. If you want to execute subsequent programs after the action ends completely, the desired effect is often not obtained. The Sequence action is required. Class: mySprite-runAction (Sequence: create (MoveTo:
Today, I was troubled by a runAction problem for a while. Later, I found that most of the actions in Cocos2dx are executed asynchronously. If you want to execute subsequent programs after the action ends completely, the desired effect is often not obtained. The Sequence action is required.
For example:
MySprite-> runAction (Sequence: create (
MoveTo: create (0.2, Enemy-> getMySprite ()-> getPosition ()),
CallFunc: create (CC_CALLBACK_0 (myCallback, this ))
, NULL ));
The action to be executed is encapsulated in the Sequence action, and the statement to be executed later is encapsulated in the callback function myCallback (which can also be directly written as a lambda expression, this can achieve the purpose of executing subsequent programs after the runAction function is executed.