码迷,mamicode.com
首页 > 其他好文 > 详细

cocos2dx Action动作解析(2)

时间:2018-04-02 13:50:00      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:方法   point   gpo   持续时间   现在   child   精灵   nta   oss   

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动作解析(2)

标签:方法   point   gpo   持续时间   现在   child   精灵   nta   oss   

原文地址:https://www.cnblogs.com/aibox222/p/8692362.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!