设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 技术文摘 查看内容

flappy bird游戏源代码揭秘和下载

2014-2-12 11:58| 发布者: 红黑魂| 查看: 8899| 评论: 0|原作者: touchsnow|来自: csdn博客

摘要: 背景: 最近火爆全球的游戏flappy bird让笔者叹为观止,于是花了一天的时间山寨了一个一模一样的游戏,现在把游戏的思路和源码分享出来,代码是基于javascript语言,cocos2d-x游戏引擎,cocos2d-x editor手游开发工 ...

背景:

  最近火爆全球的游戏飞扬的 编辑手游开发工具完成的,请读者轻砸;

  PS:运行演示必须配置好的cocos2d-X的编辑器,暂不支持其他工具


代码下载:


  CSDN下载:http://download.csdn.net/detail/touchsnow/6912707

  百度云盘:http://pan.baidu.com/s/1pJnWDb9

  金山快盘:http://www.kuaipan.cn/file/id_25348935635745384.htm?source=1

  

效果图:




开发工具:

   cocos2dx editor,它是开发跨平台的手机游戏工具,运行window系统上,javascript脚本语言,基于cocos2d-x跨平台游戏引擎,集合代码编辑,场景设计,动画制作,字体设计,还有粒子,物理系统,地图等等的,而且调试方便,和实时模拟;

cocos2dx编辑器介绍和教程:http://blog.csdn.net/touchsnow/article/details/19070665 ;

cocos2dx编辑器官方博客:http://blog.makeapp.co/?cat=8 ;


