Continuous Jumping Animation

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
N3RDY
Prole
Posts: 4
Joined: Sat May 14, 2022 8:33 pm

Continuous Jumping Animation

Post by N3RDY »

This is one of first few projects. I'm making an endless runner with the provided spritesheet using anim8. So far I've been able to make the character run but when it jumps it never stops. Is there a simple way to fix this? I'd also appreciate any other advice.

main.lua
I also used anim8 and HUMP
(1.19 KiB) Downloaded 78 times
Attachments
spritesheet.png
spritesheet.png (10.42 KiB) Viewed 2995 times
MrFariator
Party member
Posts: 509
Joined: Wed Oct 05, 2016 11:53 am

Re: Continuous Jumping Animation

Post by MrFariator »

Code: Select all

if isJumping then -- "isJumping == true" is redundant
  if player.anim ~= player.animations.jump then
    player.anim = player.animations.jump
    player.anim:gotoFrame(1)
  end
else
  if player.anim ~= player.animations.run then
    player.anim = player.animations.run
    player.anim:gotoFrame(1)
  end
end
Of course, you may want to implement some check that the player is grounded, so you'll play the run animation when player lands, and jump animation when mid-air.
N3RDY
Prole
Posts: 4
Joined: Sat May 14, 2022 8:33 pm

Re: Continuous Jumping Animation

Post by N3RDY »

A couple more questions. How would I make continuously generating platforms out of tilemaps that I have made? How would I make the character jump (go up and back down)? I also have a lot of trouble adding more than one animation so how would I add an attack animation?
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Continuous Jumping Animation

Post by milon »

Animations go in tables, and each animation itself goes in a super table. Then you can index them relatively easily.

To add multiple possible actions (and account for the way they work when the player is standing, jumping, walking, etc) you should really use a state machine. Here's a sample link to get you started, but there's LOTS of good tutorials out there if you poke around.
https://gamedevelopertips.com/finite-st ... evelopers/

It'll take a while to wrap your head around them, so give it time, make some demos, and come back with more questions.
You can also search my old posts for 'state machine' and you'll find some of my own progress dealing with them. Not my best work, but enough to get started. ;)
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
darkfrei
Party member
Posts: 1169
Joined: Sat Feb 08, 2020 11:09 pm

Re: Continuous Jumping Animation

Post by darkfrei »

If the jumping animation has same sollision as just running, then just make jumps in the spritesheet.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Continuous Jumping Animation

Post by milon »

Also, in case you haven't seen Sheepolution's animation tutorial: https://www.sheepolution.com/learn/book/17
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 50 guests