Godmaster Posted May 15, 2008 Report Share Posted May 15, 2008 Even in Game Maker official forums, I hadn't found any coding for this. This could help many, many, many people to load external animated sprites from single spritesheets, tilesets or strips (especially really big ones), instead of keeping separated animated gifs to be loaded (that's not secure at all). But I couldn't find any method in GML that loads each image part as a single subimage for a sprite. Anyone have any idea how it works? Link to comment Share on other sites More sharing options...
rogueyoshi Posted May 17, 2008 Report Share Posted May 17, 2008 sprite_add() does this pretty well. Link to comment Share on other sites More sharing options...
Godmaster Posted May 17, 2008 Author Report Share Posted May 17, 2008 sprite_add() does this pretty well. Yes, but only work for single gifs or images and not for spritesheets... I wanted to load a animated sprite from a sprite sheet. Link to comment Share on other sites More sharing options...
rogueyoshi Posted May 19, 2008 Report Share Posted May 19, 2008 no, it works for sheets too. ill post an example when i get some free time. Link to comment Share on other sites More sharing options...
Damizean Posted May 19, 2008 Report Share Posted May 19, 2008 sprite_add(fname,imgnumb,precise,transparent,smooth,preload,xorig,yorig)Adds the image stored in the file fname to the set of sprite resources. Many different image file types can be dealt with. When the image is not a gif 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). Basically, it means you can load animated sprites from a sheet, but each frame of the sheet needs to be stored horizontally (like GM exports them) and each frame to have the same box size. Upon the img number entered, GM will automatically calculate the size of each box frame Let's say we have a sprite sheet wich contains three frames. Each frame is 64x64 in size, so the resulting sheet size is 192x64. If you pass 3 to img number, it'll calculate that each frame is horizontal width / number of frames, in other words, 192 / 3 = 64. If you don't like it this way, you can always make your own loading function through surfaces and stuff. Link to comment Share on other sites More sharing options...
Recommended Posts