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
Post a Comment