Sodapop is a library that creates sprite objects. You can add different animations with different images to each sprite and switch between them at will. It has a similar use case to kikito's anim8, but it also manages the different states and properties an object in your game might have. Basically, it's a little higher level than something like anim8.
Code example!
Code: Select all
function love.load()
sodapop = require 'sodapop'
playerSprite = sodapop.newAnimatedSprite(100, 200)
playerSprite:addAnimation('walk', {
image = love.graphics.newImage 'walk.png',
frameWidth = 64,
frameHeight = 64,
frames = {
{1, 1, 4, 1, .2},
},
})
playerSprite:addAnimation('burrow', {
image = love.graphics.newImage 'burrow.png',
frameWidth = 64,
frameHeight = 64,
stopAtEnd = true,
frames = {
{1, 1, 12, 1, .05},
},
})
playerSprite:addAnimation('unburrow', {
image = love.graphics.newImage 'burrow.png',
frameWidth = 64,
frameHeight = 64,
stopAtEnd = true,
reverse = true,
onReachedEnd = function() playerSprite:switch 'walk' end,
frames = {
{1, 1, 12, 1, .05},
},
})
end
function love.update(dt)
playerSprite:update(dt)
end
function love.keypressed(key)
if key == 'left' then playerSprite.flipX = true end
if key == 'right' then playerSprite.flipX = false end
if key == 'down' then playerSprite:switch 'burrow' end
if key == 'up' then playerSprite:switch 'unburrow' end
end
function love.draw()
playerSprite:draw()
end