cocos 2 d-x action動作整理集合(二)
4018 ワード
:CCFollow
CCFollow , 。
, , 。
bool initWithTarget (CCNode *pFollowedNode)
bool initWithTarget (CCNode *pFollowedNode, const CCRect &rect)
CCFollow layer sprite, 。cocos2d-x tests , , :
void ActionFollow::onEnter()
{
ActionsDemo::onEnter();
centerSprites(1);
CCSize s = CCDirector::sharedDirector()->getWinSize();
m_grossini->setPosition(CCPointMake(-200, s.height / 2));
CCActionInterval* move = CCMoveBy::actionWithDuration(2, CCPointMake(s.width * 3, 0));
CCActionInterval* move_back = move->reverse();
CCFiniteTimeAction* seq = CCSequence::actions(move, move_back, NULL);
CCAction* rep = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
m_grossini->runAction(rep);
this->runAction(CCFollow::actionWithTarget(m_grossini, CCRectMake(0, 0, s.width * 2 - 100, s.height)));
}
:CCDelayTime
CCDelayTime , CCSequence , , , , 。
cocos2d-x tests , , :
void ActionDelayTime::onEnter()
{
ActionsDemo::onEnter();
alignSpritesLeft(1);
CCActionInterval* move = CCMoveBy::actionWithDuration(1, CCPointMake(150,0));
CCFiniteTimeAction* action = CCSequence::actions( move, CCDelayTime::actionWithDuration(2), move, NULL);
m_grossini->runAction(action);
}
:CCProgressFromTo CCProgressTo
, , 。
CCProgressTimer, CCSprite。 , 。
cocos2d-x 6 :
typedef enum {
/// Radial Counter-Clockwise
kCCProgressTimerTypeRadialCCW,
/// Radial ClockWise
kCCProgressTimerTypeRadialCW,
/// Horizontal Left-Right
kCCProgressTimerTypeHorizontalBarLR,
/// Horizontal Right-Left
kCCProgressTimerTypeHorizontalBarRL,
/// Vertical Bottom-top
kCCProgressTimerTypeVerticalBarBT,
/// Vertical Top-Bottom
kCCProgressTimerTypeVerticalBarTB,
} CCProgressTimerType;
cocos2d-x tests , , :
void SpriteProgressToHorizontal::onEnter()
{
SpriteDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCProgressTo *to1 = CCProgressTo::actionWithDuration(2, 100);
CCProgressTo *to2 = CCProgressTo::actionWithDuration(2, 100);
CCProgressTimer *left = CCProgressTimer::progressWithFile(s_pPathSister1);
left->setType( kCCProgressTimerTypeHorizontalBarLR );//
addChild(left);
left->setPosition(CCPointMake(100, s.height/2));
left->runAction( CCRepeatForever::actionWithAction(to1));
CCProgressTimer *right = CCProgressTimer::progressWithFile(s_pPathSister2);
right->setType( kCCProgressTimerTypeHorizontalBarRL );//
addChild(right);
right->setPosition(CCPointMake(s.width-100, s.height/2));
right->runAction( CCRepeatForever::actionWithAction(to2));
}
:CCGridAction
, , , , , , , 。CCGridAction ,
CCTiledGrid3DAction: Tiled
CCGrid3DAction:
以下から抜粋:http://4137613.blog.51cto.com/4127613/767613