使用 sprite 套件模板的图表的仪器分配
Instruments Allocations of the charts using sprite kit template
我正在尝试了解 Instruments 的工作原理并改进我的应用程序。下面是默认 SpriteKit 模板的结果图像。不明白为什么会有这么多Allocations,因为代码小
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)
}
}
我试着找教程,但很多都太旧了
好吧,我们不是 apple 程序员,我们真的不知道 SpriteKit 里面发生了什么。
我猜这只是因为物理引擎的复杂性。
我建议只注意泄漏。
我正在尝试了解 Instruments 的工作原理并改进我的应用程序。下面是默认 SpriteKit 模板的结果图像。不明白为什么会有这么多Allocations,因为代码小
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)
}
}
我试着找教程,但很多都太旧了
好吧,我们不是 apple 程序员,我们真的不知道 SpriteKit 里面发生了什么。
我猜这只是因为物理引擎的复杂性。
我建议只注意泄漏。