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 , float sx , 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));
贝塞尔曲线
ccBezierConfig bezier;//配置贝塞尔曲线 bezier.controlPoint1=Vec2(); //坐标省略了 bezier.contrloPoint2=Vec2(); bezier.endPosition=Vec2(); sprite->runAction(BezierBy::create(3.0f,bezier));//3.0f表示运动时间
如何如何控制曲线形状:
(Po为起始点(默认起始位置),P1位控制点1,P2为控制点2,P3为结束点)。(控制点用来确定切线)