Here's my code:
Code: Select all
function gamestate.loadimages()
gamestate.playerupanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerUpAnim.png")
gamestate.playerdownanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerDownAnim.png")
gamestate.playerleftanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerLeftAnim.png")
gamestate.playerrightanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerRightAnim.png")
gamestate.playerswingupanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerSwingDownAnim.png")
gamestate.playerswingdownanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerSwingDownAnim.png")
gamestate.playerswingleftanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerSwingDownAnim.png")
gamestate.playerswingrightanimatlas = love.graphics.newImage("Assets/Graphics/Player Animations/PlayerSwingDownAnim.png")
end
function gamestate.initanims()
gamestate.playerupanim = animation:new(gamestate.playerupanimatlas, 10, 2, 16, 32)
gamestate.playerdownanim = animation:new(gamestate.playerdownanimatlas, 10, 2, 16, 32)
gamestate.playerleftanim = animation:new(gamestate.playerleftanimatlas, 10, 2, 16, 32)
gamestate.playerrightanim = animation:new(gamestate.playerrightanimatlas, 10, 2, 16, 32)
gamestate.playeranims =
{
moveupanim = gamestate.playerupanim,
movedownanim = gamestate.playerdownanim,
moveleftanim = gamestate.playerleftanim,
moverightanim = gamestate.playerleftanim,
}
gamestate.playerswingupanim = animation:new(gamestate.playerswingupanimatlas, 30, 2, 16, 32)
gamestate.playerswingdownanim = animation:new(gamestate.playerswingdownanimatlas, 30, 2, 16, 32)
gamestate.playerswingleftanim = animation:new(gamestate.playerswingleftanimatlas, 30, 2, 16, 32)
gamestate.playerswingrightanim = animation:new(gamestate.playerswingrightanimatlas, 30, 2, 16, 32)
gamestate.playerswinganims =
{
swingupanim = gamestate.playerswingupanim,
swingdownanim = gamestate.playerswingdownanim,
swingleftanim = gamestate.playerswingleftanim,
swingrightanim = gamestate.playerswingrightanim,
}
end
Code: Select all
player.animations = gamestate.playeranims
player.currentanim = player.animations.moveupanim
Code: Select all
player.animations = gamestate.playeranims
player.currentanim = animation:new(gamestate.playerupanimatlas, 10, 2, 16, 32)