cocos2d之持续动作(一)

持续动作

Move

Jump

Scale

Rotate

Skew

Blink

Fade(to,in,out) //FadeIn从透明到不透明

Tint

 

公用代码:

CCSize s = CCDirector::sharedDirector()->getWinSize();
 CCSprite *sp = CCSprite::create("CloseSelected.png");
 sp->setPosition(ccp(s.width/2,s.height/2));
 addChild(sp);

1、移动

CCActionInterval *moveto = CCMoveTo::create(3.0f,ccp(s.width,s.height)); //参数1:时间、参数2:位置
 sp->runAction(moveto);

 

CCActionInterval *moveby = CCMoveBo::create(3.0f,ccp(s.width,s.height)); //参数1:时间、参数2:位置
 sp->runAction(moveto);

注明:moveby跟moveto的区别是moveto是移动到目标位置,moveby是移动距离,也就是横坐标和纵坐标各移动参数的数值

2、跳跃

CCActionInterval *jump =CCJumpTo::create(3.0f,ccp(s.width,s.height),100,5); //参数3:跳跃高度,参数4:跳跃次数
 sp->runAction(jump);

3、闪烁

sp->runAction(CCBlink::create(3.0f,5)); 、、参数1:时间,参数2:次数

4、透明度

sp->setOpacity(0);//设置透明

sp->runAction(CCFadeIn::create(3.0f,5)); 、、参数1:时间,参数2:次数

sp->runAciton(CCFadeTo::create(3.0f,100));//设置3秒钟内透明度为100

5、设置颜色

sp->runAction(CCTintTo::create(3.0f,255,255,0));//后面三个参数是RGB

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值