sprite sheet error on device only

I’m not sure why but the code below works fine in the simulator but not on my device…Hangs up my iphone. Do you guys know why?

[code]
local sprite= require(“sprite”)
local autoFrames = sprite.newSpriteSheetFromData( “data/auto/autoframes.png”, require(“data/auto/autoframes”).getSpriteSheetData() )
local autoSet = sprite.newSpriteSet(autoFrames,1,18)
sprite.add(autoSet,“autoLeft”,1,6,1000,0)
sprite.add(autoSet,“autoRight”,7,6,1000,0)

auto = sprite.newSprite(autoSet)
physics.addBody( auto, { density=3.0, friction=0.5, bounce=0.3 } )
gamescreen:insert( auto )

auto:setReferencePoint(display.BottomRightReferencePoint)
auto.x = 100
auto.y = 100

auto:prepare(“autoLeft”)
auto:play()
[/code] [import]uid: 10730 topic_id: 3325 reply_id: 303325[/import]

How big are your sprites? Maybe you’re using up texture memory on your iPhone (whereas the simulator doesn’t have the same memory restrictions).
[import]uid: 9905 topic_id: 3325 reply_id: 9936[/import]

256x256 with 18 frames only. I wonder if I should just use a movieclip [import]uid: 10730 topic_id: 3325 reply_id: 9993[/import]

Easier test… try it with 16 or fewer frames and see if it works. If an iPhone 3/3GS only has 1024x1024 of texture memory, you’re going over that amount: 256x256x18 = 1179648 or 131072 over.

You can also take a look at optimizing your sprite sheet using Zwoptex or equivalent.
http://www.zwoptexapp.com/ [import]uid: 9905 topic_id: 3325 reply_id: 9999[/import]

Sorry I meant the entire sprite sheet is only 256x256. I am using Zwoptex. Each frame is much smaller. They all fit into a 256x256 space.

I really don’t understand why it’s not working on my device… [import]uid: 10730 topic_id: 3325 reply_id: 10007[/import]

Ah, sorry… I’ll let someone else pick it up from here, then… I haven’t worked with sprite sheets yet. [import]uid: 9905 topic_id: 3325 reply_id: 10011[/import]

Do paths for images work now, they didnt…

They worked on the device but never on the iPhone. I posted a bug months ago but I think its actually what is required. There is a way of referencing folders on the iPhone but ive never played with it.

The advice I got at the time was to keep everything on the same level as main.lua [import]uid: 5354 topic_id: 3325 reply_id: 10031[/import]

@stoshie

Copy-paste the SpriteGrabber code in a SpriteGrabber.lua file within your project folder and try this:

[lua]local grabber=require(“SpriteGrabber”)

local autoSheet=grabber.grabSheet(“autoframes”)
local auto=autoSheet:grabSprite("", true, { autoLeft={1,6,1000,0}, autoRight={7,6,1000,0} } )

physics.addBody( auto, { density=3.0, friction=0.5, bounce=0.3 } )
gamescreen:insert( auto )

auto:playClip(“autoLeft”)[/lua]

There must be an “autoframes.png” and a “autoframes.lua” file in the folder that your main.lua exists. If these two spritesheets files have a different name, change it in the second line. We don’t care where your actual frame-images exist.

In the third line, replace “” with: “somename”, but only if your frame-images have some name before the frame numbers (e.g. something01.png, something02.png…). If the images are just named 01.png, 02.png leave the code as it is.

Also, have in mind that there is a known bug concerning spritesheets + referencepoint usage. So, avoid changing reference points, for the time, and just position your sprites as they are (with the default center reference point)
EDIT: Matthew must be right! The root of the problem is rather the path…
Move your two spritesheet files in your main.lua folder to get the code above working properly on device… [import]uid: 7356 topic_id: 3325 reply_id: 10032[/import]

Yea that was it. The sprite and sprite lua file need to be in the same directory as the main lua file. Thanks for the help. Wish I would have asked earlier. [import]uid: 10730 topic_id: 3325 reply_id: 10059[/import]