Pop Up Animation in Cocos2D game

左心房为你撑大大i 提交于 2020-01-25 09:12:05

问题


I want to create one game scene to make some object like pop up randmoly.. It shows to small when appear in screen at any time and any position.. It goes to big and come out to screen..

GameScene with objects shows pop up in screnn randmoly..

Like one game which has objects appear in jumping animation..

How its possible..? Any help should be appreciated.. Please...


回答1:


Easy...

To do those animations u must be in mind that the z value of your animated sprite should be higher the all the others to be always up front (create constants to that) You are going to use CCAction do create the action like, fadeIn, Scale, Move.

This is a sample of an viking poping up in the screen and like

CCSprite *viking =
[CCSprite spriteWithFile:@"VikingFloating.png"];
[viking setPosition:ccp(screenSize.width * 0.35f, screenSize.height * 0.45f)];
[self addChild:viking];
id rotateAction = [CCEaseElasticInOut actionWithAction:
[CCRotateBy actionWithDuration:5.5f angle:360]];
id scaleUp = [CCScaleTo actionWithDuration:2.0f scale:1.5f];
id scaleDown = [CCScaleTo actionWithDuration:2.0f scale:0.5f];
[viking runAction:[CCRepeatForever actionWithAction:
[CCSequence actions:scaleUp,scaleDown,nil]]];
[viking runAction:
[CCRepeatForever actionWithAction:rotateAction]];

there is a great book about it, in fact i've got this piece of code from it - http://cocos2dbook.com/



来源:https://stackoverflow.com/questions/6029975/pop-up-animation-in-cocos2d-game

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!