思路和源码:


  1场景设计MainLayer.ccbx,如下图;主要分三层,开始场景、主场景、游戏结束场景,通过显示隐藏控制三个场景的切换。

 

   MainLayer.ccbx代码

  1. XML  版本= “1.0”  编码= “UTF-8” ?>  
  2.   
  3. < 文件  
  4.         jsControlled = “真”  
  5.         jsController = “MainLayer”  
  6.         分辨率= “默认”  
  7.         >  
  8.   
  9.     < 决议>  
  10.         < 分辨率 centeredOrigin = “假”  = “iphone”  高度= “1280”  宽度= “720”  名称= “默认”  规模= “1” />  
  11.         < 分辨率 centeredOrigin = “假”  = “iphone”  高度= “720”  宽度= “1280”  名称= “默认1”  规模= “1” />  
  12.     决议>  
  13.   
  14.     < 动画>  
  15.         < 动画 将autoPlay = “真”  
  16.                    ID = “0”  
  17.                    名称= “默认时间轴”  
  18.                    长度= “10”的  
  19.                    chainedId = “0”  
  20.                    偏移= “0.0”  
  21.                    位置= “0.0”  
  22.                    分辨率= “30”  
  23.                    规模= “128” >  
  24.             < CallbackChannel >  
  25.             CallbackChannel >  
  26.             < 的SoundChannel >  
  27.             的SoundChannel >  
  28.         动画>  
  29.   
  30.     动画>  
  31.     <   
  32.             positionX = “0”  位置▲ = “0.0”  
  33.             的SizeType = “百分比”  
  34.             宽度= “100”  高度= “100”  
  35.             anchorPointX = “0.5”  anchorPointY = “0.5”  ignoreAnchorPoint = “真”  
  36.             将scaleX = “1”  的scaleY = “1”  
  37.             >  
  38.   
  39.       < Sprite  positionType = "LeftBottom"  width = "720.0"  height = "1280.0"  positionX = "0"  positionY = "0"  anchorPointX = "0"  
  40.                                          anchorPointY = “0”  SRC = “资源/ bg.png”  名字= “”  无功= “”  目标= “无”  的scaleX = “1”  的scaleY = “1”  可见= “真” />  
  41.       < LayerColor  positionType = "LeftBottom"  width = "720"  height = "1280"  positionX = "0"  positionY = "0"  anchorPointX = "0"  
  42.                   anchorPointY = “0”  颜色= “#fff2e8ff”  可见= “假” />  
  43.       < Menu  positionType = "LeftBottom"  width = "40"  height = "40"  positionX = "356.0"  positionY = "237.0"  anchorPointX = "0.5"  
  44.               anchorPointY = “0.5”  将scaleX = “2.4”  的scaleY = “1.725” >  
  45.       菜单>  
  46.       < Sprite  positionType = "LeftBottom"  width = "840.0"  height = "281.0"  positionX = "0"  positionY = "0"  anchorPointX = "0"  
  47.                                          anchorPointY = “0”  SRC = “资源/ ground.png”  无功= “地面”  目标= “文件” />  
  48.       < 节点 positionType = “LeftBottom”  宽度= “40”  高度= “40”  positionX = “800”  位置▲ = “250”  anchorPointX = “0”  
  49.             anchorPointY = “0”  风险值= “hoseNode”  目标= “文件” >  
  50.         < Sprite  positionType = "LeftBottom"  width = "86.0"  height = "60.0"  positionX = "-500"  positionY = "400"  anchorPointX = "0.5"  
  51.                                          anchorPointY = "0.5"  src = "Resources/flappy_packer.plist/bird3.png"  var = "test"  target = "Doc"  visible = "false" />  
  52.         < Sprite  positionType = "LeftBottom"  width = "86.0"  height = "60.0"  positionX = "-550"  positionY = "500"  anchorPointX = "0.5"  
  53.                 anchorPointY = "0.5"  src = "Resources/flappy_packer.plist/bird1.png"  var = "bird"  target = "Doc"  scaleX = "1"  scaleY = "1"  rotation = "0"  visible = "true" />  
  54.       节点>  
  55.       < Node  positionType = "LeftBottom"  width = "40"  height = "40"  positionX = "303.0"  positionY = "500"  anchorPointX = "0.5"  
  56.             anchorPointY = “0.5”  变种= “readyNode”  目标= “文件”  可见= “真” >  
  57.         < Sprite  positionType = "LeftBottom"  width = "508.0"  height = "158.0"  positionX = "95.0"  positionY = "584.0"  anchorPointX = "0.5"  
  58.                                          anchorPointY = “0.5”  SRC = “资源/ flappy_packer.plist / getready.png” />  
  59.         < Sprite  positionType = "LeftBottom"  width = "286.0"  height = "246.0"  positionX = "73.0"  positionY = "236.0"  anchorPointX = "0.5"  
  60.                                          anchorPointY = “0.5”  SRC = “资源/ flappy_packer.plist / click.png” />  
  61.       节点>  
  62.       < 节点 positionType = “LeftBottom”  宽度= “40”  高度= “40”  positionX = “300”  位置▲ = “500”  anchorPointX = “0.5”  
  63.             anchorPointY = “0.5”  变种= “overNode”  目标= “文件”  可见= “真” >  
  64.         < Sprite  positionType = "LeftBottom"  width = "590.0"  height = "298.0"  positionX = "72.0"  positionY = "219.0"  anchorPointX = "0.5"  
  65.                                          anchorPointY = “0.5”  SRC = “资源/ flappy_packer.plist / base.png” >  
  66.           < Sprite  positionType = "LeftBottom"  width = "508.0"  height = "158.0"  positionX = "286.0"  positionY = "458.0"  anchorPointX = "0.5"  
  67.                                          anchorPointY = “0.5”  SRC = “资源/ flappy_packer.plist / gameover.png” />  
  68.         雪碧>  
  69.         < 菜单 positionType = “LeftBottom”  宽度= “40”  高度= “40”  positionX = “0”  位置▲ = “0”  anchorPointX = “0.5”  
  70.               anchorPointY = “0.5” >  
  71.           < MenuItem  positionType = "LeftBottom"  width = "290"  height = "176"  positionX = "-65.0"  positionY = "-92.0"  anchorPointX = "0.5"  
  72.                     anchorPointY = "0.5"  normalImage = "Resources/flappy_packer.plist/start.png"  target = "Doc"  onClick = "onStartClicked" />  
  73.           < MenuItem  positionType = "LeftBottom"  width = "290"  height = "176"  positionX = "230.0"  positionY = "-92.0"  anchorPointX = "0.5"  
  74.                     anchorPointY = "0.5"  target = "Doc"  normalImage = "Resources/flappy_packer.plist/grade.png"  onClick = "onGradeClicked" />  
  75.         菜单>  
  76.       节点>  
  77.     图层>  
  78.   
  79.   
  80. 文档>  

 

