anim8 - How to change duration of running animation?
Posted: Fri Jan 29, 2016 2:05 am
Hello,
New to love2d, and enjoying it. Im using aim8 which is working out really well. I have a question about durations.
I can't seem to change the duration of animation once its created. How would I do this? For instance, I want to slow the animation down when the user presses the down key.
in the update function
This code switches the animations correctly, but the duration is always the same as the first animation. Ive tried looking over the code, but I'm very new to lua. Obviously, hehe.
Thanks!
New to love2d, and enjoying it. Im using aim8 which is working out really well. I have a question about durations.
I can't seem to change the duration of animation once its created. How would I do this? For instance, I want to slow the animation down when the user presses the down key.
Code: Select all
-- setup animation frames
player.left_anim_frames = {
atlas.quads['player_left_01'],
atlas.quads['player_left_02']
}
player.right_anim_frames = {
atlas.quads['player_right_01'],
atlas.quads['player_right_02']
}
player.center_anim_frames = {
atlas.quads['player_center_01'],
atlas.quads['player_center_02']
}
-- create animation
player.animation = anim8.newAnimation(player.center_anim_frames, 0.25)
player.animation['left'] = anim8.newAnimation(player.left_anim_frames, 0.25)
player.animation['right'] = anim8.newAnimation(player.right_anim_frames, 0.25)
player.animation['up'] = anim8.newAnimation(player.center_anim_frames, 0.1)
player.animation['down'] = anim8.newAnimation(player.center_anim_frames, 0.5)
Code: Select all
if love.keyboard.isDown("down") then
if self.animation.current ~= self.animation['down'] then
self.animation.current = self.animation['down']
end
end
Thanks!