- Home /
Sprite Doesnt show up
My "Bug" sprite doesnt work all the health and stats decrease/increase properly that is for sure
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SpriteChanger : MonoBehaviour {
public Sprite AlienEgg;
public Sprite HumanEgg;
public Sprite BugEgg;
public Sprite ChickenEgg;
public Sprite DogEgg;
public Sprite Bug;
public static SpriteRenderer spriteRenderer;
public static int EggBought = 0;
public Text Health;
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer>();
}
void Update (){
if (EggBought == 1) {
spriteRenderer.sprite = BugEgg;
}
else if (EggBought == 2) {
spriteRenderer.sprite = DogEgg;
}
else if (EggBought == 3) {
spriteRenderer.sprite = ChickenEgg;
}
else if (EggBought == 4) {
spriteRenderer.sprite = HumanEgg;
}
else if (EggBought == 5){
spriteRenderer.sprite = AlienEgg;
}
Health.text = ("") + Health;
}
// Update is called once per frame
void OnMouseDown () {
if (EggBought == 1) {
if (Storage.health >= 0) {
Storage.health -= 1;
Debug.Log (Storage.health);
if (Storage.health == 0) {
spriteRenderer.sprite = Bug;
Storage.money += 50;
}
}
}
}
}
Comment