Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

the problem of touch screen logic

$
0
0
en hey.....I got a problem of how to create a button on mobile device, firstly I did a little research about touch screen logic, therefore I got this code: Rect leftIconRect = new Rect (10, Screen.height-110, 150, 100); Rect rightIconRect = new Rect(170, Screen.height-110, 150, 100); Rect JumpIconRect = new Rect (Screen.width-160, Screen.height-110, 150, 100); void Update () { foreach(Touch t in Input.touches) { Vector2 vec = t.position; vec.y = Screen.height - vec.y; if(leftIconRect.Contains(vec)) axisH = -1; if(rightIconRect.Contains(vec))axisH = 1; if(JumpIconRect.Contains(vec))jumpB = true; } } It works!!! but when I build a game for android phone, the "jump"touch was not working as I expected. The "touch" is not like button, so if my finger keep pressing on the screen the jump function will always be true!! so I wonder is there any way to make the "jump" touch as a general button, just working once when I click it!!!!! I'm not sure did I explain the problem clearly..... thank you....

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>