ios - Mix colour in Sprite Kit -
i new sprite kit , want use implement simple game. i'd know if possible in sprite kit:
assume draw 2 circles, 1 in red , other 1 in green. there overlap area between 2 circles , want colour of area can automatically set red + green = yellow, kind of picture below.
is possible using sprite kit? if possible, how set up?
any reply appreciated!
you can play blending mode in conjunction skeffectnode:
class gamescene:skscene{ override func didmovetoview(view: skview) { let effect = skeffectnode() //creating shapenodes let shape1 = skshapenode(circleofradius: 50) shape1.fillcolor = skcolor.redcolor() shape1.strokecolor = skcolor.clearcolor() shape1.zposition = 1 shape1.blendmode = skblendmode.add let shape2 = skshapenode(circleofradius: 50) shape2.fillcolor = skcolor.greencolor() shape2.strokecolor = skcolor.clearcolor() shape2.zposition = 2 shape2.blendmode = skblendmode.add let shape3 = skshapenode(circleofradius: 50) shape3.fillcolor = skcolor.bluecolor() shape3.strokecolor = skcolor.clearcolor() shape3.zposition = 3 shape3.blendmode = skblendmode.add //positioning shape1.position = cgpoint(x: cgrectgetmidx(frame), y: cgrectgetmidy(frame)) shape2.position = cgpoint(x: shape1.position.x - 25, y: shape1.position.y - 50) shape3.position = cgpoint(x: shape1.position.x + 25, y: shape1.position.y - 50) effect.addchild(shape1) effect.addchild(shape2) effect.addchild(shape3) self.addchild(effect) } }
the result:
Comments
Post a Comment