cocos2d-x ActionManager控制精灵的暂停运动
运行环境:vs2010 cocos2d-x2.2
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.ActionManager控制精灵的暂停与继续播放示例代码: CCDirector* director = CCDirector::sharedDirector(); if (!isPause) { director->getActionManager()->pauseTarget( this ->getChildByTag(1)); isPause=!isPause; } else if (isPause) { director->getActionManager()->resumeTarget( this ->getChildByTag(1)); isPause=!isPause; }我们看pauseTarget的声名为: /** Pauses the target: all running actions and newly added actions will be paused. */ void pauseTarget(CCObject *pTarget); 对传入的对象进行暂停。
代码链接:http://pan.baidu.com/share/link?shareid=215292333&uk=2768417218