zoukankan      html  css  js  c++  java
  • action(四)

    void ActionDelayTime::onEnter()
    {
        ActionsDemo::onEnter();
    
        alignSpritesLeft(1);
    
        CCActionInterval*  move = CCMoveBy::create(1, ccp(150,0));
        CCFiniteTimeAction*  action = CCSequence::create( move, CCDelayTime::create(2), move, NULL);
    
        m_grossini->runAction(action);
    }

    连续动作的反向动作

    void ActionReverseSequence::onEnter()
    {
        ActionsDemo::onEnter();
    
        alignSpritesLeft(1);
    
        CCActionInterval*  move1 = CCMoveBy::create(1, ccp(250,0));
        CCActionInterval*  move2 = CCMoveBy::create(1, ccp(0,50));
        CCFiniteTimeAction*  seq = CCSequence::create( move1, move2, move1->reverse(), NULL);
        CCFiniteTimeAction*  action = CCSequence::create( seq, seq->reverse(), NULL);
    
        m_grossini->runAction(action);
    }

    瞬时动作:主要特点是动作的执行不需要花费时间,马上就能完成动作的执行。这些动作的基类是CCActionInstant。coco2d-x引擎直接提供的瞬时动作如下:
        瞬时动作名称                          描述
      CCCallFunc                          执行函数
      CCFlipX                               X翻转
      CCFlipY                               Y翻转
      CCHide                                隐藏
      CCPlace                             设置位置
      CCReuseGrid                     重用网格
      CCShow                             显示
      CCStopGrid                        停止网格
      CCToggleVisibility              可见切换

    CCActionInterval*  move1 = CCMoveBy::create(1, ccp(250,0));
        CCActionInterval*  move2 = CCMoveBy::create(1, ccp(0,50));
        CCToggleVisibility*  tog1 = new CCToggleVisibility();
        CCToggleVisibility*  tog2 = new CCToggleVisibility();
        tog1->autorelease();
        tog2->autorelease();
        CCFiniteTimeAction*  seq = CCSequence::create( move1, tog1, move2, tog2, move1->reverse(), NULL);
        CCActionInterval*  action = CCRepeat::create((CCActionInterval*)(CCSequence::create( seq, seq->reverse(), NULL)), 3);
    
    
    
        // Test:
        //   Also test that the reverse of Hide is Show, and vice-versa
        m_kathia->runAction(action);
  • 相关阅读:
    prim 堆优化+ kruskal 按秩优化
    poj 2679 Adventurous Driving(SPFA 负环)
    poj 1125 Stockbroker Grapevine (dij优化 0ms)
    codevs 4909 寂寞的堆(写的好丑0.0)
    noi 7221 拯救公主 (状态压缩+bfs)
    codevs2059逃出克隆岛(传送门bfs)
    HUD3336
    poj 3974 Palindrome
    疑难杂症
    正则表达 比较两个浮点数
  • 原文地址:https://www.cnblogs.com/newlist/p/3203345.html
Copyright © 2011-2022 走看看