CCSprite* sprite = CCSprite::create("sliderThumb.png");
//点到点的移动
CCMoveTo* moveTo = CCMoveTo::create(0.5f,ccp(300,100));
//向量的移动
CCMoveBy* moveBy = CCMoveBy::create(0.5f,ccp(300,100));
//以图片的原始大小为基准进行拉伸
CCScaleTo* scaleTo = CCScaleTo::create(0.3f,0.5f,0.4f);
//以图片当前大小为基准进行拉伸
CCScaleBy* scaleBy = CCScaleBy::create(0.3f,0.5f,0.4f);
//闪烁效果(闪3次,间隔位0.3s)
CCBlink* blink = CCBlink::create(0.3f,3);
//跳跃效果(第一个参数为渐变时间,第二个参数为跳到的位置,第三个参数为跳起的高度,第四个参数为跳动的次数)
CCJumpBy* jumpBy = CCJumpBy::create(0.5f,ccp(200,200),100,1);
//永久重复动作
CCRepeatForever* forever = CCRepeatForever::create(jumpBy);
//重复的次数
CCRepeat* repeat = CCRepeat::create(jumpBy,2);
//动作同时进行
CCAction* actions = CCSpawn::create(scaleBy,jumpBy,NULL);
//动作监听
CCCallFunc* callFunc = CCCallFunc::create(this,
callfunc_selector(HelloWorld::actionOver)
);
//动作一个接一个进行
CCAction* actions = CCSequence::create(blink,jumpBy,callFunc,NULL);
sprite->setPosition(ccp(0,0));
sprite->runAction(actions);
this->addChild(sprite);
cocos2d-x的常用动作API
最新推荐文章于 2023-10-22 14:45:18 发布