Cocos2d-x ActionManager controls the suspend motion of the genie

Source: Internet
Author: User

Run environment: vs2010 cocos2d-x2.2 run environment: vs2010 cocos2d-x2.2 ActionManager to see the name is known to be the management of the entire Action, we can get ActionManager through the single-sample CCDirector, with ActionManager, we can control the movement of a certain genie object. 1. first set the movement of an genie: CCAnimation * pSpriteAnimation = CCAnimation: create (); pSpriteAnimation-> setLoops (-1); pSpriteAnimation-> setDelayPerUnit (0.1f ); pSpriteAnimation-> loads ("loading_02.png"); pSpriteAnimation-> loads ("loading_03.png"); loads-> loads ("loading_04.png"); CCAnimate * animate = CCAnimate :: create (pSpriteAnimation); pSp Rite-> runAction (animate); 2. Add a control to the pause displayed on the image. Click here to call the pause written in 3. CCControlButton * controlButton = CCControlButton: create ("pause", "Arial", 52); controlButton-> setPosition (size. width-controlButton-> getContentSize (). width/2, size. height-controlButton-> getContentSize (). height/2); controlButton-> addTargetWithActionForControlEvents (this, cccontrol_selector (HelloWorld: testPause), CCControlEventTouchDown); 3. sample Code of the ActionManager control genie pause and Resume playback: CCDirector * director = C CDirector: sharedDirector (); if (! IsPause) {director-> getActionManager ()-> pauseTarget (this-> getChildByTag (1); isPause =! IsPause;} else if (isPause) {director-> getActionManager ()-> resumeTarget (this-> getChildByTag (1); isPause =! IsPause;} Let's see pauseTarget:/** Pauses the target: all running actions and newly added actions will be paused. */void pauseTarget (CCObject * pTarget); pause the input object.

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.