In Cocos2dx, how does one make the runAction function run before executing subsequent programs?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.