|
« Reply #2 on: February 15, 2008, 05:15:57 pm »
|
|
GM has a couple functions for adding resources at run-time, those are probably what your looking for. sprite_add(fname,imgnumb,precise,transparent,smooth,preload,xorig,yorig) Adds the image stored in the file fname to the set of sprite resources. Only bmp, jpg and gif images can be dealt with. When the image is a bmp or jpg image it can be a strip containing a number of subimages for the sprite next to each other. Use imgnumb to indicate their number (1 for a single image). For (animated) gif images, this argument is not used; the number of images in the gif file is used. precise indicates whether precise collision checking should be used. transparent indicates whether the image is partially transparent. smooth indicates whether to smooth the edges. preload indicates whether to preload the image into texture memory. xorig and yorig indicate the position of the origin in the sprite. The function returns the index of the new sprite that you can then use to draw it or to assign it to the variable sprite_index of an instance. When an error occurs -1 is returned.
sprite_replace(ind,fname,imgnumb,precise,transparent,smooth,preload,xorig,yorig) Same as above but in this case the sprite with index ind is replaced. The function returns whether it is successful.
background_add(fname,transparent,smooth,preload) Adds the image stored in the file fname to the set of background resources. Only bmp and jpg images can be dealt with. transparent indicates whether the image is partially transparent. smooth indicates whether to smooth the edges. preload indicates whether to preload the image into texture memory. The function returns the index of the new background that you can then use to draw it or to assign it to the variable background_index[0] to make it visible in the current room. When an error occurs -1 is returned.
background_replace(ind,fname,transparent,smooth,preload) Same as above but in this case the background with index ind is replaced. The function returns whether it is successful. When the background is currently visible in the room it wil be replaced also.
sound_add(fname,kind,preload) Adds a sound resource to the game. fname is the name of the sound file. kind indicates the kind of sound (0=normal, 1=background, 2=3d, 3=mmplayer) preload indicates whether the sound should immediately be stored in audio memory (true or false). The function returns the index of the new sound, which can be used to play the sound. (-1 if an error occurred, e.g. the file does not exist).
sound_replace(index,fname,kind,loadonuse) Same as the previous function but this time a new sound is not created but the existing sound index is replaced, freeing the old sound. Returns whether correct. There's also sprite_delete(index), background_delete(index), and sound_delete(index) which you should use when your done with them to free up memory.
Logged
|
|