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);