Page 1 of 1

controller player jumping problem

Posted: Tue May 27, 2014 5:23 pm
by smoking bunny
howdy

ive run into some little problem, looked through forum and wiki, but cant anything.
so, i cant seem to get my controller to get the player to jump . got it to move, no problem. but the buttons are not working to the same standard as say the d-pad

this is the code im using. bear in mind im giving both jump code for sharing with [or command] the keyboard and by itself. i just uncommented for this post.
though feel its an easy answer in the end

Code: Select all

function player:jumping(key)
	if key == ' ' or joyStick:isGamepadDown('a') then
        if self.jump then
	       self.speedY = self.jumpSpeed
            self.jump = false
    	end
    end
--second jump
    if joyStick:isGamepadDown('a') then
        if self.jump then
            self.speedY = self.jumpSpeed
            self.jump = false
        end
    end
end
using the 360 controller, since its the best option i feel for gaming dev and controllers in general. though my hands down [best] controller is the gamecube one ;)

Re: controller player jumping problem

Posted: Tue May 27, 2014 5:41 pm
by zorfmorf
I never used joysticks/gamepads in löve, but the documentation seems to imply that you should use the button's index, not name:

Code: Select all

 
anyDown = Joystick:isDown( buttonN, ... )

number buttonN
    The index of a button to check. 


Wuups, I misread. Ignore what I wrote.

Re: controller player jumping problem

Posted: Wed May 28, 2014 10:18 am
by smoking bunny
HA, no worries.

so... anyone else. its just a bit weird this not working to how the lef/right d-pad works.
plus i know full well the buttons work, its a new controller, plus have been playing some steam games also. just odd

Re: controller player jumping problem

Posted: Wed May 28, 2014 11:44 am
by micha
I'd rather use the joystickpressed-call back than checking joyStick:isGamepadDown each frame.

Re: controller player jumping problem

Posted: Wed May 28, 2014 12:14 pm
by smoking bunny
oooh, ill take a look after some lunch.
thanks ;)

Re: controller player jumping problem

Posted: Wed May 28, 2014 2:25 pm
by smoking bunny
so i have tried this. but no go. no errors either

Code: Select all

if love.joystickpressed(joyStick, 'a') then
        if self.jump then
            self.speedY = self.jumpSpeed
            self.jump = false
        end
end

Re: controller player jumping problem

Posted: Wed May 28, 2014 2:42 pm
by DaedalusYoung
love.joystickpressed is a callback function you need to define yourself. Putting it in an if-statement won't work because the function is not defined. And should not be called by you either. You write the function, and then it will be called by LÖVE when the user presses a button on any joystick device.

Re: controller player jumping problem

Posted: Wed May 28, 2014 3:15 pm
by smoking bunny
ah yeah, plus as well i have them in this project anyhow for different things. i just had a brain fart and seeped out.

cheers

Re: controller player jumping problem

Posted: Wed May 28, 2014 4:59 pm
by smoking bunny
ive actually put the findings into the wiki page as well. im gonna do that for any wikis that do not have any example code. this just helps future LÖVErs ;)

thanks again