+ 5

Jumping Animation

Can anyone help me create a working jump animation? I had a working one, except it went below the screen. I implemented it so when the y axis is at the bottom, the velocity is equal to 0, making it land properly. But then that if statement override everything and jump did nothing. I have been trying this for ages but it won't work. Does anyone have any ideas for an jump animation that works. https://code.sololearn.com/WSC3JL587LQ2/?ref=app

23rd Jun 2019, 6:55 PM
Clueless Coder
Clueless Coder - avatar
4 Answers
+ 3
4 adjustments have to be made: 1) define boost before using it. defining a variable with a variable that doesn't exist yet won't be very effective 2)Add 'this.velY -= this.gravity; after this.y += this.velY; This will emulate the gravity effect 3) replace 'else' to if(this.y >= 400) This will stop gravity if the ground is hit 4) reassign velY every time the jump button is pressed. Allows for multiple jumps https://code.sololearn.com/WfusWC7rU60v/?ref=app
23rd Jun 2019, 9:31 PM
CodeMStr
CodeMStr - avatar
+ 1
Niek Aukes Thanks for the reply, I've got a Q/A post that hasn't been properly answered yet. I was wondering if you could check it out https://www.sololearn.com/discuss/1859954/?ref=app
26th Jun 2019, 10:16 AM
Clueless Coder
Clueless Coder - avatar