0
votes

I'm trying to paint the stroke color in black, but it doesn't appear any line...

This is how it's displayed in the iOS simulator:

Circle in iOS simulation

BUT, if I run the same code in the Xcode playground, the circle is perfect

The circle in the playground live view

My scene code:

import SpriteKit

class GameScene: SKScene {

   override func didMoveToView(view: SKView) {
      /* Setup your scene here */
      self.backgroundColor = UIColor.whiteColor()
      let midcir = self.mainCircle()
      self.addChild(midcir)
  }

  func mainCircle()->SKSpriteNode{
    let node = SKSpriteNode()
    node.anchorPoint=CGPoint(x: 0.5, y: 0.5)


    let outsideNode = SKShapeNode(circleOfRadius: 127.5)
    let insideNode = SKShapeNode(circleOfRadius: 1)


    outsideNode.strokeColor = UIColor.blackColor()
    outsideNode.fillColor = UIColor.blueColor()
    outsideNode.lineWidth = 5

    insideNode.strokeColor = UIColor.clearColor()
    insideNode.fillColor = UIColor.clearColor()


    node.addChild(outsideNode)
    node.addChild(insideNode)

    node.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame))

    return node
}

}

And the playground code, it's for OS X for live view incompatibilities (live view): It only changes the UIColor for NSColor

import XCPlayground
import Cocoa
import SpriteKit


var myView = SKView(frame: NSRect(x: 0, y: 0, width: 400, height: 400))
var myScene = SKScene(size: CGSize(width: 400, height: 400))
myScene.backgroundColor = NSColor.whiteColor()
myView.presentScene(myScene)

func maincircle()->SKSpriteNode{
    let node = SKSpriteNode()
    node.anchorPoint=CGPoint(x: 0.5, y: 0.5)



    let outsideNode = SKShapeNode(circleOfRadius: 127.5)
    let insideNode = SKShapeNode(circleOfRadius: 1)

    outsideNode.strokeColor = NSColor.blackColor()
    outsideNode.fillColor = NSColor.blueColor()
    outsideNode.lineWidth = 5

    insideNode.strokeColor = NSColor.clearColor()
    insideNode.fillColor = NSColor.clearColor()

    node.addChild(insideNode)
    node.addChild(outsideNode)
    node.position = CGPoint(x: 200, y: 200)


    return node
}


let node = maincircle()
myScene.addChild(node)


XCPShowView("MainCir", myView)

I don't know that is happening, I'll post the answer if I find it. Thank you!

I think the first argument of the second CGPathAddArc statement should be insideCircle not outsideCircle. Also, circleOfRadius(radius:CGFloat) is a convenience method of SKShapeNode, so creating a CGPath is not necessary here. That being said, I couldn't get stroke to work with anything other than a line. I suspect there's a bug in sprite kit.0x141E
true! bug fixed. It's true the first time I can use the SKShapeNode with the radio constructor, but in other code lines I modify manually the path (inside.path = newInsideCircle), that's why is like that there. I will change it to be more readableDraelach
I implemented this in Objective-C in Xcode 6 and saw the issue. The same code in Xcode 5 (iOS 7.1) did not have the problem. It looks like there's a bug in SKShapeNode in iOS 8.0.0x141E