2代码编写MainLayer.js

   首先,小鸟在向前飞,其实是底部的路和水管在向左移动,相对的你就感觉小鸟在向右飞了;路循环移动代码:

[浏览器]  鉴于普通副本在代码上查看代码片派生到我的代码片
  1. MainLayer.prototype.groundRun =  函数 ()  
  2. {  
  3.     无功 动作1 = cc.MoveTo.create(0.5,cc.p(-120,0));  
  4.     变种 动作2 = cc.MoveTo.create(0,cc.p(0,0));  
  5.     变种 行动= cc.Sequence.create(动作1,动作2);  
  6.     ground.runAction(cc.RepeatForever.create(行动));  
  7. }  

   初始化高低不同的水管,每一关卡都由上下两水管和空隙组成。总长度相同,空隙也一定,随机取下面水管的长度,就形成错落有致的水管关卡;

[浏览器]  鉴于普通副本在代码上查看代码片派生到我的代码片
  1. MainLayer.prototype.newHose =  功能 (NUM)  
  2. {  
  3.     无功 hoseHeight = 830;  
  4.     无功 acrossHeight = 300;  
  5.     无功 downHeight = 100 +次getRandom(400);  
  6.     无功 upHeight = 1100 - downHeight - acrossHeight;  
  7.   
  8.     无功 hoseX = 400 *民;  
  9.   
  10.     无功 HoseName = FP_MAIN_TEXTURE.HOSE;  
  11.     无功 ccSpriteDown = cc.Sprite.createWithSpriteFrameName(HoseName [0]);  
  12.     ccSpriteDown.setZOrder(1);  
  13.     ccSpriteDown.setAnchorPoint(cc.p(0,0));  
  14.     ccSpriteDown.setPosition(cc.p(hoseX,0));  
  15.     ccSpriteDown.setScaleY(downHeight / hoseHeight);  
  16.   
  17.     无功 ccSpriteUp = cc.Sprite.createWithSpriteFrameName(HoseName [1]);  
  18.     ccSpriteUp.setZOrder(1);  
  19.     ccSpriteUp.setAnchorPoint(cc.p(0,0));  
  20.     ccSpriteUp.setPosition(cc.p(hoseX,downHeight + acrossHeight));  
  21.     ccSpriteUp.setScaleY(upHeight / hoseHeight);  
  22.   
  23.     这个。hoseNode.addChild(ccSpriteDown);  
  24.     这个。hoseNode.addChild(ccSpriteUp);  
  25.     这个。hoseSpriteList.push(ccSpriteDown);  
  26.     这个。hoseSpriteList.push(ccSpriteUp);  
  27.     返回 空值;  
  28. }  

  一开始进入游戏让底部路不断移动,初始化水管,显示准备游戏场景;

[浏览器]  鉴于普通副本在代码上查看代码片派生到我的代码片
  1. MainLayer.prototype.onEnter =  函数 ()  
  2. {  
  3.     cc.AnimationCache.getInstance()addAnimations( 资源/ flappy_frame.plist” );  
  4.     。groundRun();  
  5.     。ground.setZOrder(10);  
  6.     。birdReadyAction();  
  7.     。bird.setZOrder(20);  
  8.     这个。readyNode.setVisible();  
  9.     这个。overNode.setVisible();  
  10.   
  11.      (变种 I = 0; I <30; i + +){  
  12.         。newHose(ⅰ);  
  13.     }  
  14. }  

 点击屏幕,小鸟向上飞60dp,然后更快的速度下落(移动动画),同时闪动翅膀(帧动画);

[浏览器]  鉴于普通副本在代码上查看代码片派生到我的代码片
  1. MainLayer.prototype.birdRiseAction =  函数 ()  
  2. {  
  3.     无功 riseHeight = 60;  
  4.     变种 birdX =  这个bird.getPositionX();  
  5.     变种 的Birdy =  这个bird.getPositionY();  
  6.     变种 时间= BIRDY / 600;  
  7.   
  8.     无功 actionFrame = cc.Animate.create(cc.AnimationCache.getInstance()getAnimation( 飞行” ));  
  9.     无功 flyAction = cc.Repeat.create(actionFrame,90000);  
  10.     无功 riseAction1 = cc.MoveTo.create(0.2,cc.p(birdX,BIRDY + riseHeight));  
  11.     无功 riseAction2 = cc.RotateTo.create(0,-30);  
  12.     无功 riseAction = cc.Spawn.create(riseAction1,riseAction2);  
  13.     无功 fallAction1 = cc.MoveTo.create(时间,cc.p(birdX,50));  
  14.     无功 fallAction2 = cc.Sequence.create(cc.DelayTime.create(时间/ 6),cc.RotateTo.create(0,30));  
  15.     无功 fallAction = cc.Spawn.create(fallAction1,fallAction2);  
  16.   
  17.     。bird.stopAllActions();  
  18.     这个。bird.runAction(cc.Spawn.create(  
  19.             cc.Sequence.create(riseAction,cc.DelayTime.create(0.1),fallAction)  
  20.             flyAction)  
  21.     );  
  22. }  

 检测碰撞,如果小鸟碰到地面和水管,发生碰撞,这里碰撞直接用的cocos2d-X里面的图片和图片交叉函数cc.rectIntersectsRect;

[浏览器]  鉴于普通副本在代码上查看代码片派生到我的代码片
  1. MainLayer.prototype.checkCollision =  函数 ()  
  2. {  
  3.     如果 (。bird.getPositionY()<60){  
  4.         cc.log( 地板” );  
  5.         。birdFallAction();  
  6.         返回;  
  7.     }  
  8.      (变种 I = 0;我<  这个。hoseSpriteList.length,我+ +){  
  9.         变种 软管=  这个。hoseSpriteList由[i];  
  10.         如果 (!这个。isInScreen(软管)){  
  11.             / /继续;  
  12.         }  
  13.   
  14.         如果 (cc.rectIntersectsRect(hose.getBoundingBox(),  。bird.getBoundingBox())){  
  15.             cc.log( 软管positionX ==”  + hose.getBoundingBox()×);  
  16.             cc.log(“this.bird positionX ==”  +  。bird.getBoundingBox()×);  
  17.             cc.log( 我==”  + I);  
  18.             cc.log(“birdFallAction” );  
  19.             。birdFallAction();  
  20.             返回;  
  21.         }  
  22.     }  
  23. }  

碰撞后,小鸟先下落,游戏结束场景显示;

[浏览器]  鉴于普通副本在代码上查看代码片派生到我的代码片
  1. MainLayer.prototype.birdFallAction =  函数 ()  
  2. {  
  3.     这个游戏模式= OVER了。;  
  4.     。bird.stopAllActions();  
  5.     。ground.stopAllActions();  
  6.     变种 birdX =  这个bird.getPositionX();  
  7.     变种 的Birdy =  这个bird.getPositionY();  
  8.     变种 时间= BIRDY / 2000;  
  9.     这个。bird.runAction(cc.Sequence.create(  
  10.             cc.DelayTime.create(0.1),  
  11.             cc.Spawn.create(cc.RotateTo.create(时间,90),cc.MoveTo.create(时间,cc.p(birdX,50))))  
  12.     );  
  13.     这个。overNode.setVisible();  
  14. }  

游戏的难度主要在于多个水管的移动,小鸟触摸动画,检测碰撞,我把Mainlayer.js所有代码贴出来;

[浏览器]  鉴于普通副本在代码上查看代码片派生到我的代码片
  1. FP_MAIN_TEXTURE = {  
  2.     FRAME_ANIMS: 魔豆/资源/ bs_main_anims.plist” ,  
  3.     软管:[ “holdback1.png” ,  “holdback2.png” ]  
  4. }  
  5.   
  6. READY = 1;  
  7. START = 2;  
  8. OVER = 3;  
  9.   
  10. 无功 MainLayer =  函数 ()  
  11. {  
  12.     cc.log(“MainLayer” );  
  13.     这个。鸟=  这个鸟| | {};  
  14.     这个离地=  这个地面| | {};  
  15.     这个。hoseNode =  这个hoseNode | | {};  
  16.     这个。readyNode =  这个readyNode | | {};  
  17.     overNode =。  overNode | | {};  
  18.   
  19.     passTime = 0;  
  20.     hoseSpriteList = [];  
  21.     这个。ISSTART =  ;  
  22.   
  23.     这个。游戏模式=待用;  
  24. };  
  25.   
  26. MainLayer.prototype.onDidLoadFromCCB =  函数 ()  
  27. {  
  28.     如果 (sys.platform ==  '浏览器' ){  
  29.         。的OnEnter();  
  30.     }  
  31.     否则 {  
  32.         这个。rootNode.onEnter =  函数 ()  
  33.         {  
  34.             。controller.onEnter();  
  35.         };  
  36.     }  
  37.   
  38.     这个。rootNode.schedule(函数 (DT)  
  39.     {  
  40.         这个。controller.onUpdate(DT);  
  41.     });  
  42.   
  43.     这个。rootNode.onExit =  函数 ()  
  44.     {  
  45.         。controller.onExit();  
  46.     };  
  47.   
  48.     这个。rootNode.onTouchesBegan =  功能 (触摸,事件)  
  49.     {  
  50.         这个。controller.onTouchesBegan(触摸,事件);  
  51.         返回 ;  
  52.     };  
  53.   
  54.     这个。rootNode.onTouchesMoved =  功能 (触摸,事件)  
  55.     {  
  56.         这个。controller.onTouchesMoved(触摸,事件);  
  57.         返回 ;  
  58.     };  
  59.     这个。rootNode.onTouchesEnded =  功能 (触摸,事件)  
  60.     {  
  61.         这个。controller.onTouchesEnded(触摸,事件);  
  62.         返回 ;  
  63.     };  
  64.     这个。rootNode.setTouchEnabled();  
  65. };  
  66.   
  67. MainLayer.prototype.onEnter =  函数 ()  
  68. {  
  69.     cc.AnimationCache.getInstance()addAnimations( 资源/ flappy_frame.plist” );  
  70.     。groundRun();  
  71.     。ground.setZOrder(10);  
  72.     。birdReadyAction();  
  73.     。bird.setZOrder(20);  
  74.     这个。readyNode.setVisible();  
  75.     这个。overNode.setVisible();  
  76.   
  77.      (变种 I = 0; I <30; i + +){  
  78.         。newHose(ⅰ);  
  79.     }  
  80. }  
  81.   
  82. MainLayer.prototype.newHose =  功能 (NUM)  
  83. {  
  84.     无功 hoseHeight = 830;  
  85.     无功 acrossHeight = 300;  
  86.     无功 downHeight = 100 +次getRandom(400);  
  87.     无功 upHeight = 1100 - downHeight - acrossHeight;  
  88.   
  89.     无功 hoseX = 400 *民;  
  90.   
  91.     无功 HoseName = FP_MAIN_TEXTURE.HOSE;  
  92.     无功 ccSpriteDown = cc.Sprite.createWithSpriteFrameName(HoseName [0]);  
  93.     ccSpriteDown.setZOrder(1);  
  94.     ccSpriteDown.setAnchorPoint(cc.p(0,0));  
  95.     ccSpriteDown.setPosition(cc.p(hoseX,0));  
  96.     ccSpriteDown.setScaleY(downHeight / hoseHeight);  
  97.   
  98.     无功 ccSpriteUp = cc.Sprite.createWithSpriteFrameName(HoseName [1]);  
  99.     ccSpriteUp.setZOrder(1);  
  100.     ccSpriteUp.setAnchorPoint(cc.p(0,0));  
  101.     ccSpriteUp.setPosition(cc.p(hoseX,downHeight + acrossHeight));  
  102.     ccSpriteUp.setScaleY(upHeight / hoseHeight);  
  103.   
  104.     这个。hoseNode.addChild(ccSpriteDown);  
  105.     这个。hoseNode.addChild(ccSpriteUp);  
  106.     这个。hoseSpriteList.push(ccSpriteDown);  
  107.     这个。hoseSpriteList.push(ccSpriteUp);  
  108.     返回 空值;  
  109. }  
  110.   
  111. MainLayer.prototype.groundRun =  函数 ()  
  112. {  
  113.     无功 动作1 = cc.MoveTo.create(0.5,cc.p(-120,0));  
  114.     变种 动作2 = cc.MoveTo.create(0,cc.p(0,0));  
  115.     变种 行动= cc.Sequence.create(动作1,动作2);  
  116.     ground.runAction(cc.RepeatForever.create(行动));  
  117. }  
  118.   
  119. MainLayer.prototype.birdReadyAction =  函数 ()  
  120. {  
  121.     变种 birdX =  这个bird.getPositionX();  
  122.     变种 的Birdy =  这个bird.getPositionY();  
  123.     变种 时间= BIRDY / 2000;  
  124.     无功 actionFrame = cc.Animate.create(cc.AnimationCache.getInstance()getAnimation( 飞行” ));  
  125.     无功 flyAction = cc.Repeat.create(actionFrame,90000);  
  126.     这个。bird.runAction(cc.Sequence.create(  
  127.             flyAction)  
  128.     );  
  129. }  
  130.   
  131. MainLayer.prototype.birdFallAction =  函数 ()  
  132. {  
  133.     这个游戏模式= OVER了。;  
  134.     。bird.stopAllActions();  
  135.     。ground.stopAllActions();  
  136.     变种 birdX =  这个bird.getPositionX();  
  137.     变种 的Birdy =  这个bird.getPositionY();  
  138.     变种 时间= BIRDY / 2000;  
  139.     这个。bird.runAction(cc.Sequence.create(  
  140.             cc.DelayTime.create(0.1),  
  141.             cc.Spawn.create(cc.RotateTo.create(时间,90),cc.MoveTo.create(时间,cc.p(birdX,50))))  
  142.     );  
  143.     这个。overNode.setVisible();  
  144. }  
  145.   
  146. MainLayer.prototype.birdRiseAction =  函数 ()  
  147. {  
  148.     无功 riseHeight = 60;  
  149.     变种 birdX =  这个bird.getPositionX();  
  150.     变种 的Birdy =  这个bird.getPositionY();  
  151.     变种 时间= BIRDY / 600;  
  152.   
  153.     无功 actionFrame = cc.Animate.create(cc.AnimationCache.getInstance()getAnimation( 飞行” ));  
  154.     无功 flyAction = cc.Repeat.create(actionFrame,90000);  
  155.     无功 riseAction1 = cc.MoveTo.create(0.2,cc.p(birdX,BIRDY + riseHeight));  
  156.     无功 riseAction2 = cc.RotateTo.create(0,-30);  
  157.     无功 riseAction = cc.Spawn.create(riseAction1,riseAction2);  
  158.     无功 fallAction1 = cc.MoveTo.create(时间,cc.p(birdX,50));  
  159.     无功 fallAction2 = cc.Sequence.create(cc.DelayTime.create(时间/ 6),cc.RotateTo.create(0,30));  
  160.     无功 fallAction = cc.Spawn.create(fallAction1,fallAction2);  
  161.   
  162.     。bird.stopAllActions();  
  163.     这个。bird.runAction(cc.Spawn.create(  
  164.             cc.Sequence.create(riseAction,cc.DelayTime.create(0.1),fallAction)  
  165.             flyAction)  
  166.     );  
  167. }  
  168.   
  169. MainLayer.prototype.onUpdate =  功能 (DT)  
  170. {  
  171.     如果 (这个。游戏模式!= START){  
  172.         返回;  
  173.     }  
  174.     这个。passTime + = DT;  
  175.   
  176.     这个。hoseNode.setPositionX(800 - 200 *  passTime。);  
  177.     这个。bird.setPositionX(-500 +200 *  passTime。);  
  178.     。checkCollision();  
  179. }  
  180.   
  181. MainLayer.prototype.checkCollision =  函数 ()  
  182. {  
  183.     如果 (。bird.getPositionY()<60){  
  184.         cc.log( 地板” );  
  185.         。birdFallAction();  
  186.         返回;  
  187.     }  
  188.      (变种 I = 0;我<  这个。hoseSpriteList.length,我+ +){  
  189.         变种 软管=  这个。hoseSpriteList由[i];  
  190.         如果 (!这个。isInScreen(软管)){  
  191.             / /继续;  
  192.         }  
  193.   
  194.         如果 (cc.rectIntersectsRect(hose.getBoundingBox(),  。bird.getBoundingBox())){  
  195.             cc.log( 软管positionX ==”  + hose.getBoundingBox()×);  
  196.             cc.log(“this.bird positionX ==”  +  。bird.getBoundingBox()×);  
  197.             cc.log( 我==”  + I);  
  198.             cc.log(“birdFallAction” );  
  199.             。birdFallAction();  
  200.             返回;  
  201.         }  
  202.     }  
  203. }  
  204.   
  205. MainLayer.prototype.isInScreen =  功能 (雪碧)  
  206. {  
  207.     返回 (sprite.getPositionX()> 0 && sprite.getPositionX()<720);  
  208. }  
  209.   
  210. MainLayer.prototype.onExitClicked =  函数 ()  
  211. {  
  212. }  
  213.   
  214. MainLayer.prototype.onStartClicked =  函数 ()  
  215. {  
  216.     。cc.Director.getInstance()恢复();  
  217.     cc.BuilderReader.runScene( “”  “MainLayer” );  
  218. }  
  219.   
  220. MainLayer.prototype.onExit =  函数 ()  
  221. {  
  222.     cc.log( 的OnExit” );  
  223. }  
  224.   
  225. MainLayer.prototype.onTouchesBegan =  功能 (触摸,事件)  
  226. {  
  227.     无功 LOC =触动[0]的getLocation();  
  228. }  
  229.   
  230. MainLayer.prototype.onTouchesMoved =  功能 (触摸,事件)  
  231. {  
  232. }  
  233.   
  234. MainLayer.prototype.onTouchesEnded =  功能 (触摸,事件)  
  235. {  
  236.     如果 (这个。游戏模式== OVER){  
  237.         返回;  
  238.     }  
  239.   
  240.     如果 (这个。游戏模式== READY){  
  241.         这个。游戏模式= START;  
  242.         这个。readyNode.setVisible();  
  243.     }  
  244.   
  245.     无功 LOC =触动[0]的getLocation();  
  246.     。birdRiseAction();  
  247.   
  248. }  
  249.   
  250. 功能 isInRect(ccRect,ccTouchBeganPos)  
  251. {  
  252.     如果 (ccTouchBeganPos.x> ccRect.x && ccTouchBeganPos.x <(ccRect.x + ccRect.width)){  
  253.         如果 (ccTouchBeganPos.y> ccRect.y && ccTouchBeganPos.y <(ccRect.y + ccRect.height)){  
  254.             返回 ;  
  255.         }  
  256.     }  
  257.     返回 ;  
  258. }  
  259.   
  260. 函数 次getRandom(MAXSIZE)  
  261. {  
  262.     返回 Math.floor(Math.random()有关* MAXSIZE)%MAXSIZE;  
  263. }  

再次提示代码下载地址:

 

CSDN下载:http://download.csdn.net/detail/touchsnow/6912707

  百度云盘:http://pan.baidu.com/s/1pJnWDb9

  金山快盘:http://www.kuaipan.cn/file/id_25348935635745384.htm?source=1

本文地址:http://blog.csdn.net/touchsnow/article/details/19071961

1

酷毙

雷人
1

鲜花

鸡蛋

漂亮

刚表态过的朋友 (2 人)

  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部