
I'm using anim8 but I can't make it actually animate a walking motion, left to right using an earthbound sprite sheet. I've measured the dimensions of the sprite sheet (the sheet is 128x98, the individual frames are 32x48) so I don't know where I've screwed up.
The error I get is 'There is no frame for x=1, y=2'.
Code: Select all
local anim8 = require 'anim8'
local player
function love.load()
local spritesheet = love.graphics.newImage('ANIMATION/paulaani.png');
local g = anim8.newGrid(32, 48, 128, 98)
player = {
spritesheet = spritesheet,
x = 200,
y = 200,
speed = 50,
animations = {
left = anim8.newAnimation('loop', g(1,1, 1,2, 1,3, 1,4), 1.0),
right = anim8.newAnimation('loop', g(2,1, 2,2, 2,3, 2,4), 1.0)
}
}
player.animation = love.graphics.newImage('ANIMATION/paula.png') -- player starts looking down
end
function love.update(dt)
if love.keyboard.isDown("w") then
player.y = player.y - player.speed * dt
elseif love.keyboard.isDown("s") then
player.y = player.y + player.speed * dt
elseif love.keyboard.isDown("a") and player.x > 0 then
player.x = player.x - player.speed * dt
player.animation = player.animations.left
elseif love.keyboard.isDown("d") and player.x < 10000 then
player.x = player.x + player.speed * dt
player.animation = player.animations.right
end
player.animation:update(dt)
end
Thanks!