controller player jumping problem

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
smoking bunny
Citizen
Posts: 67
Joined: Wed May 07, 2014 9:04 am
Contact:

controller player jumping problem

Post 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 ;)
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
User avatar
zorfmorf
Prole
Posts: 35
Joined: Sat Mar 10, 2012 12:31 pm

Re: controller player jumping problem

Post 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.
User avatar
smoking bunny
Citizen
Posts: 67
Joined: Wed May 07, 2014 9:04 am
Contact:

Re: controller player jumping problem

Post 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
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: controller player jumping problem

Post by micha »

I'd rather use the joystickpressed-call back than checking joyStick:isGamepadDown each frame.
User avatar
smoking bunny
Citizen
Posts: 67
Joined: Wed May 07, 2014 9:04 am
Contact:

Re: controller player jumping problem

Post by smoking bunny »

oooh, ill take a look after some lunch.
thanks ;)
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
User avatar
smoking bunny
Citizen
Posts: 67
Joined: Wed May 07, 2014 9:04 am
Contact:

Re: controller player jumping problem

Post 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
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
User avatar
DaedalusYoung
Party member
Posts: 407
Joined: Sun Jul 14, 2013 8:04 pm

Re: controller player jumping problem

Post 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.
User avatar
smoking bunny
Citizen
Posts: 67
Joined: Wed May 07, 2014 9:04 am
Contact:

Re: controller player jumping problem

Post 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
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
User avatar
smoking bunny
Citizen
Posts: 67
Joined: Wed May 07, 2014 9:04 am
Contact:

Re: controller player jumping problem

Post 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
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
Post Reply

Who is online

Users browsing this forum: No registered users and 81 guests