Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Saltar : MonoBehaviour {
- //TEXTURA DEL BOTON PARA SALTAR
- public GUITexture botonSaltar;
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- //LLAMAR AL VOID
- programarSalto ();
- }
- void programarSalto()
- {
- //DETECTAR TODOS LOS TOQUES EN LA PANTALLA
- foreach(Touch toque in Input.touches)
- {
- //SOLO TRATAR LOS TOQUES SOBRE ESE BOTON
- //SI NO DARA ERROR EN HitTest
- if(botonSaltar)
- {
- //SABER SI HIZO TOQUE SOBRE EL BOTON
- bool hitTest = botonSaltar.HitTest(toque.position);
- //EVENTOS SOBRE TOQUE CUANDO SE LEVANTA EL DEDO
- if(toque.phase == TouchPhase.Ended)
- {
- if(hitTest)
- {
- Debug.Log("Saltar al levantar el dedo");
- }
- }
- //EVENTOS SOBRE TOQUE CUANDO SE PONE EL DEDO
- if(toque.phase == TouchPhase.Began)
- {
- if(hitTest)
- {
- Debug.Log("Saltar al poner el dedo");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment