Check if sprite exists?

Started by abstauber, Wed 12/03/2014 21:51:20

Previous topic - Next topic

abstauber

Hey,
is it possible to check via script, if the given sprite slot even exists?
I'd like to create dynamic sprites from a textbox, but of course the game crashes when I enter an invalid number.

Is there a way to prevent this?

Thanks!

Ryan Timothy B

I believe there isn't any way of doing this. For now you'll want to look into this as a hack:
Code: ags
Game.SpriteWidth[int slot]   OR   Game.SpriteHeight[int slot]

QuoteIf an invalid sprite slot is supplied, 0 will be returned.

That's all I can think of.

abstauber

Well, that should at least prevent DynamicSprite.Create from crashing.
Thanks!

SMF spam blocked by CleanTalk