Reputation: 11
I was following a tutorial and did exactly what it showed but it doesn't work and I can't figure out why.
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
local sheetOptions = {
width = 512,
height = 256,
numFrames = 8
}
local sheet_runningCat = graphics.newImageSheet( "sprites-cat-running.png", sheetOptions )
local sequences_runningCat = {
{
name = "normalRun",
start = 1,
count = 8,
time = 800,
loopCount = 0,
loopDirection = "forward"
}
}
local runningCat = display.newSprite( sheet_runningCat, sequences_runningCat )
It creates this error...
main.lua:26: bad argument #1 to 'newSprite' (ImageSheet expected, got nil)
stack traceback:
[C]: in function 'newSprite'
main.lua:26 in main chunk
Do you want to relaunch the project?
Upvotes: 1
Views: 70
Reputation: 61
It means that the file "sprites-cat-running.png" was not found in the same directory as this file main.lua
so graphics.newImageSheet()
returns a nil value, and sheet_runningCat
is now nil instead of an ImageSheet object.
To fix this, download the image file from the tutorial and save it in the same directory as main.lua
Upvotes: 1