BWSnippet

SpriteKit - using SKScene get user data values

SpriteKit - using SKScene get user data values

How to get the user data set in SKScene.sks in your nifty swift code..

        if let value = userData?.value(forKey: "someCoolValueSetInScene") as? Bool {
            print(" YAY got a value: \( value ) ")
        } else {
            print(" Could not get your fancy value... check your sks file again. Sometimes you forget to actually save the updates. ")
        }

Tags

SpriteKit - using SKScene get user data values