SpriteSheets and removeSelf's

Hi - I was displaying some images with [image]=display.newImage, but have now replaced all of these with spritesheets.

My code still has references to:

[image]:removeSelf() [image]=nil

Should I remove these, and then just dispose of the overall spritesheet when finished with? I’m presuming you can’t / there’s no point in trying to remove/tidy up individual sprites?

((For info: when I generate a build, it doesn’t seem to cause any problems, but I don’t think the ‘removeSelf’ code releases any texture memory.))

So, should I just replace my ‘removeSelf’ code with isVisible=false, and then dispose / garbage collect later?

Any thoughts / advice? Thanks in advance,
Dave. [import]uid: 82595 topic_id: 20743 reply_id: 320743[/import]

You dipose of spritesheets with the

mySheet:dispose()
mySheet = nil

command.

[import]uid: 84637 topic_id: 20743 reply_id: 81494[/import]

Thanks Danny - I am aware of this syntax, and already have these spritesheet disposal statements in my code.

The question is, do I need to:

1.) remove all of my old [image].removeSelf statements (which were in there from before, when I was displaying images, not sprites.

2.) replace these with isVisible=false (i.e. to remove them from screen / use when required). i.e. control the visibility of my sprites, but not clean up any texture memory yet.

3.) Finally, at the end of the app, dispose of the spritesheet(s) using your syntax provided.

Many thanks,
Dave. [import]uid: 82595 topic_id: 20743 reply_id: 81508[/import]

If your doing like :

local sprite = newSprite()

then still use

display.remove(sprite)

along with disposing the sheet later :slight_smile: [import]uid: 84637 topic_id: 20743 reply_id: 81509[/import]

That’s great - thanks Danny.

Dave. [import]uid: 82595 topic_id: 20743 reply_id: 81510[/import]