- Home /
Question by
Sudah Pero · Mar 16, 2014 at 06:18 AM ·
scenegameover
How to Create game Over Scene in this Scripts
private bool GuiOn=false,bisa=true;
public GUIStyle template;
// The force which is added when the player jumps
// This can be changed in the Inspector window
public Vector2 jumpForce = new Vector2(0, 300);
// Update is called once per frame
void Update ()
{
if (bisa)
{
skor.guiText.text = score.ToString ();
// Jump
if (Input.GetKeyUp("space"))
{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(jumpForce);
}
if(Input.touchCount > 0) {
for (int i = 0; i<Input.touchCount; i++) {
if (Input.GetTouch(i).phase == TouchPhase.Ended)
{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(jumpForce);
}
}
}
}
}
void OnCollisionEnter2D (Collision2D col)
{
if (col.gameObject.tag == "rocks") {
GuiOn=true;
}
}
void OnTriggerEnter2D (Collider2D col)
{
if (col.gameObject.tag == "score") {
Debug.Log ("scoooooooooorrrrreeeeeee");
score += 1;
audio.Play();
}
}
// Die by being off screen
Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
if (screenPosition.y > Screen.height || screenPosition.y < 0)
{
Die();
}
}
// Die by collision
void OnCollisionEnter2D(Collision2D other)
{
Die();
}
void Die()
{
Application.LoadLevel(Scene 03 - game over);
}
}
How To Create Game Over in This c#scripts
Please help me
Comment
Do you want the GameOver to be a separate level/scene? If so, Application.LoadLevel is the right approach.