I’m just getting started and I can’t get sprites to work. I’m doing as simple a code as I can right out of tutorials but I get the error ’ bad argument #1 to newSprite (Image sheet expected, got nil).’ I have no idea what I’ve missed and would appreciate some help.
Code is below:
display.setStatusBar(display.HiddenStatusBar)
objGroup = display.newGroup()
options = {
width = 32,
height = 32,
numFrames = 6,
sheetContentHeight = 32,
sheetContentWidth = 192
}
shipSheet = graphics.newImageSheet( “ShooterStrip.png”, options )
sequenceData = {
{ name = “all”, start=1, count=6, time=0, loopCount=1 }
}
spaceshipImg = display.newSprite(shipSheet, sequenceData)
spaceshipImg.x = display.contentWidth/2
spaceshipImg.y = display.contentHeight-48
spaceshipImg.speed = 4
spaceshipImg:setSequence(“all”)
spaceshipImg:setFrame(1)
objGroup:insert(spaceshipImg)
local function moveShip(event)
if event.x < display.contentWidth/2 then
spaceshipImg.x = spaceshipImg.x - spaceshipImg.speed
end
if event.x > display.contentWidth/2 then
spaceshipImg.x = spaceshipImg.x + spaceshipImg.speed
end
end
Runtime:addEventListener(“touch”,moveShip)