Free up sprite/animation slots? - Printable Version +- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum) +-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7) +--- Thread: Free up sprite/animation slots? (/showthread.php?tid=1085) |
Free up sprite/animation slots? - Midnight Syntax - 04-07-2021 I've got a project now that I'm creating sprites in but I'm having trouble finding the documentation for freeing up those slots and making them available to use again. RE: Free up sprite/animation slots? - megamarc - 04-07-2021 Remember that you don't create sprites, instead you use (configure) and disable preallocated sprites. A sprite is set up with TLN_SetSpriteSet(): http://www.tilengine.org/doc/md_sprites.html#autotoc_md92 A sprite is disabled/released with TLN_DisableSprite(): http://www.tilengine.org/doc/md_sprites.html#autotoc_md103 You can manage sprite indexes by yourself, or ask Tilengine for a free sprite to use with TLN_GetAvailableSprite(): http://www.tilengine.org/doc/group__sprite.html#ga9257b468fe9cef605bd1323687c762c8 RE: Free up sprite/animation slots? - Midnight Syntax - 04-07-2021 Okay that makes sense, I'm just a little worried about the memory that it would use since would the sprite data still be held in memory? RE: Free up sprite/animation slots? - Midnight Syntax - 04-07-2021 Also just so I don't have to make a new thread, can I still check collisions on a layer even if it isn't being drawn? RE: Free up sprite/animation slots? - megamarc - 04-07-2021 Don't worry by the memory. Each sprite takes about 100 bytes, so if you preallocate 128 sprites (SNES for example) it just takes about 13 kbytes. Nothing to worry about! Disabled sprites are free as they don't take any CPU cycles. Yes, to check collisions with a given layer you must interrogate the layer tiles with TLN_GetLayerTile(): http://www.tilengine.org/doc/md_layers.html#autotoc_md47 This just requires having the layer loaded with a valid tileset and tilemap, but it will work even if you've disabled the layer with TLN_DisableLayer() so it is not drawn. RE: Free up sprite/animation slots? - Midnight Syntax - 04-07-2021 Okay great, thanks! |