Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos SKShapeNode第一次未填充_Macos_Swift_Sprite Kit - Fatal编程技术网

Macos SKShapeNode第一次未填充

Macos SKShapeNode第一次未填充,macos,swift,sprite-kit,Macos,Swift,Sprite Kit,当我添加下面的代码时,第一个精灵不是填充,但其他精灵是法线(填充的红色矩形) 有人知道它是Xcode 7.0中的Swift错误还是GCPath或SKShapeNode配置中缺少的东西吗 代码与OSX的游戏模板相同,但有一些更改 import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView) { /* Setup your scene here */ } func ge

当我添加下面的代码时,第一个精灵不是填充,但其他精灵是法线(填充的红色矩形) 有人知道它是Xcode 7.0中的Swift错误还是GCPath或SKShapeNode配置中缺少的东西吗

代码与OSX的游戏模板相同,但有一些更改

import SpriteKit

class GameScene: SKScene {
   override func didMoveToView(view: SKView) {
    /* Setup your scene here */

}


func getSprite() -> SKShapeNode
{
    let aPath = CGPathCreateMutable()
    CGPathAddRect(aPath,nil,   CGRect(x: 0, y: 0, width: 100, height: 100))
    let shapeNode = SKShapeNode()
    shapeNode.strokeColor = SKColor.redColor()
    shapeNode.fillColor = SKColor.redColor()

    shapeNode.lineWidth = 1
    shapeNode.path =  aPath
    shapeNode.zPosition = 2
    return shapeNode
}


override func mouseDown(theEvent: NSEvent) {
    /* Called when a mouse click occurs */

    let location = theEvent.locationInNode(self)

    let sprite = getSprite() //SKSpriteNode(imageNamed:"Spaceship")
    sprite.position = location;
    sprite.setScale(0.5)

    let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
    sprite.runAction(SKAction.repeatActionForever(action))

    self.addChild(sprite)
}

override func update(currentTime: CFTimeInterval) {
    /* Called before each frame is rendered */
}
}

我真的不知道是什么引起了这个问题。但我有两点要分享:1。在
didMoveToView
中绘制任何内容都将消除该问题。2.使用相同代码的iOS 8和iOS 9上不存在此问题。我真的不知道是什么导致了此问题。但我有两点要分享:1。在
didMoveToView
中绘制任何内容都将消除该问题。2.使用相同代码的iOS 8和iOS 9上不存在此问题。