🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles

Check if an asset exists?

A topic by Liam Brocklehurst created Oct 06, 2016 Views: 185 Replies: 2
Viewing posts 1 to 3

I might be missing something here, but I'm just wanting to check if an asset exists (from a path) before I assign it to something.

For example, I would do something like:


but I'd like to be able to do:


You could use a simple try / catch statement like so:

try {
this.mySprite.setSprite( "Path/To/Sprite" );
} catch( error ) {
Sup.log( error ); //Something went wrong, most likely the path to the asset doesn't exist

Yeah I'm thinking that's what I might have to do, thanks!