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 / after I deleted the sprite, need I delete the image which the sprite used?

Author
Message
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 20th Jan 2012 10:26
After I deleted the sprite, need I delete the image which the sprite used?

The Miracrea Games
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 20th Jan 2012 11:08
It depends.
Images to sprites are a one-to-many relationship. A sprite can only have one image applied to it (the one relationship), but yet many sprites can have the same image (the many relationship).

Ask yourself these questions:
1) Do any other sprites currently use this image,
2) Will I be using this image again soon?

If either answer is 'yes', keep the image in memory; it is faster to use something that is already in memory than it is to delete it, reload it when needed, delete it, etc.

This of course is a generalization. For large projects with lots of sprites and animations, you'll want to swap out images on demand to make sure there's enough space for other animations when they're needed. For simple projects, I wouldn't worry about it. For isntance, my current project, I have all images loaded into memory at startup (all of my images combined are 1-2MB total) and then load my level images only when their stage is called.

Hi there. My name is Dug. I have just met you, and I love you.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Jan 2012 11:50
If this is for "Fruit Warrior" you could easily improve the framerate by separating the 'Game' from the 'Menu' and loading your atlas textures as you pass from one mode to the other. I don't know how it runs on iPad but it was fine on my netbook.

If you are worried about the framerate you could save some system memory this way and improve the speed, your images are 1024x1024 maximum but there are quite a few of them. I would only load active corpses for each level too.

Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 21st Jan 2012 10:14
Short answer:
Images take up memory, sprites don't.

Cheaper devises have less video memory and can only load so much. Images only have to be deleted if you need more memory.

3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 24th Jan 2012 02:04 Edited at: 24th Jan 2012 02:06
I think I have alot of experence with this subject as my game crashed because I was loading too much at the start. I tried the following that did not work well.

I loaded only sprites that needed to be displayed. This was slow because I had too delete then add different ones.
I thought if I made an array that held the temp images then I would not have to have that much in virtual memory. Athough this worked. Loading from room to room was like 5 to 10 sec.
So I thought that was too long of a wait.

So I went back to my old method of loading them all at once at the start, and getting ride of any animations that I had which worked. So I keeped it that way, and published it.

I also seperated my main menu from my graphics that where already loaded. I forgot the problem with this method, but I think it dealt with if the image was unloaded or not, and I got alot of messy graphics exiting to the menu.

I think if I am going to make my next game I will use an array like I did my first method to store temp images, but also seperate it from the menu and the end. Which I think is the best solution. Each array will be an image in the game starting with one being the base image and so on being copies of that image. When deleting them I will only delete the 2 to the last image thereby keeping the orignal.

Go through yourself at a wall.

Login to post a reply

Server time is: 2024-11-22 23:56:40
Your offset time is: 2024-11-22 23:56:40