Croweley Posted October 6, 2014 Report Share Posted October 6, 2014 Is there a way to check if a frame exists within an atlas? Preferably before setting the frame name in a sprite. Quote Link to comment Share on other sites More sharing options...
nkholski Posted October 6, 2014 Report Share Posted October 6, 2014 game.cache._images[atlasName].frameData._frameNames.hasOwnProperty(frameName) Returns true or false. (atlasName = name of your atlas, frameName = frame you want to test.) clark 1 Quote Link to comment Share on other sites More sharing options...
nemoDreamer Posted January 2, 2015 Report Share Posted January 2, 2015 Avoid digging into _* and internals manually.Using:game.cache.getFrameByName('characters/player.png')will return null if no frame of that name is found. gauravD and clark 2 Quote Link to comment Share on other sites More sharing options...
Anatol Posted February 21, 2020 Report Share Posted February 21, 2020 (edited) Very late reply, but I was looking for a solution to the same issue. I don't think nemoDreamer's anser would work, it seems to just look for an image, not texture atlas frame. I'd also avoid using underscore as in the first reply, but you can do something with Phaser only methods like this: function hasFrameName ( { atlasName, frameName } ) { return this.state.cache.getFrameData( atlasName ).checkFrameName( frameName ) } Edited February 21, 2020 by Anatol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.