domingo, 14 de febrero de 2016

Introducción a Infinite Squared Run | Introduction to Infinite Squared Run









                   Español                                                                               English


Mi primer juego, hecho para Android en Unity pero en realidad lo único que lo diferencia entre poder jugar en Android o PC es literalmente 1 línea de código:

 ---------------------------------

My first game, made for Android in Unity but the only thing that makes this game to be played in Android  or Pc is literally 1 line of code:

 ---------------------------------
If ( Input.GetKeyDown("space") ) es para PC | is for PC

If( Input.touchCount > 0 && Input.GetTouch(0).phase ==  TouchPhase.Began ) es para Android | is for Android
Lo que hace la versión PC es simplemente ver si se presionó la barra espaciadora y ejecuta el código. Mientras que la versión Android es un poco más rebuscada, ya que lo deseado es que el jugador toque la pantalla con 1 solo dedo,no varios.

Por lo que la primera parte se encarga de ver si la pantalla esta presionada, por lo que touchCount valdría 1 o más en caso de que haya más de 1 dedo en la pantalla, luego, para 1 solo dedo "GetTouch(0)" se le debe asignar una fase de contacto (contacto-pantalla-dedo iniciado), la fase llamada para cuando haya 1 dedo es "TouchPhase.Began", lo que permite ejecutar el código adentro del IF.

La ventaja de esto último es que solo se tomará en cuenta 1 presión (1 dedo en pantalla) para ejecutar la acción, lo que permite que no ocurran errores si el jugador tiene mas de un dedo en la pantalla (como ejecutar la secuencia varias veces).

 ---------------------------------


What the PC version does is very simple, checks if the space bar was pressed, if so, execute the code. The Android version on the other hand works in a different way, as the desired funcionality is for the player to only touch once the screen (with only one finger).

For which the first part of the statement is to check if the screen was touch, 1 finger on the screen will give "touchCount" the value of 1, if there were more fingers touching the screen, this value would be bigger. Then, a phase has to be assignated (contact screen-finger began)  for 1 finger only "GetTouch(0)", which will be "TouchPhase.Began", that will enable to execute the IF statement.

The advantage of this last version is that it will only respond to 1 touch (1 finger only touching the screen) to execute the action, which disables the possibility of error if the player has more than 1 finger on the screen (such as executing the statement multiple times).


No hay comentarios.:

Publicar un comentario