FlappyBird开发总结(八)——MainScene场景
2015-03-06 16:25
127 查看
这个游戏呢,基本是完成了,不过有点单调,所以我加了个主场景,用来控制游戏的难度,说白了就是给不同的速度给小鸟啦,废话不多说,上代码:
不,先上图片
NGUI创建不多说,先创建一个脚本
MainSceneManager.cs
恩,写了它就别管了
然后每个按钮各有一个脚本:
恩恩,说白了就是记录一个值,游戏难度的值,然后我们把这个值要变成小鸟的速度,这就需要修改下Bird.cs了
把Bird.cs脚本中的这个函数改一下,哦了,基本上游戏完毕了,创建声源就那几个步骤我也不写了,然后就是细节上的调试和UI了,我的发布的APK在第一遍总结中给了地址了,好了,全篇总结完毕!呼啦啦~~
不,先上图片
NGUI创建不多说,先创建一个脚本
MainSceneManager.cs
using UnityEngine; using System.Collections; public class MainSeceneManager { public static int gameLevel;//传递游戏难度 }
恩,写了它就别管了
然后每个按钮各有一个脚本:
using UnityEngine; using System.Collections; public class ChooseEasyLevel : MonoBehaviour { public void SendLevel() { MainSeceneManager.gameLevel = 2; Application.LoadLevel("StartGame"); } }
using UnityEngine; using System.Collections; public class ChooseSimpelLevel : MonoBehaviour { public void SendLevel() { MainSeceneManager.gameLevel = 5; Application.LoadLevel("StartGame"); } }
using UnityEngine; using System.Collections; public class ChooseHardlLevel : MonoBehaviour { public void SendLevel() { MainSeceneManager.gameLevel = 8; Application.LoadLevel("StartGame"); } }
恩恩,说白了就是记录一个值,游戏难度的值,然后我们把这个值要变成小鸟的速度,这就需要修改下Bird.cs了
public void GetTheGameBegin() { currentBirdSpeed = MainSeceneManager.gameLevel; this.rigidbody.velocity = new Vector3(currentBirdSpeed, 0, 0); this.rigidbody.useGravity = true; }
把Bird.cs脚本中的这个函数改一下,哦了,基本上游戏完毕了,创建声源就那几个步骤我也不写了,然后就是细节上的调试和UI了,我的发布的APK在第一遍总结中给了地址了,好了,全篇总结完毕!呼啦啦~~
相关文章推荐
- FlappyBird开发总结(三)——小鸟脚本,让小鸟煽动翅膀
- FlappyBird开发总结(五)——背景延伸
- cocos2dx3.3开发FlappyBird总结十六:游戏层实现
- FlappyBird开发总结(一)—— 开发前所必备
- cocos2dx3.3开发FlappyBird总结十四:常量定义
- cocos2dx3.3开发FlappyBird总结十三:数字特效类
- cocos2dx3.3开发FlappyBird总结一:背景介绍
- cocos2dx3.3开发FlappyBird总结六:设计共享小鸟类(主角)
- cocos2dx3.3开发FlappyBird总结五:说说屏幕适配
- cocos2dx3.3开发FlappyBird总结十五:记录玩家得分
- cocos2dx3.3开发FlappyBird总结十:背景层设计
- FlappyBird开发总结(七)—— GameOver计分板
- cocos2dx3.3开发FlappyBird总结四:资源管理类
- cocos2dx3.3开发FlappyBird总结八:载入场景LoadingScene
- cocos2dx3.3开发FlappyBird总结十二:状态层设计
- cocos2dx3.3开发FlappyBird总结十七:结束语
- cocos2dx3.3开发FlappyBird总结三:项目剖析
- cocos2dx3.3开发FlappyBird总结九:欢迎场景(WelcomeScene)
- FlappyBird开发总结(二)——场景
- cocos2dxFlappyBird开发总结二:开发环境介绍