他のシーンを呼び出すには、build settingで設定します。
呼び出しのスクリプトです。
#pragma strict var ball : Transform; var n : int = 0; function Update () { if (Input.GetButtonUp("Jump")){ Instantiate(ball, transform.position, transform.rotation); n++; } if (n > 10){ Application.LoadLevel("gameover"); } }
Gameの書き出しは、build and settingでbuidl and rundで行います。
player
#pragma strict function Update () { var x: float = Input.GetAxis("Horizontal"); transform.Translate(x * 0.2, 0, 0); } function OnCollisionEnter(obj: Collision) { if (obj.gameObject.name == "Enemy(Clone)"){ transform.localScale.x -= Random.Range(0.1, 0.5); if (transform.localScale.x < 1.0) transform.localScale.x = 1.0; } }
enemy
#pragma strict function Update () { transform.position.z -= 0.1; transform.Rotate(1, 1, 1); if (transform.position.z < -12.0){ Application.LoadLevel("GameOver"); } } function OnCollisionEnter(){ Destroy(gameObject); }
#pragma strict var enemy: Transform; function Update () { if(Time.frameCount % 60 == 0){ Instantiate(enemy, Vector3(Random.Range(-5.0,5.0),1,8), transform.rotation); } }
#pragma strict var style: GUIStyle; function OnGUI(){ GUI.Label(Rect(10, 10, 100, 30), "GameOver", style); }