swift - Draw a circular SKSpriteNode with texture? -
is there way draw circular skspritenode texture? or alternatively, draw skshapenode texture?
it consider images rectangle/squares. see round, how show colored pixels: outside circle, transparent , inside, colored part.
- we need circle
- we texture it
- we add scene
- we take new texture shape node added scene
- we make new sprite using new texture
we add sprite scene
let shape: skshapenode = skshapenode(circleofradius: 50) shape.name = "shape" shape.linewidth = 1 // way see circle shape.fillcolor = .white // see true colors of our image //shape.strokecolor = .white //shape.glowwidth = 0 shape.filltexture = sktexture(imagenamed:"myimage") shape.position = cgpoint(x: 0, y:200) self.addchild(shape) let newtexture: sktexture = (self.view?.texture(from: self.childnode(withname: "shape")!))! let sprite: skspritenode = skspritenode(texture: newtexture) self.addchild(sprite) shape.removefromparent()
Comments
Post a Comment