论坛首页 移动开发技术论坛

游戏启动画面设计

浏览 3111 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-07-17  
iOS
效果:
1) 游戏主画面加在完毕
2) 进程图片渐现、渐隐(Ready, Set, Go!)
3) 进入游戏

思路:
通过图片加载生成CCSprite实例后构造包含多个Action的CCSequence:
  • 图片渐显(CCFadeIn)
  • 图片放大(CCScaleTo)
  • 图片淡出(CCFadeOut)
  • 执行回调(CCCallFuncN)【说实话,没太搞明白】


代码:
CCSprite * ready = [CCSprite spriteWithFile:@"ready.png"];
[self addChild:ready z:3];
[ready setPosition:ccp(240,160)];
[ready setOpacity:0];

CCSprite * set =[CCSprite spriteWithFile:@"set.png"];
[self addChild:set z:3];
[set setPosition:ccp(240,160)];
[set setOpacity:0];

CCSprite * go = [CCSprite spriteWithFile:@"go.png"];
[self addChild:go z:3];
[go setPosition:ccp(240,160)];
[go setOpacity:0];

[ready runAction:[CCSequence actions:[CCDelayTime actionWithDuration:0.5],[CCSpawn actions:[CCFadeIn actionWithDuration:0.4],[CCScaleTo actionWithDuration:0.4 scale:1.2],nil] ,[CCDelayTime actionWithDuration:0.2],[CCFadeOut actionWithDuration:0.4],[CCCallFuncN actionWithTarget:self selector:@selector(removeSprite:)],nil]];
[set runAction:[CCSequence actions:[CCDelayTime actionWithDuration:1.5],[CCSpawn actions:[CCFadeIn actionWithDuration:0.4],[CCScaleTo actionWithDuration:0.4 scale:1.2],nil] ,[CCDelayTime actionWithDuration:0.2],[CCFadeOut actionWithDuration:0.4],[CCCallFuncN actionWithTarget:self selector:@selector(removeSprite:)],nil]];
[go runAction:[CCSequence actions:[CCDelayTime actionWithDuration:2.5],[CCSpawn actions:[CCFadeIn actionWithDuration:0.4],[CCScaleTo actionWithDuration:0.4 scale:1.2],nil] ,[CCDelayTime actionWithDuration:0.2],[CCFadeOut actionWithDuration:0.4],[CCCallFuncN actionWithTarget:self selector:@selector(removeSpriteAndBegin:)],nil]];


代码下载:
http://bruce-lin-chn-sina-cn.iteye.com/blog/1124752
   发表时间:2011-07-26  
介也可以啊
0 请登录后投票
论坛首页 移动开发技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics