| View previous topic :: View next topic |
| Author |
Message |
Maca
Joined: 27 Aug 2007 Posts: 2
|
Posted: Mon Aug 27, 2007 4:17 am Post subject: Button press/release |
|
|
I'm trying to implement semi-automatic gunfire for my game.
With this code here. If I press square, the gun sound will play and if I release square it will play again
when I press square again, which is what I want.
But if while I'm holding square and then press any other button, the wav will play, and then again when I release that button. I need to find a way to stop it from playing when I press/release the other buttons while holding square?
| Code: |
while ( 1 )
{
sceCtrlReadBufferPositive( &pad, 1 );
if ( pad.Buttons & PSP_CTRL_SQUARE )
{
if( pad.Buttons != lastPad.Buttons )
{
WAV_Play(ourWav);
}
}
lastPad = pad;
} |
|
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Aug 27, 2007 5:03 am Post subject: |
|
|
I guess you can replace the "if (pad.Buttons != lastPad.Button)s" by
"if (!(lastpad.Buttons & PSP_CTRL_SQUARE))" |
|
| Back to top |
|
 |
Maca
Joined: 27 Aug 2007 Posts: 2
|
Posted: Mon Aug 27, 2007 5:09 am Post subject: |
|
|
| Holy shit, man, thanks a lot. ! |
|
| Back to top |
|
 |
|