cocos2dx 動畫 一,cocos2dx動畫
1.精靈的runAction方法
1 spt = Sprite::create("pean.jpg"); 2 this->addChild(spt); 3 4 MenuItemFont *item = MenuItemFont::create("開始", [&](Ref* spen){ 5 ToggleVisibility *visi = ToggleVisibility::create(); 6 spt->runAction(visi); 7 }); 8 Menu *menu = Menu::create(item, NULL); 9 menu->setPosition(100, 500);10 this->addChild(menu);
2.FadeTo方法
1 FadeTo *fade = FadeTo::create(2.0, 0);2 spt->runAction(fade);
3.MoveTo方法
1 MoveTo *move = MoveTo::create(2, ccp(500,500));2 spt->runAction(move);
4.MoveBy方法(x/y軸位移量)
1 MoveBy *move = MoveBy::create(2.0, Vec2(100, 100));2 spt->runAction(move);
5.JumpBy
第一個參數:跳躍總時間
第二個參數:跳躍後的位移位置
第三個參數:跳躍的高度
第四個參數:跳躍的次數
1 JumpBy *by = JumpBy::create(2.0, Vec2(200,0), 300, 1);2 spt->runAction(by);
6.CardinalSplineBy(按軌跡移動)
貌似 CardinalSplineBy 和CardinalSplineTo一樣,用的是點不是位移量
PointArray *pa = PointArray::create(5);pa->addControlPoint(Vec2(200,0));pa->addControlPoint(Vec2(200,200));pa->addControlPoint(Vec2(400,200));pa->addControlPoint(Vec2(400,0));CardinalSplineBy *sb = CardinalSplineBy::create(5.0, pa, 1);spt->runAction(sb);