标签:scale 没有 run 研究 精灵 period 闪烁 forever ade
/** * DelayTime延迟 * @param d Duration 延迟时间 */ auto delayTime = DelayTime::create(3); sprite->runAction(delayTime); /** MoveTo 移动 @param duration 时长 @param position 移动到的位置 */ auto *moveto = MoveTo::create(1.2f, Vec2(200, 300)); sprite->runAction(moveto); /** MoveBy 移动的距离 @param duration 时长 @param position 移动的距离, 从起始位置移动(100, 200)的位移 */ auto *moveBy = MoveBy::create(1.2f, Vec2(100, 200)); sprite->runAction(moveBy); /** * ScaleTo x, y, z轴按比例缩放 对应于ScaleBy * @param duration 动作时长 * @param x比例 * @param y比例 * @param z比例 */ auto *scaleTo = ScaleTo::create(1.2f, 2.0, 0.5, 2.0); sprite->runAction(scaleTo); /** RotateTo旋转, 如果是3D, 需要参数Vec3, 表示x, y, z方向旋转角度 对应于RotateBy @param duration 时长 @param dstAngleX x旋转角度 @param dstAngleY y旋转角度 */ auto *rotateTo = RotateTo::create(3.0, 90, 0); sprite->runAction(rotateTo); /** SkewTo 倾斜一定角度 对应于SkewBy @param t 时长 @param sx x角度 @param sy y角度 */ auto skewTo = SkewTo::create(3.0, 0, -30); sprite->runAction(skewTo); /** * JumpTo创建跳跃动作 对应于JumpBy * @param duration 时长. * @param position 目标位置. * @param height 每次跳跃的高度. * @param jumps 跳跃次数. */ auto jumpTo = JumpTo::create(3.0, Vec2(300, 100), 100, 3); sprite->runAction(jumpTo); /** * BezierBy创建贝塞尔曲线动作 对应于BezierTo * @param t 时长 * @param c 贝塞尔配置. */ ccBezierConfig bezier; bezier.controlPoint_1 = Vec2(-100, 0); bezier.controlPoint_2 = Vec2(100, 80); bezier.endPosition = Vec2(0, 160); auto *bezierBy = BezierBy::create(2, bezier); sprite->runAction(bezierBy); /** * FadeIn渐渐显示至255, (如果精灵本来就是255透明度, 没有效果) 对应于FadeOut渐渐消失 FadeTo(渐变到..) * @param duration 时长 */ auto fadeIn = FadeIn::create(3.0); sprite->runAction(fadeIn); /** * TintTo填充颜色渐变 对应于TintBy * @param duration 时长 * @param red r值 0 to 255. * @param green g值 * @param blue b值 */ auto tintTo = TintTo::create(3.0, 120, 120, 140); sprite->runAction(tintTo); /** * Blink闪烁 * @param duration 时长 * @param blinks 闪烁次数. */ auto *blink = Blink::create(1.0f, 4); sprite->runAction(blink); /** OrbitCamera创建一个球面坐标轨迹进行旋转的动作 @param t 动画时长 @param radius 起始半径 @param deltaRadius 半径差 @param angleZ 起始Z角度 @param deltaAngleZ 旋转Z角度 @param angleX 起始X角度 @param deltaAngleX 旋转X角度 */ auto orbit = OrbitCamera::create(3, 10, 0, 0, 180, 0, 180); auto reverse = orbit->reverse(); sprite->runAction(reverse); /**CardinalSplineTo创建一个样条曲线轨迹的动作 对应于CardinalSplineBy * @param duration 时长 * @param points 控制点的坐标数组 * @param tension 拟合度 其值= 0 路径最柔和 */ PointArray *array = PointArray::create(20); array->addControlPoint(Vec2(0, 0)); array->addControlPoint(Vec2(210, 0)); array->addControlPoint(Vec2(210, 240)); array->addControlPoint(Vec2(0, 160)); array->addControlPoint(Vec2(0, 0)); auto cardinalSplineTo = CardinalSplineTo::create(5.0, array, 0); sprite->runAction(cardinalSplineTo); /** CatmullRomTo创建一个样条插值轨迹 对应于CatmullRomBy * @param 时长 * @param points 控制点的坐标数组 * @code */ auto catmullRomTo = CatmullRomTo::create(3.0, array); sprite->runAction(catmullRomTo); /** EaseBounceIn 创建有反弹效果的动作(开始时反弹) 对应于EaseBounceOut结束位置反弹, EaseBounceInOut @param action 目标动作 */ auto moveTo = MoveTo::create(4.0, Vec2(300, 300)); auto easeBoundIn = EaseBounceIn::create(moveTo); sprite->runAction(easeBoundIn); /** EaseBackOut 让目标动作赋予回力, 且以目标动作终点位置作为回力点 对应于EaseBackIn, EaseBackInOut @param action 目标动作 */ auto moveTo = MoveTo::create(4.0, Vec2(300, 300)); auto easeBackOut = EaseBackOut::create(moveTo); sprite->runAction(easeBackOut); /** EaseElasticIn 让目标动作赋予弹性, 且以目标动作起点位子赋予弹性 对应于EaseElasticOut, EaseElasticInOut @param action 目标动作 @param period */ auto moveTo = MoveTo::create(4.0, Vec2(300, 300)); auto easeElasticIn = EaseElasticIn::create(moveTo, 0.5); sprite->runAction(easeElasticIn); /** EaseExponentialIn 让目标动作缓慢开始 对应于EaseExponentialOut, EaseExponentialInOut @param action 目标动作 */ auto moveTo = MoveTo::create(4.0, Vec2(300, 300)); auto easeExponentialIn = EaseExponentialIn::create(moveTo); sprite->runAction(easeExponentialIn); /** EaseRateAction 给目标动作设置速率 @param action 目标动作 @param rate 速率 **/ auto moveTo = MoveTo::create(4.0, Vec2(300, 300)); auto easeRateAction = EaseRateAction::create(moveTo, 3); sprite->runAction(easeRateAction); /** EaseSineIn 动作由慢到快 对应于EaseSineOut, EaseSineInOut(动作由慢到快再快到慢) @param action */ auto moveTo = MoveTo::create(4.0, Vec2(300, 300)); auto easeSineIn = EaseSineIn::create(moveTo); sprite->runAction(easeSineIn); /** Speed 倍速 * @param action 目标动作 * @param speed 几倍速 */ auto moveTo = MoveTo::create(4.0, Vec2(300, 300)); auto speed = Speed::create(moveTo, 4); sprite->runAction(speed); /* Spawn 组合多个动作 * 参数:多个目标动作 */ auto spawn = Spawn::create(action1, action2, NULL); sprite->runAction(spawn); /** Sequence 多个动作顺序执行 * 参数:多个动作 如果要执行反方向动作, 所有动作都得支持反方向动作 */ auto moveBy = MoveBy::create(4.0, Vec2(300, 300)); auto scale = ScaleBy::create(2.0, 0.7); auto sequence = Sequence::create(moveBy, scale, NULL); auto sequenceRever = Sequence::create(sequence, sequence->reverse(), NULL); sprite->runAction(sequence); sprite->runAction(sequenceRever); /* Repeat 重复动作 * @param action 要重复的动作, 可以是Sequence, Spawn类型的 * @param times 重复次数 */ auto repeat = Repeat::create(sequence, 3); sprite->runAction(repeat); /* RepeatForever 永久性重复动作 * @param action 要重复的动作, 可以是Sequence, Spawn类型的 */ auto repeatForever = RepeatForever::create(sequence, 3); sprite->runAction(repeatForever);
//Follow 创建的时候需要设置要追随的精灵,然后让背景来执行follow (有待继续研究)
/**
* 创建动作可以设置范围, 也可以不设置
* @param followedNode 追随的精灵
* @param rect 如果没有设置, 表示RECT::ZERO, 表示没有范围
*/
Size s = Director::getInstance()->getWinSize();
log("+++++++++s.width:%f, s.height:%f", s.width, s.height);
sprite->setPosition(Vec2(-200, s.height / 2));
auto move = MoveBy::create(2, Vec2(s.width * 3, 0));
auto move_back = move->reverse();
auto seq = Sequence::create(move, move_back, NULL);
auto rep = RepeatForever::create(seq);
sprite->runAction(rep);
this->runAction(Follow::create(sprite, Rect(0, 0, s.width * 2 - 100, s.height)));
标签:scale 没有 run 研究 精灵 period 闪烁 forever ade
原文地址:http://www.cnblogs.com/lion-witcher/p/6004787.html