SKSpriteNode(iOS)中的隐形圆圈笔触颜色

时间:2014-08-14 15:36:33

标签: ios xcode swift sprite-kit

我试图用黑色绘制笔触颜色,但它不会出现任何线条...

这是它在iOS模拟器中的显示方式:

Circle in iOS simulation

但是,如果我在Xcode游乐场中运行相同的代码,则圆圈是完美的

The circle in the playground live view

我的场景代码:

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
}

}

操场代码,它是OS X的实时视图不兼容性(实时视图): 它只会更改NSColor的UIColor

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)

我不知道发生了什么,如果我找到答案,我会发布答案。谢谢!

0 个答案:

没有答案