Actions are orders given to a CCNode object. These actions usually modify some of the object's attributes like position, rotation, scale, etc. If these attributes are modified during a period of time, they are CCIntervalAction actions, otherwise they are CCInstantAction actions. For example, the CCMoveBy action modifies the position property during a period of time, hence, it is a subclass of CCIntervalAction.ide
You can run TestCpp->Actions
test to see the action's visual effects. And cocos2d-x/samples/Cpp/TestCpp/Classes/ActionsTest
, ActionsEaseTest are good sample codes for the usage.rest
Example:code
// Move a sprite 50 pixels to the right, and 10 pixels to the top over 2 seconds. 2CCActionInterval* actionBy = CCMoveBy::create(2, ccp(50,10));
The CCIntervalAction actions have some interesting properties: They can be accelerated using the time-altered actionsci
You can pause/resume all actions by using the CCActionManager:get
// Pause actions CCDirector *director = CCDirector::sharedDirector(); m_pPausedTargets = director->getActionManager()->pauseAllRunningActions(); // resume actions CCDirector *director = CCDirector::sharedDirector(); director->getActionManager()->resumeTargets(m_pPausedTargets);
###Basic Actions Basic actions are the ones that modify basic properties like:it
####Positionio
####Scaleclass
####Rotationtest
####Visibilitysed
CCShow
CCHide
CCBlink
CCToggleVisibility
Opacity
CCFadeIn
CCFadeOut
CCFadeTo
####Color
Example:
CCSprite *sprite = CCSprite::create("Images/grossini.png"); sprite->setPosition(ccp(100, 100)); addChild(sprite); CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0)); sprite->runAction(CCRepeat::create(act1, 1));