Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: abstauber on Wed 12/03/2014 21:51:20

Title: Check if sprite exists?
Post by: abstauber on Wed 12/03/2014 21:51:20
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!
Title: Re: Check if sprite exists?
Post by: Ryan Timothy B on Wed 12/03/2014 22:02:16
I believe there isn't any way of doing this. For now you'll want to look into this as a hack:
Code (ags) Select
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.
Title: Re: Check if sprite exists?
Post by: abstauber on Thu 13/03/2014 07:53:59
Well, that should at least prevent DynamicSprite.Create from crashing.
Thanks!