Is it possible to check if a spritenumber is already loaded or if it is empty? I ask, because I want to use this to "lazy-load" sprites. This would lead to a faster startup time because you wouldn't have to load everything at once on startup. So I mean in code something like this:
CONSTANT SPR_TITLESCREEN = 0
CONSTANT SPR_INTRO = 1
CONSTANT SPR_PLAYER = 2
CONSTANT SPR_TILES = 3
// ..
// do some stuff
// ..
// lazy loading of sprite, only load sprite at point where it will be needed
IF (spriteisloaded(SPR_TILES) = FALSE) // <- how to check if a sprite is loaded?
LOADANIM "media/tiles.png", SPR_TILES, 48, 48
ENDIF
I guess you could use static variables like this..
STATIC Sprite_was_loaded
IF Sprite_was_loaded = FALSE
Sprite_was_loaded = TRUE
LOADANIM "media/tiles.png", SPR_TILES, 48, 48
ENDIF
..But then you would have to use a lot of static variables, so I was wondering if there is a way to check the spritenumber (or sprite pointer). Maybe by using some INLINE stuff to check if a sprite-pointer is zero or something like that?
You can check the dimensions of the sprite, if it's 0 x 0, it's most likely empty :-)
Or use GENSPRITE() - if a sprite couldn't be loaded, then the value returned wont increase...
GENSPRITE returns the "highest" possible number. I fixed that for more compatibility.