cocos2dx Action動作解析(2)
阿新 • • 發佈:2018-04-02
repeat line eve als OS osi 動作 現在 posit
CCTintTo、CCTintBy是將sprite的顏色調到你想設置的目標顏色;
CCScaleTo與CCScaleBy比較:
static CCScaleTo* CCScaleTo::create(float duration , float sx , float sy); /* * duration是動作執行持續時間,單位為秒; * sx是X方向的拉伸值(註意,是拉伸值!); * sy是Y方向的拉伸值; */
Static CCScaleBy* CCScaleBy::create(float duration , floatsx , float sy); /* * duration是動作執行持續時間 * sx是X方向的拉伸倍數(註意,現在是倍數!); * sy是Y方向的拉伸倍數; */
CCJumpTo:把某一CCSprite跳到某一位置
CCJumpBy:把某一CCSprite跳起一段距離,它有一個方法reverse,它讓對象按原路徑返回;
CCCardinalSplineTo 為精靈規劃路徑
//創建精靈 Boss Boss =CCSprite::create("diji.png"); Boss->setPosition(ccp(320, 1000));//Boss坐標 this->addChild(Boss); //創建坐標組 並添加坐標 CCPointArray * bosspoints=CCPointArray::create(18); bosspoints->addControlPoint(ccp(250, 980)); bosspoints->addControlPoint(ccp(350, 800)); bosspoints->addControlPoint(ccp(450, 650)); bosspoints->addControlPoint(ccp(500, 500)); bosspoints->addControlPoint(ccp(450, 350)); bosspoints->addControlPoint(ccp(350, 200)); bosspoints->addControlPoint(ccp(250, 350)); bosspoints->addControlPoint(ccp(150, 500)); bosspoints->addControlPoint(ccp(50, 650)); bosspoints->addControlPoint(ccp(150, 800)); bosspoints->addControlPoint(ccp(250, 980)); bosspoints->addControlPoint(ccp(150, 980)); bosspoints->addControlPoint(ccp(50, 980)); bosspoints->addControlPoint(ccp(150, 980)); bosspoints->addControlPoint(ccp(250, 980)); bosspoints->addControlPoint(ccp(350, 980)); bosspoints->addControlPoint(ccp(450, 980)); bosspoints->addControlPoint(ccp(350, 980)); bosspoints->addControlPoint(ccp(250, 980)); //根據坐標組創建一個軌跡 三個參數是 移動一輪的時間,坐標組,浮張力(慣性) CCActionInterval * bosslineTo=CCCardinalSplineTo::create(18, bosspoints, 0); //讓boss執行這個行動 CCRepeatForever是一直執行 Boss->runAction(CCRepeatForever::create(bosslineTo));
cocos2dx Action動作解析(2)