Page 1 of 1

AnAL animation issue

Posted: Tue Mar 11, 2014 6:27 pm
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!

Re: AnAL animation issue

Posted: Tue Mar 11, 2014 7:41 pm
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!

Re: AnAL animation issue

Posted: Thu Mar 13, 2014 1:02 pm
by croftxd
Ah ofcourse! Thanks for the help!

Re: AnAL animation issue

Posted: Wed Apr 23, 2014 9:08 pm
by YGOFreak1997
I'm happy I could help :D

Greetings!