Do I load all Graphics and Audio files at the start of the game?

Previous topic - Next topic

Millerszone

My baseball game for the iPad has 7Mb of graphic files and 3.5Mb of Audio files.
So, is it o.k. to load everything at the start of the game, or load only the parts that I'm using at the time.
Example: load Menu first, if I press new game, then clear menu graphics from memory and load the game files, etc..



Hardware: iMac 27", MacBook Air, PC 3.5Ghz Quad
Developing Tools: GLBasic SDK, Gideros Studio, PureBasic
Developing for: iOS, Android, Windows, OS X, webOS, HTML5

MrTAToad

I load everything at the start of the game - saves having any unsightly delays during the running of the program

Leginus

It depends on exactly how much there is to be fair.

I loaded all my gfx on Percycute (which were a lot) all at once, and the game crashed on older devices and at one point even a 3gs crashed due to loading too much.  I ended up splitting it so that the important stuff like menu and tutorial screens loaded first, with a small percentage of game files and then loaded the rest on starting the game, taking care to unload the menu stuff.

Another consideration, is, if you have a high content game, it may still crash if people are multitasking on ios4, so you may need to inform people that if your app crashed to exit out of all other apps.

Best idea is to see if you can get away with it.


Millerszone

Quote from: Leginus on 2011-Jan-22
It depends on exactly how much there is to be fair.

I loaded all my gfx on Percycute (which were a lot) all at once, and the game crashed on older devices and at one point even a 3gs crashed due to loading too much.  I ended up splitting it so that the important stuff like menu and tutorial screens loaded first, with a small percentage of game files and then loaded the rest on starting the game, taking care to unload the menu stuff.

Another consideration, is, if you have a high content game, it may still crash if people are multitasking on ios4, so you may need to inform people that if your app crashed to exit out of all other apps.

Best idea is to see if you can get away with it.

Thanks for the replies.

The way my game is setup now is that it loads certain parts of the game, then unloads when finished.
It never crashed until I added the menu and leaderboard, but it seems to only crash when switching
to and from the menu. It doesn't crash when I'm playing the game.

This is what I am using to unload the sprites and sound.
LOADSPRITE "", 1
LOADSOUND "", 1, 1

I'll try to load all graphics and sound at the start of the game.


Hardware: iMac 27", MacBook Air, PC 3.5Ghz Quad
Developing Tools: GLBasic SDK, Gideros Studio, PureBasic
Developing for: iOS, Android, Windows, OS X, webOS, HTML5

Leginus

To unload a sprite, use LOADSPRITE "Blank",1
If you use LOADSPRITE "",1 it doesnt unload the resource

MrTAToad


Leginus

mmm I now see where you are coming from according to the online manual.
I am sure before that you couldnt unload a sprite with LOADSPRITE "",1 and had to specify a name that didnt exist

Has this been changed in an update I missed, or have i lost the plot :)

MrTAToad

Yes, you are right - using LOADSPRITE "" wont delete the sprite.

But then using LOADSPRITE "x" wont either.  May have found a buggy wuggy

Ian Price

Does GLB remove sprites from memory if you re-use the same sprite number for multiple loading instances?

EG if I use -
Code (glbasic) Select

LOADSPRITE "dog.bmp",1


Then use -
Code (glbasic) Select

LOADSPRITE "cat.bmp",1


Doesn't that automatically remove the original (dog) sprite from memory? Or is GLB garbage collector not doing a proper job? Any unreferenced/null object is removed surely?

Or is it? :S

Depending on the game I'm making, I generally load all media in at the start of the game, however, where multiple maps are required (and different imagery are used for each) I tend to use the method above - load in the new images at the same sprite location as the last, no longer required sprite. This could have one of two outcomes -

1. The original sprite is removed and replaced with the new one and no memory is lost

2. The original sprite is still in memory and the new one is allocated a new memory address and over time memory is being eaten/lost. At some point a system crash will occur if this happens often.

I can't remember if GLB has commands to check for available memory/memory usage. I'll have to have a looksee when I'm not at work...

An interesting problem, which I have thought about before, but never spent time to find the answer to.
I came. I saw. I played.

Hemlos

Theres no memory leaks with Sprite ID's, as they are completely reusable.
When you load a new sprite with an old id, it resets the old memory used.
Personally, I check the memory as i load or unload images, in the task manager in windows.
Bing ChatGpt is pretty smart :O

Marmor

in most cases i load all media at the start of the the game but if i get a too long delay for, i split it, play music, show some screens and load the rest in a "user Delay " such like menu or something !

so i get a fast starting app without  loading screen . if this not your way so show  a loading screen with a progess bar

MrTAToad

For all loadings, the user should, of course, always be informed about progress...

Marmor

yap wait  in a front of a black screen is booring .