I have a game designed with SpriteKit which heavily relies on 1 SKShapeNode (Which is a line). I'm making the line like this:
if let path = createPathToMove() {
let shapeNode = SKShapeNode()
shapeNode.path = path
shapeNode.name = "line"
shapeNode.strokeColor = UIColor.blackColor()
shapeNode.lineWidth = 20
shapeNode.zPosition = 5
shapeNode.antialiased = false
shapeNode.lineCap = kCGLineCapRound
self.world!.addChild(shapeNode)
}
Unfortunately, since this was designed as a debug feature (Sprite-kit drawing), it is not optimized for what I'm doing, and a bigger problem is the line has artifacts (Since it's line width is greater than 2). Those look like this: http://i.stack.imgur.com/ccQ1s.png
With this in mind, I've deducted that using Sprite-kit's SKShapeNode isn't an option for me, unless someone knows how to fix the mentioned problems. I've looked into cocos2d, however it seems like that is a bit overkill (Using the entire lib for just a CCDrawNode). Is there any open source/public extensions for SKShapeNode (and swift), that improves the drawing feature? The most important thing to be fixed is the artifacts (white dots/lines in the node). If there isn't anything public, is Cocos2d my best choice?
Although this post is a bit old, I thought I might as well answer it myself incase anyone else has the same problem.
Basically, to remove the artifacts in the line, you want to set the line width to a size smaller than 2.0 (For whatever reason no artifacts occur when it is smaller than this). After setting the line width, you will want to scale up the SKNode like so:
node.xScale = 10
node.yScale = 10
This will then make the line appear significantly thicker than it is, and there is no artifacts in the line.
You may also have to set the antialiased property to false, otherwise the line will appear very fuzzy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With