Removing spritesheets in a storyboard scenario

Hi,
How do I remove spritesheets that I use in my storyboard scenes?
The displayobject that is created is added to the group and removed by storyboard.

But the spritesheet that I added remains in memory after leave the scene. It appears as a table.
The getSpriteSheetData function is still there.

I use the visual debugger with the variables option formCider to see what doesn’t get disposed of properly. And all the spritesheets leave tables.

The dispose spritesheet option doesn’t work that gives me a nil error. (when I add it to exit scene)

Any help is appreciated :slight_smile: [import]uid: 100901 topic_id: 24482 reply_id: 324482[/import]

Like you I had the same problem trying to use spriteSheet:dispose() in what seemed to be the logical place.

I put all my spriteSheet:dispose() in functions that were executed before leaving the scene, quitting the game, etc. and it seems to work without problem.
[import]uid: 34029 topic_id: 24482 reply_id: 99071[/import]

Update: using spriteSheet:dispose() in exitScene works. I’m not sure if it was the daily build I was using or something else I did, but I remembered I no longer had to put all my spriteSheet:dispose() in my custom functions for changing scenes.

I’m creating all my sprites in createScene but I have a forward reference to the sheets above (outside of) createScene.

Let me know if you get it working or find a better way to do it.

*using Build 2012.777

[import]uid: 34029 topic_id: 24482 reply_id: 99086[/import]

Thanks for the tips.

local sprite = require("sprite")  
local test = require("jjOgen-hd")  
local spriteData = test.getSpriteSheetData()  
sheet1 = sprite.newSpriteSheetFromData( "jjOgen@2x.png", spriteData )  
local spriteSet1 = sprite.newSpriteSet(sheet1, 1, 11)  
local instance1 = sprite.newSprite( spriteSet1 )  
sprite.add( spriteSet1, "ogenJJ", 1, 11, 3000,0)  
instance1:prepare("ogenJJ")  
instance1:play()  
group:insert(instance1)  

This is my sprite. Removing it still doesn’t work. I don’t get the error anymore if I make the sheet1 global. So it seems to work. But if I look at the variables in memory it still shows up in other scenes than the one I created it in. So it does
sheet1:dispose()
it just doesn’t seem to do anything. Am I trying to dispose the wrong variable?

Also tried the forward declaration instead of making it global, than I get a nil error. [import]uid: 100901 topic_id: 24482 reply_id: 99159[/import]

One thing that seems to work:
I use cider to look at the table that is left after I move scenes. I than set the resulting table name to nil.
Seems to work a bit.
But since it is the image name that becomes the table name I cannot set the tables for my retina images as they use the @2x extension and I can’t use the @ or the "-"sign [import]uid: 100901 topic_id: 24482 reply_id: 99368[/import]

If you get a chance, check out Jonathan Beebe’s blog:
http://blog.anscamobile.com/2012/03/image-sheets-image-groups-and-sprites/

As Jonathan’s post explains, there are some new ways you can use image sheets and sprites starting with build 2012.759. With the changes you no longer use spriteSheet:dispose() to remove a sheet created with graphics.newImageSheet.

To remove an image sheet, you simply remove any objects that are using the image sheet (which includes image objects, sprites, and image groups), and then set the reference to the image sheet to nil.

I just converted one scene to use the new graphics.newImageSheet and display.newSprite but I haven’t done any testing with cider to see what might be left over when I switch to a new scene.

There are also some examples of how to use the sheets for your retina images - I hope that helps with your last issue. [import]uid: 34029 topic_id: 24482 reply_id: 99539[/import]

Yeah, I just renamed everything. In my next app I will use imagesheets. This one is already done and on sale in the appstore. (#1 in the dutch appstore cat. Education!) But there are some memory issues if you play the app too long. Fixing this for an update I want to release this week. [import]uid: 100901 topic_id: 24482 reply_id: 99544[/import]

Wow! Congrats #1!

It’d be great if you can post any updates/resolutions you find regarding memory issues.
[import]uid: 34029 topic_id: 24482 reply_id: 99552[/import]