Image sheet to new image error

Hi folks,

I’ve been struggling with this for a while now and just can’t work it out. I’ve created a image sheet

local options = { frames = { { x = 2, y = 70, width = 100, height = 100 }, { x = 2, y = 242, width = 100, height = 100 }, }, sheetContentWidth = 512, sheetContentHeight = 512 } local imageSheet = graphics.newImageSheet( "test.png", options );

Then I try to create a display image using that image sheet like so

local myImage = display.newImage( imageSheet , 1)

It fails with a ‘Failed to find image(1)’ error. I can’t work out what’s going on. Creating a sprite using display.newSprite and some random sequence data works fine, but display.newImage( imageSheet , index) refuses to work.

Any help would be greatly appreciated!
Thanks,
Lisa

[import]uid: 168400 topic_id: 35925 reply_id: 335925[/import]

I’m not an expert with image sheets, but that error would tell me that there was a problem with the imageSheet. Perhaps it’s nil? Does test.png exist in the same folder with main.lua?

[import]uid: 199310 topic_id: 35925 reply_id: 142814[/import]

Hi Lisa,
Rob is correct, this is likely an issue with the file. Your syntax looks fine. Perhaps there’s a scoping error?

Brent [import]uid: 200026 topic_id: 35925 reply_id: 142823[/import]

Hey guys, thanks for the replies but scoping definitely isn’t the issue.

Using the imagesheet for a animation sprite (display.newSprite) works fine and I’ve double & triple checked everything. I’ve even downloaded an example imagesheet from a imagesheet tutorial incase it was some image format error that happened exporting from photoshop.

I updated the Corona SDK to the latest build too incase there was a bug listing I was unaware of.

I’ve tried placing the image in the same folder as main.lua and in a image folder I have inside the project but yet still nothing, newSprite works but newImage(imageSheet, 1) always throws the same error.

I am absolutely and completely stumped…

EDIT:
Also using newImageGroup

local testGroup = display.newImageGroup( imageSheet );

doesn’t throw an error in the code either, but once I try to add a display image using

local myImage1 = display.newImage( imageSheet , 1)

it crashes again. [import]uid: 168400 topic_id: 35925 reply_id: 142844[/import]

Your syntax is 100% correct. I copy-pasted it into a blank project and made a simple png to load, and it works perfectly.

What happens if you would do the same? Copy-paste the code from the forum here into a new project with a blank main.lua, copy over your png to the project and try to create your newImage().

I’m starting to think that *maybe* you have some hidden characters in your source code that you can’t see.
[import]uid: 70847 topic_id: 35925 reply_id: 142845[/import]

Hi, thanks for that reply, I tried that myself and it worked too.

Pasting that code back in to my project generated the same error though but it did allow me to find what is causing the issue. I require the crawlspacelib for generating text paragraphs in my app (http://www.elevatefun.com/crawl-space-corona-sdk-library/) and I think that is creating an incompatibility of some kind.

Shall look into it more now, thanks everyone! :slight_smile: [import]uid: 168400 topic_id: 35925 reply_id: 142846[/import]

I just tested this and it works fine with the image sheet i used.

Could you post up the console log of the error? [import]uid: 84637 topic_id: 35925 reply_id: 142849[/import]

ImageSheet is listed as being supported by display.newImage() in the official APIs below :slight_smile:

http://docs.coronalabs.com/api/library/display/newImage.html

It’s working now that I’ve removed the crawl space library reference.
[import]uid: 168400 topic_id: 35925 reply_id: 142858[/import]

@vStream. Perhaps the crawlspace library was subclassing display.newImage?
I have never used it personally. [import]uid: 84637 topic_id: 35925 reply_id: 142859[/import]

I haven’t looked at CSL for a long time, and I haven’t had a need to use it, but it does override display.newImage(). The same goes for newImageRect() and many other display.* functions.
It’s also relatively old and I wouldn’t be too confident about the compatibility with the newer builds of Corona SDK. [import]uid: 70847 topic_id: 35925 reply_id: 142862[/import]

Yep it was, I’ve removed all the image override methods from the library and added it back into the app and it’s all working away nicely together now :slight_smile:
Thanks folks, I was only using the library for a helper for some text and had never realised it effected the display images too. D’oh.

Thanks again! :slight_smile:
[import]uid: 168400 topic_id: 35925 reply_id: 142865[/import]

I’m not an expert with image sheets, but that error would tell me that there was a problem with the imageSheet. Perhaps it’s nil? Does test.png exist in the same folder with main.lua?

[import]uid: 199310 topic_id: 35925 reply_id: 142814[/import]

Hi Lisa,
Rob is correct, this is likely an issue with the file. Your syntax looks fine. Perhaps there’s a scoping error?

Brent [import]uid: 200026 topic_id: 35925 reply_id: 142823[/import]

Hey guys, thanks for the replies but scoping definitely isn’t the issue.

Using the imagesheet for a animation sprite (display.newSprite) works fine and I’ve double & triple checked everything. I’ve even downloaded an example imagesheet from a imagesheet tutorial incase it was some image format error that happened exporting from photoshop.

I updated the Corona SDK to the latest build too incase there was a bug listing I was unaware of.

I’ve tried placing the image in the same folder as main.lua and in a image folder I have inside the project but yet still nothing, newSprite works but newImage(imageSheet, 1) always throws the same error.

I am absolutely and completely stumped…

EDIT:
Also using newImageGroup

local testGroup = display.newImageGroup( imageSheet );

doesn’t throw an error in the code either, but once I try to add a display image using

local myImage1 = display.newImage( imageSheet , 1)

it crashes again. [import]uid: 168400 topic_id: 35925 reply_id: 142844[/import]

Your syntax is 100% correct. I copy-pasted it into a blank project and made a simple png to load, and it works perfectly.

What happens if you would do the same? Copy-paste the code from the forum here into a new project with a blank main.lua, copy over your png to the project and try to create your newImage().

I’m starting to think that *maybe* you have some hidden characters in your source code that you can’t see.
[import]uid: 70847 topic_id: 35925 reply_id: 142845[/import]

Hi, thanks for that reply, I tried that myself and it worked too.

Pasting that code back in to my project generated the same error though but it did allow me to find what is causing the issue. I require the crawlspacelib for generating text paragraphs in my app (http://www.elevatefun.com/crawl-space-corona-sdk-library/) and I think that is creating an incompatibility of some kind.

Shall look into it more now, thanks everyone! :slight_smile: [import]uid: 168400 topic_id: 35925 reply_id: 142846[/import]

I just tested this and it works fine with the image sheet i used.

Could you post up the console log of the error? [import]uid: 84637 topic_id: 35925 reply_id: 142849[/import]

ImageSheet is listed as being supported by display.newImage() in the official APIs below :slight_smile:

http://docs.coronalabs.com/api/library/display/newImage.html

It’s working now that I’ve removed the crawl space library reference.
[import]uid: 168400 topic_id: 35925 reply_id: 142858[/import]

@vStream. Perhaps the crawlspace library was subclassing display.newImage?
I have never used it personally. [import]uid: 84637 topic_id: 35925 reply_id: 142859[/import]

I haven’t looked at CSL for a long time, and I haven’t had a need to use it, but it does override display.newImage(). The same goes for newImageRect() and many other display.* functions.
It’s also relatively old and I wouldn’t be too confident about the compatibility with the newer builds of Corona SDK. [import]uid: 70847 topic_id: 35925 reply_id: 142862[/import]