游戏效果图
通过陀螺仪使得小球有运动的力
public class groy : MonoBehaviour { float x; float y; Gyroscope go; void Start() { go = Input.gyro; go.enabled = true; } void Update() { x = Input.acceleration.x; y = Input.acceleration.y; this.GetComponent<Rigidbody>().AddForce(new Vector3(-x, 0, -y) * 20); } }
开始的UI场景,应用于按钮(开始,和游戏结束)
public class StartUi : MonoBehaviour { public void Reaply() { Time.timeScale = 1; Application.LoadLevel(1); } public void Quit() { Application.Quit(); } }
用触发器时刻判断,进洞重新开始,到终点弹出重玩,下一关按钮进行选择,用GUI制作了简易放回主菜单(回到场景0)按键,,
public class Mover : MonoBehaviour { public GameObject go; private void OnTriggerStay(Collider other) { if (other.name == "target") { go.gameObject.SetActive(true); Time.timeScale = 0; } else { Application.LoadLevel(1); } } private void OnTriggerEnter(Collider other) { if (other.name == "target") { go.gameObject.SetActive(true); Time.timeScale = 0; } else { Application.LoadLevel(1); } } private void OnGUI() { GUIStyle style = new GUIStyle(); style.fontSize = 36; if (GUI.Button(new Rect(50,30, 200,80 ), "返回菜单",style)){ Application.LoadLevel(0); } } }
作者:Czhenya 发表于2017/8/19 11:49:20 原文链接
阅读:55 评论:0 查看评论