swift - SKSpriteNode image not displaying -


when view presented, image named "player" (set) in images.xcassets show on scene.

currently scene loads blue. not sure why, when adding color change image color did nothing.

import spritekit  class characterscene: skscene {      var circle = skspritenode(imagenamed: "player")      override func didmovetoview(view: skview) {         backgroundcolor = skcolor.blackcolor()         circle.size = cgsize(width: 40, height: 40)         circle.position = cgpoint(x: cgrectgetmidx(self.frame), y: cgrectgetmidy(self.frame))         circle.color = skcolor.browncolor()         self.addchild(circle)      }  } 

you need initialize size of characterscene before presenting on screen. here go:

self.scene!.view!.presentscene(characterscene(size: self.scene!.size), transition: sktransition.pushwithdirection(sktransitiondirection.up, duration: 0.3)) 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -