以下使用这个动作都用 pSprite->runAction(); auto pSprite = Sprite::create("1.png"); // this->addChild(pSprite,2); pSprite->setPosition(visibleSize.width / 2, visibleSize.height / 2); //瞬时动画 // auto pFlipX = FlipX::create(true); // auto pFlipY = FlipY::create(true); //延时动画 // auto pMoveTo = MoveTo::create(2.0f, Vec2(visibleSize.width / 2+400, visibleSize.height / 2+200));//还有一个是MoveBy,MoveTo是移动的绝对坐标,MoveBy是相对坐标 // auto pRotateBy = RotateBy::create(2.0f, 30);//顺时针旋转30°,同样也有RotateTo版本 // auto pScaleBy = ScaleBy::create(2.0f, 1.2f);//原有基础上放大1.2,也有To版本 // auto pSkewBy = SkewBy::create(2.0f, 30.f, 0.0f);//在2s内在X方向上扭曲30 // auto pJumpBy = JumpBy::create(2.0f, Vec2(100, 0), 30, 10);//跳跃高度为30,跳跃10次,里面的坐标是相对坐标 // auto pFadeOut = FadeOut::create(2.0f);//淡入淡出动画, 另有 FadeIn,FadeTo,注意FadeTo创建时要指定第二个参数代表透明度 // auto pTineBy = TintBy::create(2.0f, 255, 100, 0); //改变颜色 // auto pBlink = Blink::create(20.0f, 20); //20s内让精灵显示后隐藏,重复20次 // auto pRpeatForever = RepeatForever::create(pRotateBy); //重复动画,直接Repeat:;create() 里面第一个参数相同,第二个参数指定次数 // auto pDelayTime = DelayTime::create(2.0f);//延迟动画 // pSprite->runAction(Sequence::create(pMoveTo,pDelayTime,pTineBy,nullptr)); 动画队列,按顺序执行 // pSprite->runAction(Spawn::create(pMoveTo ,pTineBy, nullptr)); //多个动画同时进行 /*===================== 滚动动画 ==================== auto pProgressTimer = ProgressTimer::create(pSprite); pProgressTimer->setPosition(230, 320); pProgressTimer->setType(ProgressTimer::Type::RADIAL); //设置类型 // pProgressTimer->setType(ProgressTimer::Type::BAR); pProgressTimer->setMidpoint(Vec2(0.5,0.5)); //设置中心点 // pProgressTimer->setBarChangeRate(Vec2(1, 0)); //只有设置为BAR类型时,setBarChangeRate才会起作用 // 注:MidPoint,BarChangeRate 为 (0,0)(1,0)左-》右 (1,0)(1,0)右-》左 (0,0)(0,1)下-》上 (0,1)(0,1)上-》下 this->addChild(pProgressTimer,2); auto pProgressTo = ProgressTo::create(3.0f, 100);//另有ProgressFromTo::create(3.0f,30,100) pProgressTimer->runAction(pProgressTo);*/ // auto pElasticIn = EaseElasticOut::create(pMoveTo, 0.3f);//弹性动画,分别有EaseElasticOut,EaseElasticIn,EaseElasticInOut // auto pBounceOut = EaseBounceInOut::create(pMoveTo); //跳跃动画 ,同上,有In Out InOut 三个版本 // auto pExpIn = EaseExponentialInOut::create(pMoveTo); // Sine动画,似乎跟直接MoveTo没什么区别,呃... // auto pBackIn = EaseBackInOut::create(pMoveTo); //回震动画 // auto pSpeed = Speed::create(pMoveTo, 0.5f);//设置速度 // auto pFollow = Follow::create(pSprite); this->runAction(pFollow); //节点跟随 // ======== 3D 动 画 =============================================== // auto pEffectAction = Shaky3D::create(10, Size(15, 10), 2, TRUE);//持续时间(s).网格的大小。晃动特效的范围。指定是否在z轴晃动。 // auto pEffectAction = Waves3D::create(4, Size(15, 10), 20, 5.0f);//3d波动---指定的持续时间(s)。网格的大小。波浪的数量。振幅。 // auto pEffectAction = Ripple3D::create(100, Size(15, 10), Vec2(20, 20), 100, 5,80.f);//3d水涟漪特效 // auto pEffectAction = Lens3D::create(300, Size(15, 10), Vec2(visibleSize.width / 2, visibleSize.height / 2),300);//凸透镜 // auto pEffectAction = Twirl::create(4, Size(15, 10), Vec2(visibleSize.width / 2, visibleSize.height / 2), 4, 4.f); //扭曲特效,看起来倒感觉有点旋转的样式,参数:时间。网格的大小。漩涡的中心位置。漩涡的数量。振幅 // auto pEffectAction = Liquid::create(4, Size(15, 10), 4, 4.0f);//水等液体流动特效 // auto pEffectAction = FlipX3D::create(10);//3d的X轴翻转,感觉像翻书,还有FlipY3D // auto pEffectAction = PageTurn3D::create(5, Size(5, 5)); //3D翻页特效。 // auto pEffectAction = ShakyTiles3D::create(4, Size(15, 10), 10, true);//3d晃动特效,可以看到一个个格子,第三个参数大了之后会很夸张 // auto pEffectAction = ShuffleTiles::create(5, Size(15, 10), CCRANDOM_0_1() * 10000);//洗牌特效,将格子都分开并随机移动 // auto pEffectAction = FadeOutTRTiles::create(4, Size(15, 10));//3D格子淡入淡出动画,共四种FadeOutTRTiles,FadeOutBLTiles,FadeOutUpTiles,FadeOutDownTiles // auto pEffectAction = WavesTiles3D::create(4, Size(15, 10), 20,20.0f);//3D波动效果 // auto pEffectAction = SplitCols::create(4, 12);//分裂函数,另一个版本Row,第二个参数代表分裂的条数 // auto pEffectAction = TurnOffTiles::create(5, Size(15, 10), 10);//以随机方块的方式消失 // auto pEffectAction = JumpTiles3D::create(5, Size(15, 10), 10, 20);//酷炫3d方块跳跃式动画 // auto pEffectAction = ShatteredTiles3D::create(5, Size(15, 10), 5, TRUE);//3D破裂特效 /*auto pNodeGrid = NodeGrid::create();//使用NodeGrid作为载体 this->addChild(pNodeGrid, 2); pNodeGrid->addChild(pSprite); pNodeGrid->runAction(RepeatForever::create(pEffectAction));*/