FlappyBird开发总结(八)——MainScene场景

这个游戏呢,基本是完成了,不过有点单调,所以我加了个主场景,用来控制游戏的难度,说白了就是给不同的速度给小鸟啦,废话不多说,上代码:
不,先上图片这里写图片描述
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在第一遍总结中给了地址了,好了,全篇总结完毕!呼啦啦~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值