我正在玩一个有物理世界的游戏 . 我在整个场景周围创建物理盒,以防止精灵从屏幕上消失 . 但问题是,当我向场景中添加太多物体时,其中一些物体会离开这个物理盒 . 这是场景周围的物理盒:

homeArea.size = CGSizeMake(self.frame.size.width, self.frame.size.height)
    homeArea.position = CGPointMake(self.frame.size.width / 2.0, self.frame.size.height / 2.0)
    homeLayer.addChild(homeArea)

    homeArea.physicsBody = SKPhysicsBody(edgeLoopFromRect: CGRectMake(-homeArea.frame.width / 2.0, -homeArea.frame.height / 2.0, homeArea.frame.size.width, homeArea.frame.size.height))

这是太多的身体:

func addSprites() {
    for i in 0...20 {
        for j in 0...20 {
            let shape = SKShapeNode(rect: CGRectMake(-5.0, -5.0, 10.0, 10.0))
            shape.fillColor = SKColor.redColor()
            shape.position = CGPointMake(self.frame.size.width - (shape.frame.size.width * CGFloat(i)), 0.0 + (shape.frame.size.height * CGFloat(j)))
            shape.physicsBody = SKPhysicsBody(rectangleOfSize: shape.frame.size)
            shape.physicsBody?.dynamic = true
            addChild(shape)
        }
    }
}

我为这些尸体制造了一个大炮射击 . 在那里,我想用大炮的子弹来创造像飞溅一样的东西 . 我从精灵那里射到这堵墙,并注意到节点的数量,因为我的子弹,一些精灵从屏幕上掉了下来 . 我添加了方法usesPreciseCollisionDetection . 但它完全一样 .