仪器使用精灵工具包模板分配图表

时间:2015-05-16 13:00:38

标签: swift sprite-kit instruments

我正在努力了解乐器如何运作并使我的应用更好。下面是默认SpriteKit模板的结果图像。我不明白为什么这么多分配,因为代码很小

override func didMoveToView(view: SKView) {
        /* Setup your scene here */
        let myLabel = SKLabelNode(fontNamed:"Chalkduster")
        myLabel.text = "Hello, World!";
        myLabel.fontSize = 65;
        myLabel.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame));

        self.addChild(myLabel)
    }

    override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
        /* Called when a touch begins */

        for touch in (touches as! Set<UITouch>) {
            let location = touch.locationInNode(self)

            let sprite = SKSpriteNode(imageNamed:"Spaceship")

            sprite.xScale = 0.5
            sprite.yScale = 0.5
            sprite.position = location

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

            sprite.runAction(SKAction.repeatActionForever(action))

            self.addChild(sprite)
        }
    }

Result

我试图找到教程,但其中很多都很老了

1 个答案:

答案 0 :(得分:0)

我们不是苹果程序员,我们真的不知道SpriteKit里面发生了什么。

我猜测它只是因为物理引擎的复杂性。

我建议只是留意泄漏。