Lua Löve - anim8.lua:59: There is no frame for x=5, y=1

Viewed 52

I wanted to create a simple game with my girlfriend, so I choose a lang that I don't even know. I like a challenge.

I am following this tutorial. (it's in portuguese bc it's my native idiom)

Well. I have no idea what's going on.
My code is that below. Thanks for everyone who can helps me <3

local anim = require 'anim8'

local image, inimation
local posX = 100
local direction = true

function love.load()
  image = love.graphics.newImage('images/stickman-spritesheet.png')
  local g = anim.newGrid(180, 340, image:getWidth(), image:getHeight())
  animation = anim.newAnimation(g('1-9', 1, '1-9', 2, '1-9', 3, '1-9', 4, '1-9', 5, '1-9', 6, '1-9', 7, '1-7', 8), 0.01)
end

function love.update(dt)
  if love.keyborad.isDown('left') then
    posX = posX - 150 * dt
    direction = false
    animation:update(dt)
  end
  if love.keyborad.isDown('right') then
    posX = posX + 150 * dt
    direction = true
    animation:update(dt)
  end
end

function love.draw()
  love.graphics.setBackgroundColor(255, 255, 255)

  if direction then
    animation:draw(image, posX, 50, 0, 1, 1, 90, 0)
  elseif not direction then
    animation:draw(image, posX, 50, 0, -1, -1, 90, 0)
  end
end
1 Answers

There is no frame for x=5, y=1 happens when a frame is outside the provided image.

anim.newGrid(180, 340, image:getWidth(), image:getHeight()) means, that you have frames of size 180 by 340. Now if your image has the size 360 by 340 for example, you would have 2 by 1 frames.

In your case you expect a x of up to 9.

Double check the frame size and animation provided in g(...)

Read https://github.com/kikito/anim8 for more details.

Related