Page 1 of 1

Anyone can help me how to solve this problem in the creation of grids: There's no frame for x = 7 and y = 1?

Posted: Fri Nov 22, 2019 2:24 pm
by gutborn

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' 
GAME.zip
(93.94 KiB) Downloaded 142 times

Re: Anyone can help me how to solve this problem in the creation of grids: There's no frame for x = 7 and y = 1?

Posted: Sat Nov 23, 2019 6:42 am
by randomnovice
Hello,

I could be wrong but I think the problem is with the sizing of the image "sprites.png".

I was able to get past that particular error by editing line 13 to say:

Code: Select all

local grid = anim_char.newGrid(76, 88, img:getWidth(), img:getHeight())
and using the attached image (which I've removed the border from).

However you'll now find a new error as on line 42 you want to draw something called 'imagem'. I'm not sure what you're referring to with that one.

Good luck with the next part of your game.

Re: Anyone can help me how to solve this problem in the creation of grids: There's no frame for x = 7 and y = 1?

Posted: Sun Nov 24, 2019 9:38 am
by gutborn
Thaaaaaaanks!!!
Now i'll just apply the changes!!