一个节点有可能有两条物理体路径吗?我想创建一个节点,节点两侧有两个(圆形)物理体。
如果不可能,是否有任何变通方法可以实现?谢谢
最佳答案
您想使用[SKPhysicsBody bodyWithBodies:...]
。来自docs :
The shapes of the physics bodies passed into this method are used to create a new physics body whose covered area is the union of the areas of its children. These areas do not need to be contiguous. If there is space between two parts, other bodies may be able to pass between these parts. However, the physics body is treated as a single connected body, meaning that a force or impulse applied to the body affects all of the pieces as if they were held together with an indestructible frame.
它看起来像这样:
SKPhysicsBody *leftCircle = [SKPhysicsBody bodyWithCircleOfRadius:leftCircleRadius center:leftCircleCenter];
SKPhysicsBody *rightCircle = [SKPhysicsBody bodyWithCircleOfRadius:rightCircleRadius center:rightCircleCenter];
node.physicsBody = [SKPhysicsBody bodyWithBodies:@[leftCircle, rightCircle]];
关于ios - SpriteKit : One node with two physics body,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25178390/