So I set up a NSUserDefault to store a string in my GameViewController

 NSUserDefaults.standardUserDefaults().setObject("_1", forKey: "SkinSuffix")

The idea is it stores a suffix which I will attach to the end of an image name in order to save what skin of a character the player should use.

When I call the value in my GameScene class like so

var SkinSuffix = NSUserDefaults.standardUserDefaults().stringForKey("SkinSuffix")
println(SkinSuffix)

it prints "Optional("_1")" instead of just "_1" so when I try to change the name of my image file like so, it doesn't load the image file

hero = SKSpriteNode(texture: heroAtlas.textureNamed("10Xmini_wizard\(SkinSuffix)"))

How do I fix this issue?

Related posts

Recent Viewed