我希望接地节点始终与框架一样宽。我目前拥有的代码是;

    ground.position = CGPointMake(0, 175)
    ground.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(self.frame.size.width, 1))
    ground.physicsBody!.dynamic = false
    ground.physicsBody!.categoryBitMask = PhysicsCategory.ground
    ground.physicsBody?.contactTestBitMask = PhysicsCategory.ground
    ground.physicsBody?.collisionBitMask = PhysicsCategory.ground
    self.addChild(ground)


如何使它与框架一样宽?

最佳答案

尝试使用此方法将宽度调整为场景大小,或者几乎只是屏幕大小

 ground.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: (scene?.size.width)!, height: ("specify your height"))

关于ios - Spritekit框架长地面节点,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43532462/

10-08 20:50