- Home /
Question by
hariprasadh10792 · Jun 25, 2011 at 08:20 AM ·
androidspritemobilejumpside scroller
touch anywhere on screen to jump
Hey guys I need help to make a character sprite jump when there is a touch detected anywhere on screen. So can you please tell me the code that registers the touch on screen..
Thanks in Advance
Comment
Answer by gbelini · Jan 02, 2013 at 07:33 PM
this code do not work?
void Update()
{
if (Input.GetMouseButtonDown(0))
{
//Touch anywhere
}
}
Just tested it out. Worked great on desktop and iPad $$anonymous$$ini both. Thanks!
Answer by benni05 · Jun 25, 2011 at 04:31 PM
From the script reference this is how to detect touches.
function Update () {
var fingerCount = 0;
for (var touch : Touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
fingerCount++;
}
if (fingerCount > 0)
print ("User has " + fingerCount + " finger(s) touching the screen");
}