Posted: 9th Dec 2011 21:58
MySprite = agk::CreateSprite (agk::LoadImage ("sprite.png"));

If I do DeleteSprite(MySprite), will the associated Image be also deleted from memory, since I cannot do a DeleteImage command in this case.
Posted: 9th Dec 2011 23:59
You can still do the deleteImage by getting the Image Id from the Sprite.
Posted: 10th Dec 2011 8:25
How stupid of me, there is indeed a GetSpriteImageID (mysprite) command!!!!!

So how does it work? First delete the image and then delete the sprite?
Posted: 10th Dec 2011 9:41
@bjadams, for your questions, you can use memory tool to test the change of your device memory, and you create a lot of sprites, then delete them ,then you can know the answer.

I'll do the test later. Then I can tell you the answer, if you don't have a memory tool.
Posted: 10th Dec 2011 10:04
So how does it work? First delete the image and then delete the sprite?

I'd delete the sprite first, then it's image, but I'm sure it doesn't really matter.
Posted: 10th Dec 2011 12:17
I think I read in another thread that sprites simply point to an image so deleting the image first might cause a white sprite to take its place but I can't confirm it. Well, you can always test it to see what happens (on my iPad right now so I can't do it) but I'd delete a sprite before an image.
Posted: 10th Dec 2011 15:56
So how does it work? First delete the image and then delete the sprite?


It only really matters if you're going to use a compound statement like the one used to create the sprite, if you delete the sprite first, you wont be able to retrieve the image ID from it

So you have to delete the image first or make a note of it's ID before deleting the sprite.

White sprite shouldn't be a problem if both are done together as this will be between screen refreshes and so is effectively simultaneous.
Posted: 10th Dec 2011 22:56
Yes I am using a compound statement.
White sprite would not bother me, as the sprite would be deleted on the next line of code.

As I get into larger game projects, and want to remove level data, and load new levels, I am learning more new things!
Posted: 12th Dec 2011 21:07
First rule of sprites: Sprites always points to images.

I suggest storing the image and sprite IDs. That makes managing them easy later.