Search Unity

Flicking marbles game

Discussion in 'iOS and tvOS' started by Mirek Uhlir, Mar 17, 2011.

  1. Mirek Uhlir

    Mirek Uhlir

    Joined:
    Dec 25, 2009
    Posts:
    124
    Hi,
    I am new to iOS development and especially to touch control. I would like to make simple ​​flicking marbles game.
    I looked at the documentation on TouchPhase, but I'm not sure how to do it.
    Thanks for any advice.
     
  2. nggs

    nggs

    Joined:
    Oct 23, 2009
    Posts:
    90
    Here's some touch phase code I used. I only had to determine if the swipe went left, right, up, or down. You'll have to sort out the precise direction of the swipe, but this should give you a head start.
    Code (csharp):
    1.  
    2.         foreach (Touch touch in Input.touches)
    3.         {
    4.             if (touch.phase == TouchPhase.Began)
    5.             {
    6.                 if (_paused == false)
    7.                 {
    8.                     downpoint = Input.mousePosition;
    9.                 }
    10.             }
    11.  
    12.             if (touch.phase == TouchPhase.Ended)
    13.             {
    14.                 if (_paused == false)
    15.                 {
    16.                     uppoint = Input.mousePosition;
    17.                 }
    18.             }
    19.         }
    20.