I'm trying to use the AnAL library to create separate animations which get drawn dependent on what the active Image variable "state" is set to. I have managed to get the left and right walking animations working (random luck and not to sure why it does work). But now I'm trying to get my jumping code to change state and draw the correct animation, however this is not working and the static image given to the player shows.
So my questions are how do I get the anim2 animation to work once the user presses the space bar, and from my opinion I really don't think the way I have written the active image states is the most suitable (but it possibly could be) so any suggestions on how to improve this would also be greatly appreciated.
I've attached the full main.lua file.
Thanks!
AnAL animation issue
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
AnAL animation issue
- Attachments
-
- main.lua
- (2.02 KiB) Downloaded 152 times
- YGOFreak1997
- Party member
- Posts: 103
- Joined: Sun Jan 22, 2012 4:29 pm
- Location: Germany, Baden-Württemberg
- Contact:
Re: AnAL animation issue
Quite straightforward problem, I'd say... Let me explain:
Directly under your change to the jumping state, your state will either way change to "walkingright" or "standing", depending on whether you're holding down the right arrow key or not. I guess you have to put it all in one if-else block to avoid these problems
Greetings!
Code: Select all
if player.y_velocity ~= 450 then -- we're probably jumping
player.y = player.y + player.y_velocity * dt -- dt means we wont move at
-- different speeds if the game lags
player.y_velocity = player.y_velocity + gravity * dt
activeImage = "jumping"
anim2:update(dt)
if player.y > 450 then -- we hit the ground again
player.y_velocity = 450
player.y = 450
end
end
if love.keyboard.isDown("right") then
player.x = player.x + (player.speed * dt)
activeImage = "walkingright"
anim:update(dt)
else
activeImage = "standing"
end
Greetings!
Also look at my LÖVE-Tutorial-Youtube-Channel (German )
GitHub Repo: Click Me!
Website: No, Me!
IndieDB: Or Maybe Me?
ÖBEY!
GitHub Repo: Click Me!
Website: No, Me!
IndieDB: Or Maybe Me?
ÖBEY!
Re: AnAL animation issue
Ah ofcourse! Thanks for the help!
- YGOFreak1997
- Party member
- Posts: 103
- Joined: Sun Jan 22, 2012 4:29 pm
- Location: Germany, Baden-Württemberg
- Contact:
Re: AnAL animation issue
I'm happy I could help
Greetings!
Greetings!
Also look at my LÖVE-Tutorial-Youtube-Channel (German )
GitHub Repo: Click Me!
Website: No, Me!
IndieDB: Or Maybe Me?
ÖBEY!
GitHub Repo: Click Me!
Website: No, Me!
IndieDB: Or Maybe Me?
ÖBEY!
Who is online
Users browsing this forum: Bing [Bot] and 4 guests