第一部分:CCFollow跟随动作
- bool initWithTarget (CCNode *pFollowedNode)
- bool initWithTarget (CCNode *pFollowedNode, const CCRect &rect)
- 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)));
- }
- 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);
- }
- 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;
- 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));
- }