I've got a problem. I'm xant to make a 2D scrolling game, but I can't figure out how to change the sprite when going in an opposite direction. Here's the code :
Code: Select all
require("AnAL")
function love.keypressed(key)
if (key == "right") then
anim:seek(1)
end
end
function love.keypressed(key)
if (key == "left") then
anim:seek(14)
end
end
function love.load()
img = love.graphics.newImage("perso.png")
bg = love.graphics.newImage("bg.png")
anim = newAnimation(img, 170, 400, 0.1, 13)
x = 0
end
function love.update(dt)
if love.keyboard.isDown ("right") then
anim:update(dt)
x = x + 2
elseif love.keyboard.isDown("left") then
anim:update(dt)
x = x - 2
end
end
function love.draw()
love.graphics.draw(bg)
anim:draw(x, 100)
end