ios - How can I find out if an SKTexture is the placeholder image -


in spritekit, if load image [sktexture texturewithimagenamed:] method, first search bundles, atlases, if fails find texture, create placeholder image , load it.

is there way find out (without visually checking) if loaded image placeholder?

this doesn't seem "cocoa" way handle type of error.

developer.apple.com down now, figured pose question so.

sktexture has private properties helpful (see e.g. https://github.com/luisobo/xcode-runtimeheaders/blob/master/spritekit/sktexture.h), in swift , during development i'm using this:

extension sktexture {     public var isplaceholdertexture:bool {         if size() != cgsize(width: 128, height: 128) {             return false         }          return string(describing: self).contains("'missingresource.png'")     } } 

attention!:

this works, if using sktextureatlas:

let t1 = sktextureatlas(named: "mysprites").texturenamed("nonexistingfoo") // t1.isplaceholdertexture == true  let t2 = sktexture(imagenamed: "nonexistingbar") // t2.isplaceholdertexture == false 

Comments

Popular posts from this blog

python 3.x - Mapping specific letters onto a list of words -

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -