Code: Select all
--this code will create the running animation character
local anim_char = require 'anim8'
local posX = 100
local direction = true
function love.load()
img = love.graphics.newImage('character/sprites.png')
local grid = anim_char.newGrid(86, 109, img:getWidth(), img:getHeight())
animation = anim_char.newAnimation(grid('1-7', 1, '1-7', 2, '1-7', 3, '1-6', 4), 0.09)--
end
function love.update(dt)
--movimentos para a esquerda
if love.keyboard.isDown('left') then
posX = posX - 150 * dt
direcao = false
animation: update(dt)
end
--movimentos pra direita
if love.keyboard.isDown then
posX = posX + 150 * dt
direcao = true
animation: update(dt)
end
end
function love.draw()
love.graphics.setBackgroundColor(255, 255, 255)
if direcao then
animation:draw(imagem, posX, 50, 0, 1, 1, 43, 0)
elseif not direcao then
animation:draw(imagem, posX, 50, 0, -1, 1, 43, 0)
end
end
*When i run the code this is what happens:
Error
anim8.lua:59: There is no frame for x=7, y=1
Traceback
[C]: in function 'error'
anim8.lua:59: in function 'getOrCreateFrame'
anim8.lua:87: in function 'grid'
main.lua:15: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'