前端之家收集整理的这篇文章主要介绍了
cocos 2d-x 动作,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Size visibleSize = Director::getInstance()->getVisibleSize();
auto role = Sprite::create("grossini.png");
role->setPosition(visibleSize / 2);
addChild(role);
role->setScale(0.5);//减小一倍
role->setScale(2);//放大一倍
//
role->runAction(MoveTo::create(2,Vec2(visibleSize.width-100,visibleSize.height/2)));//2秒时间中向右移动
//多个动作组合
//先向右再向左移动
auto move1 = MoveTo::create(2,Vec2(visibleSize.width - 100,visibleSize.height / 2));
auto move2 = MoveBy::create(2,Vec2(-1000,0));
role->runAction(Sequence::create(move1,move2,NULL));*/
/*
//先向左移动再返回(反转)
auto move1 = MoveBy::create(2,0));
auto move2 = move1->reverse();
role->runAction(Sequence::create(move1,NULL));*/
//并列执行
/*
auto move = MoveBy::create(2,Vec2(600,0));
auto scale = ScaleTo::create(2,1);
role->runAction(Spawn::create(move,scale,NULL));*/
//执行完的回调(打印over)
role->runAction(Sequence::create(Spawn::create(move,NULL),CallFunc::create([](){
log("over");
}),NULL));
@H_
502_25@
原文链接:https://www.f2er.com/cocos2dx/342024.html