Invisible circle stroke color in SKSpriteNode (iOS)

笑着哭i 提交于 2020-01-06 08:26:03

问题


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:

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

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!

来源:https://stackoverflow.com/questions/25312055/invisible-circle-stroke-color-in-skspritenode-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!