cocos2d-x学习笔记(10)重复动作RepeatForever和Repeat 以及动
发布时间:2020-12-14 18:53:07 所属栏目:百科 来源:网络整理
导读:Repeat和RepeatForever Sprite* sprite=Sprite::create("sprite.png");sprite-setPosition(Point(visibleSize.width/2,visibleSize.height/2));this-addChild(sprite,1);JumpBy* jumpBy=JumpBy::create(3.0f,Point(50,1),100,1);//RepeatForever* repeatfore
Repeat和RepeatForever Sprite* sprite=Sprite::create("sprite.png"); sprite->setPosition(Point(visibleSize.width/2,visibleSize.height/2)); this->addChild(sprite,1); JumpBy* jumpBy=JumpBy::create(3.0f,Point(50,1),100,1); //RepeatForever* repeatforeverAction=RepeatForever::create(jumpBy); Repeat* repeatAction=Repeat::create(jumpBy,3); sprite->runAction(repeatAction); Sequence和Spawn Sprite* sprite=Sprite::create("sprite.png"); sprite->setPosition(Point(visibleSize.width/2,1); MoveBy* moveBy=MoveBy::create(2.2f,Point(40,20)); JumpBy* jumpBy=JumpBy::create(3.0f,5); RotateBy* rotateBy=RotateBy::create(2.5f,220,10); Action* action=Spawn::create(moveBy,jumpBy,rotateBy,NULL); sprite->runAction(action); Action是所有动作额父类,Spawn也是一个动作,只不过这个动作又可以包含若干个动作,最后一个参数是NULL值,因为Spawn的create函数参数是可变参数,需要用NULL值表示结束。. Seqence是动作一个接着一个执行; Spawn是动作一起执行。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |