I want to step through all the sprites in the game from my plugin.
This is the code I have:
// global
int s = 0;
// in on_key_press
bool exists = true;
do
{
s++;
if (s > 1000) s = 0;
exists = true;
try
{
BITMAP *agsBitmap = engine->GetSpriteGraphic(s);
if (!agsBitmap || agsBitmap->w <= 0) exists = false;
}
catch (...)
{
exists = false;
}
}
while (!exists);
It seems that GetSpriteGraphic can return non-NULL for nonexistent sprites, so I added the try/catch block to catch an access violation in agsBitmap->w. Unfortunately at some point GetSpriteGraphic throws an exception which AGS catches - out of sprite cache bounds.
Is there an easier way to do what I want to do? I don't want to resort to telling the plugin what the valid sprites are.
Cheers!
There isn't an easy way to do this, no. I'm not sure why you'd need to iterate through every sprite in the game?
It's part of the Ags3d editor (or it will be, hopefully) - reassigning textures on the fly.