(Download link is at the bottom)
Advanced to expert users only.
See the second post where I give a bullet list of reasons why storing your resources externally is a VERY GOOD THING
This application manages external sprites, backgrounds and sounds. Here is the folder setup showing the folders and files you need to know:
resourceLoader.gmk /resources /backgrounds /sprites /sounds backgrounds.ini sprites.ini sounds.ini
You may be thinking "Wait a minute, how could I set options for external resources such as the bounding box, the origin, precise collision checking, and such?"
I have a system so you CAN. The settings are stored in the .ini files.
backgrounds.ini holds settings for your external backgrounds. sprites.ini holds settings for your sprites. sounds.ini holds settings for your sounds. More on this later.
The actual external resources can be put in the /backgrounds, /sprites or /sounds directory, depending on what type of resource is it. Sub-folders in these directories are also automatically imported so you can organize your resources as you would like.
Here is an example of how the sprites.ini file could look:
[logo.png] origCenter=1 [explode1.gif] name=explosion origCenter=1 [baby_strip2.png] name=baby imgNumb=2 origCenter=1
The section names should be the full name of the files you would like to configure. You may be able to guess what the above settings mean or you may not. Here is an outline of all the settings. Some are self-explanatory or are explained in the GM manual and aren't labeled.
Any resources that you do not define settings for will have default settings applied. Some settings do not do anything depending on if the file is a .png or not. png files will be loaded with their alpha values unless the alpha setting is set to 0
imgNumb = image number (eg if it is an animation strip) transparent = whether transparency should be used in the case of a non-png file smooth preload xorig = x origin yorig origCenter = set this to 1 if you want the origin to simply be the center of the image (this is just convenient). Defaults to 0 //bounding box stuff boundMode = precise|auto|full|manual - defaults to 'full'. This is an option seen in the built in sprite editor bound_left = defaults 0 bound_top = defaults 0 bound_right = defaults to right edge bound_bottom = defaults to bottom edge name = name of sprite as should be reference within the game. Defaults to the name of the image without the extension alpha = whether to use the alpha channel in the case of a png image. Defaults to 1.
To reference a sprite in the game is simple:
sprite.<name> //Example in the downloadable demo: sprite_index = sprite.alphaDemonstation;
Just prefix the resource name with 'sprite.' or 'background.' This is actually nice as it is a form of "namespace". There is also a demonstration in the gmk file. See the testing room (bring it to the top and run the game to see it). Study the code in the objects put into that room.
Here are the available settings for external backgrounds
transparent=transparent smooth=smooth preload=preload name = name of sprite as should be reference within the game. Defaults to the name of the image without the extension alpha = whether to use the alpha chanel in the case of a png image. Defaults to 1
And here are the available settings for external sounds
kind = indicates the kind of sound (normal|background|3d|mmplayer) preload = indicates whether the sound should immediately be stored in audio memory (0 or 1). volume = (0 = low, 1 = high, default=1) pan = (-1 = left, 0 = center, 1 = right) tempo = the tempo of the music (if it is a midi file). 1 = normal tempo. Larger values = faster tempo, smaller = slower tempo. Must lie between 0.01 and 100. name = name as it should be referenced within GM
There are two rooms in the demo. The first is the resource manager.
Press Z to bring up a list of loaded sprites, X to bring up a list of loaded backgrounds, or C to bring up a list of loaded sounds. Click one to view it. It will then display the resource and demonstrate (some of) the configurations such as the bounding-box and origin in the case of a sprite. In the future it will display more settings and you will be able to modify the settings from the manager.
The second room in the .gmk is a demonstration of how you might use the resource loader in a game.
Using the Resource Loader
First, merge the .gmk with your game. Second, make sure to put the object controller in the room. It needs to be the first instance placed in the room (or at least before any instances that use external resources)/
To change the external resource loading screen, modify the scripts updateLoader() and initLoader() which are in the resourceLoader folder of the internal scripts
* External tile layout editor
* Full external room editor (level creator)
Put it to good use. Suggestions? Ideas?
Edited by slayer_jojo, 25 July 2009 - 04:19 AM.