ios - Strange black border when using SKCropNode -
i'm working on game spritekit , have square skspritenode corners want make round. can't use skshapenode because want add gradient it. decided use skcropnode crop it, when so, weird black border appears:
if don't try crop it, looks this:
this code using create , crop it:
spritenode = skspritenode(color: color.skcolor, size: cgsize(width: tilesize, height: tilesize)) let borderradius: cgfloat = 2 let roundpath = cgpathcreatewithroundedrect(cgrect(x: -tilesize / 2, y: -tilesize / 2, width: tilesize, height: tilesize), borderradius, borderradius, nil) let mask = skshapenode() mask.path = roundpath mask.fillcolor = skcolor.whitecolor() mask.strokecolor = skcolor.whitecolor() let cropnode = skcropnode() cropnode.masknode = mask let shadow = skspritenode(color: skcolor.blackcolor(), size: cgsize(width: tilesize, height: tilesize)) shadow.colorblendfactor = 1 shadow.alpha = 0.25 let radius: cgfloat = 3.5 shadow.position = cgpoint(x: radius / 2, y: radius / 2) let effectnode = skeffectnode() effectnode.filter = cifilter(name: "cigaussianblur", withinputparameters: [kciinputradiuskey: radius]) effectnode.zposition = spritenode!.zposition - 1 effectnode.addchild(shadow) let bluredtile = skshapenode(path: roundpath) bluredtile.addchild(effectnode) cropnode.addchild(spritenode!) addchild(bluredtile) addchild(cropnode)
why happening, , how can stop it?
Comments
Post a Comment