|
Hello i am learning android development i created a simple 2D car game with left arrow used to go left and right arrow to right. I use these commands if (Input.GetKey(KeyCode.LeftArrow)) now that i am successful with it in pc i want it to use with my android. I created 2 guiText '<' for left and '>' for right i got them on the screen but i dont know how to implement them in my script and use it like 'player touches '>' for right' .. please help
(comments are locked)
|
|
Hi There! For your entertainment and mine I created a simple script which should implement touch controls for phones (I don't have a mobile phone!) Oh, also, whilst you 'could' use GuiText, a guiTexture is much more easier to use for mobile input (although neither is preferable!) Regardless, here's the code: dude i will sure check this when i get home , this community is best!!
Jun 04 '11 at 03:58 PM
Anonymous 1
can u explain me how it works ?
Jun 05 '11 at 03:47 AM
Anonymous 1
Hi, it uses a GuiTexture (1 drawcall per texture on screen btw), and uses the in-built function HitTest (for the GuiTexture) reading if you have your finger is on a point. If your finger is on a point inside a guiTexture (this includes any alpha around the edges of an opaque button), it will trigger a repeating (every update) function -- in this case ButtonPressed. Touches for a phone are read as Input.touches, which is an array that collects every touch you do. Each touch has different modes, and we're only interested in touches that are currrently on the screen. Each important line of code also explains what that line does. Please be more precise if something is confusing in particular.
Jun 06 '11 at 12:10 AM
kariwmklawm
thanx for your help but ( i am a little new ) how do implement this in my script ? like i said i use " if (Input.GetKey(KeyCode.LeftArrow))" how can i replace your code with mine ? thanx
Jun 06 '11 at 04:18 AM
Anonymous 1
anyone ?? i am suffering
Jun 10 '11 at 11:58 AM
Anonymous 1
(comments are locked)
|
|
how do you use this code to rotate a sphere on ios when the user drags their finger around the gui texture
(comments are locked)
|
