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 / Deleting all media

Author
Message
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Dec 2011 11:36
Hello, is there a way to delete all images/sprites/sounds/musics in AppGameKit?

As the autocreated id's start at a number I don't currently know, I can't create a for/next loop to delete them. Just wondering if there's an undocumented way of deleting all loaded media?

I'll create an entry in the bug/request board anyway.

My signature is NOT a moderator plaything! Stop changing it!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Dec 2011 13:29
That would be a handy command seconded...

Currently I have to store everything created. That data is already stored somewhere by AppGameKit so we are having to create wasted memory to effectively use it.

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 7th Dec 2011 13:32
Mobiius, all this deleting media, memory leaks etc etc confuses the hell out of me... If you don't mind me asking (I don't want to hijack your post), why would you need to delete media? All I do is create a sprite and then move it on screen as and when I need it... Is that not right? I've never even thought about deleting media, if I don't need something to be displayed, I simply move it off screen. Am I going the wrong way about things? (I'm new to this if you haven't guessed, and would like to get rid of my bad habits early!!)... Thank you!
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Dec 2011 13:59 Edited at: 7th Dec 2011 14:00
Mobiius:
I would say it's better to keep track of the media you need to delete rather than deleting everything. Reloading media is inefficient. Using variables to keep track of your media makes this a whole lot easier than keeping track of numbers yourself.

Funnell:
You don't need to move sprites outside of the screen. You can change their visibility with SetSpriteVisible(). Depending on the size of your project, deleting media might be a good idea to save memory. In a large project you might consider loading, deleting and loading more media. However, AppGameKit will automatically delete your media for you when you end the program.

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 7th Dec 2011 14:15
Thanks Digital Awakening... I guess thats the difference, my projects are not that large. I simply load everything up front and then use it as and when I need it. In other words, once the game has loaded, everything has been created, I never perform any 'Create' or 'Load' commands in the 'Loop'...

As for the invisibility thing, I done that originally, but found that the sprite is still actually there and influences things like 'GetpriteHit' etc... Thats when I opted for moving them off screen, that way, they can never get touched...

Thanks again...
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 7th Dec 2011 14:50
Yes if you are checking SpriteHits then making sprite invisible is not enough, you need to move it outside the screen.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Dec 2011 16:41
Quote: "Currently I have to store everything created."

Yes, so am I. I had to change the way my game engine works to accommodate it. But at least I can now return every image used in an animated sprite. (GetSpriteImageID() only returns one image so is useful only for animations with atlas images. Animations created with multiple images don't return every image with that command, only the current frame)

Quote: "why would you need to delete media?"

Image I have a level. This level has 200 images and 400 sprites.

Now imagine I have 8 of these levels, and each level doesn't use the same images. (Because, for example, one is a lava level, one is an ice level, and they don't share images for this reason) There would be a lot of images loaded onto a device which were not being used.

I'm from the programming school which loads only what's needed, then clears up when I've done with it. Memory is precious!

Quote: "Reloading media is inefficient."

So is retaining unused media in memory "just in case"

My signature is NOT a moderator plaything! Stop changing it!
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 7th Dec 2011 16:49
Quote: "Imagine I have a level. This level has 200 images and 400 sprites.

Now imagine I have 8 of these levels, and each level doesn't use the same images. (Because, for example, one is a lava level, one is an ice level, and they don't share images for this reason) There would be a lot of images loaded onto a device which were not being used.
"


Point taken! Thanks! I'm a self-taught coder (a very recent one at that), information like this is much appreciated. I'm working on a game which probably has only about 200 images for the whole thing which I guess is why I haven't experienced memory issues...
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Dec 2011 17:11
I haven't experienced memory issues either. And coding like I do, I hope I never will! Lol

My signature is NOT a moderator plaything! Stop changing it!
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 7th Dec 2011 17:33
I did this once,



And the same thing with all buttons, texts ect.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Dec 2011 19:24
I tried that, but with the more specific:

But I got a "GAME.exe has stopped working" error. So I changed it.

My signature is NOT a moderator plaything! Stop changing it!
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Dec 2011 19:30
Mobiius:
If I were you I would load all the level images into an array, something like this. It would then be easy to delete all these images without deleting stuff like player or HUD images.



LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 8th Dec 2011 01:06
I rather like the idea of a universal DELETE ALL command. If someone would add it as a feature request in the issues board it might just make an appearance in a future build: http://code.google.com/p/agk/issues/list

I drink tea, and in my spare time I write software.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 8th Dec 2011 15:58
Quote: "If someone would add it as a feature request"

I did, as soon as I made the original post! lol

Quote: "I'll create an entry in the bug/request board anyway. "

See.
Here's the link to it, and it's already been accepted.
http://code.google.com/p/agk/issues/detail?id=175


Quote: "If I were you I would load all the level images into an array, something like this"

My existing code wouldn't support this without some major recoding. (My UI code is all plug and play, just add the agc file and your done.) This method would not be plug and play enough.

I did however come up with a way to save the images to a typed array after loading with the original UI code so I'm good to go. As I'm still developing, I haven't implemented it yet, but it'll work in theory!

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2024-11-22 19:58:51
Your offset time is: 2024-11-22 19:58:51