Joypad problem

Non-platform specific questions.

Joypad problem

Postby Jagmaster » Fri Jun 17, 2011 12:34 pm

I'm having trouble with Joypad input.

Code: Select all
A=GetJoystickButton[0];

if(A==1&&canjump==1&&canpress==1)
{
jump
canjump=0;
canpress=0;
}


The player keeps jumping. It's as if I have keydown set to repeat. :?
How do I tell it to only jump when I tap the button ?
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

Re: Joypad problem

Postby Hblade » Fri Jun 17, 2011 3:56 pm

theres are quite confusing to fix XD Try this
code:
Code: Select all
if (A==1) {
switch(canjump) {
case 0: canpress=0;
break;
case 1:
    if (canpress==1) {
   //do jump code
    canjump=0;
                            }
break;
}
}


That code might have a few bugs in it, but thats because it was untested and I didn't even open GE :P

that should work though.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Joypad problem

Postby lcl » Sat Jun 18, 2011 9:16 pm

Jagmaster wrote:I'm having trouble with Joypad input.

Code: Select all
A=GetJoystickButton[0];

if(A==1&&canjump==1&&canpress==1)
{
jump
canjump=0;
canpress=0;
}


The player keeps jumping. It's as if I have keydown set to repeat. :?
How do I tell it to only jump when I tap the button ?

Your code seems to be alright, it sets canpress and canjump to 0, so it shouldn't repeat.
So, this code is not the problem. Go and check what is the value of the canjump variable during the game. Create a text actor, and make it show the canjump value. I'm pretty sure there is something making canjump equal to 1 even when it shouldn't.

Tell me what you find out! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest