x


mobile programming questions

I have a question involving the mobile programming, mainly the input for touch. I am in the development/design phase of the mobile game and i wanted to know if for the touch sensor specifically android if there is a function similar to onmousedown where i am touching a button and holding it down and while it is down to instantiate and fire a projectile.

thanks in advance for any and all help.

more ▼

asked Jan 31 '12 at 06:57 PM

kievar1983 gravatar image

kievar1983
66 9 11 15

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

There is a stationary phase with the touch class.

http://unity3d.com/support/documentation/ScriptReference/TouchPhase.html

So:

void Update()
       {
         if( Input.touchCount == 1 )
         {
          Touch touch_0 = Input.touches[0];

          switch( touch_0.phase )
          {
          case TouchPhase.Stationary:
              //Do checks here
              break;
          default:
              break;
          }
         }
       }
more ▼

answered Jan 31 '12 at 07:21 PM

dannyskim gravatar image

dannyskim
3.8k 5 7 19

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5049
x2447
x576
x408

asked: Jan 31 '12 at 06:57 PM

Seen: 585 times

Last Updated: Jan 31 '12 at 07:21 PM