cocos2dx Action动作解析

Posted Echo-BOX

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cocos2dx Action动作解析相关的知识,希望对你有一定的参考价值。

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

 

以上是关于cocos2dx Action动作解析的主要内容,如果未能解决你的问题,请参考以下文章

cocos2dx action test

cocos2dx 3.x(常见的46种动作)

cocos2dx游戏--欢欢英雄传说--为敌人添加移动和攻击动作

cocos2dx的runAction: 反复运行,多个动作连接运行,多个动作同一时候运行的实现

TiledMap+TexturePacker,解决cocos2dx下tiled地图1坑

Xcode 运行cocos2dx弹出内部错误对话框