| View previous topic :: View next topic |
| Author |
Message |
fattymc03
Joined: 11 Feb 2006 Posts: 18
|
Posted: Sat Feb 11, 2006 12:26 am Post subject: How to detect diagonal on the directional pad.. |
|
|
| How can I detect the pressing of a diagonal on the directional pad. Like pressing up and right at the same time. |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Sat Feb 11, 2006 12:46 am Post subject: |
|
|
Here for 'hardcoded':
| Code: |
if pad:up() and pad:right() then
....
elseif pad:up() and pad:left() then
....
elseif pad:up() then
....
elseif pad:left() then
....
end
|
Make sure the diagonals are before the 'normal' ones.
You can prolly use this if you use it for some kind of value changes, like y=y+1 and x=x+1 etc.:
| Code: |
if pad:up() then
....
end
if pad:right() then
....
end
if pad:left() then
....
end
|
Last edited by MikeHaggar on Sat Feb 11, 2006 7:36 am; edited 1 time in total |
|
| Back to top |
|
 |
fattymc03
Joined: 11 Feb 2006 Posts: 18
|
Posted: Sat Feb 11, 2006 2:09 am Post subject: |
|
|
| thanks for the quick response i appreciate it. that works, but its not that fluid. its like it moves in the direction of the first detected button. you have to press them both at exactly the same time to get it to move correctly, but it is not that fluid. are there any other solutions? |
|
| Back to top |
|
 |
fattymc03
Joined: 11 Feb 2006 Posts: 18
|
Posted: Sat Feb 11, 2006 2:13 am Post subject: |
|
|
| opps, sorry about the above post. i didnt realize i had a return statement in the wrong place. it works correctly now. i was wondering if you could explain the buttonmasks and when is the correct time to use them. thanks again. |
|
| Back to top |
|
 |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Sat Feb 11, 2006 2:49 am Post subject: |
|
|
Suggest a timer to allow the user to press two buttons before testing them. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
CaseyB
Joined: 23 Jan 2006 Posts: 15
|
Posted: Sat Feb 11, 2006 3:04 am Post subject: |
|
|
If you do it the second way suggested by MikeHaggar, i.e.,
| MikeHaggar wrote: |
You can prolly use this if you use it for some kind of value changes, like y=y+1 and x=x+1 etc.:
| Code: |
if pad:up() then
....
end
if pad:right() then
....
end
if pad:left() then
....
end
|
|
It should work perfectly without having to introduce the complexity of a timer or worrying about what order to call the checks in. |
|
| Back to top |
|
 |
fattymc03
Joined: 11 Feb 2006 Posts: 18
|
Posted: Sat Feb 11, 2006 4:46 am Post subject: |
|
|
| mike haggars way worked fine.. thanks guys |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Sat Feb 11, 2006 7:35 am Post subject: |
|
|
| fattymc03 wrote: | | i was wondering if you could explain the buttonmasks and when is the correct time to use them. thanks again. |
hm... what do you mean? |
|
| Back to top |
|
 |
|