AnAL animation issue

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
croftxd
Prole
Posts: 7
Joined: Tue Mar 11, 2014 4:58 pm

AnAL animation issue

Post by croftxd »

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!
Attachments
main.lua
(2.02 KiB) Downloaded 152 times
User avatar
YGOFreak1997
Party member
Posts: 103
Joined: Sun Jan 22, 2012 4:29 pm
Location: Germany, Baden-Württemberg
Contact:

Re: AnAL animation issue

Post by YGOFreak1997 »

Quite straightforward problem, I'd say... Let me explain:

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
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!
Also look at my LÖVE-Tutorial-Youtube-Channel (German ^^)
GitHub Repo: Click Me!
Website: No, Me!
IndieDB: Or Maybe Me?

ÖBEY!
croftxd
Prole
Posts: 7
Joined: Tue Mar 11, 2014 4:58 pm

Re: AnAL animation issue

Post by croftxd »

Ah ofcourse! Thanks for the help!
User avatar
YGOFreak1997
Party member
Posts: 103
Joined: Sun Jan 22, 2012 4:29 pm
Location: Germany, Baden-Württemberg
Contact:

Re: AnAL animation issue

Post by YGOFreak1997 »

I'm happy I could help :D

Greetings!
Also look at my LÖVE-Tutorial-Youtube-Channel (German ^^)
GitHub Repo: Click Me!
Website: No, Me!
IndieDB: Or Maybe Me?

ÖBEY!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests