Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Will this release the Image from memory?

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
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.
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 9th Dec 2011 23:59
You can still do the deleteImage by getting the Image Id from the Sprite.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Dec 2011 08: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?
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 10th Dec 2011 09:41 Edited at: 10th Dec 2011 09: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.

The Miracrea Games
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Dec 2011 10:04
Quote: "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.

My signature is NOT a moderator plaything! Stop changing it!
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
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.

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th Dec 2011 15:56
Quote: "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.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
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!
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
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.

Login to post a reply

Server time is: 2024-11-22 20:10:40
Your offset time is: 2024-11-22 20:10:40