我有以下代码每秒生成块。
_ = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("spawnPipes"), userInfo: nil, repeats: true)
func spawnPipes() {
let square = SKShapeNode(rectOfSize: CGSize(width: 50, height: 50))
square.fillColor = SKColor.whiteColor()
square.strokeColor = SKColor.whiteColor()
square.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: 50, height: 50))
square.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame))
self.addChild(square)
当我在iPhone 6上运行代码时,它显示316个节点,但在模拟器上显示158个节点。为什么我的iPhone上有两倍的节点?
它创造了滞后:(并减少了FPS。