Advertisement
SokazGames

GameController

Mar 11th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class GameController : MonoBehaviour {
  5.  
  6.    
  7.     public Sprite jumpingJack1;
  8.     public Sprite jumpingJack2;
  9.     public int spriteNum;
  10.     Sprite playerSprite;
  11.     GameObject player;
  12.    
  13.  
  14.     // Use this for initialization
  15.     void Start () {
  16.         player = GameObject.FindGameObjectWithTag("player");
  17.         playerSprite = player.GetComponent<SpriteRenderer>().sprite;
  18.     }
  19.    
  20.     // Update is called once per frame
  21.     void Update () {
  22.  
  23.         if (Input.GetMouseButtonDown(0)) {
  24.             Debug.Log("pressed");
  25.             spriteNum += 1;
  26.         }
  27.         if (spriteNum % 2 == 0){
  28.            playerSprite = jumpingJack1;
  29.         }
  30.         else {
  31.            playerSprite = jumpingJack2;
  32.         }
  33.    
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement