在SpriteKit中使用PhysicsBodies时发生意外行为

时间:2018-10-28 18:15:00

标签: xcode sprite-kit

在本练习中,我的物理机构遇到了一些问题。

当点(蛇)移动得非常快时,它会通过砖的物理物体“挤压”自身。有人可以帮忙吗?

enter image description here

蛇:

self.physicsBody.categoryBitMask = snakeCategory;
self.physicsBody.collisionBitMask = lineCategory | brickCollissionCategory;
self.physicsBody.contactTestBitMask = brickContactCategory;
self.physicsBody.usesPreciseCollisionDetection = YES;
self.physicsBody.allowsRotation = NO;
self.physicsBody.dynamic = YES;
self.physicsBody.restitution = 0;
self.physicsBody.affectedByGravity = NO;

砖:

self.physicsBody.categoryBitMask = brickCollissionCategory;
self.physicsBody.collisionBitMask = snakeCategory;
self.physicsBody.dynamic = NO;
self.physicsBody.affectedByGravity = NO;
self.physicsBody.usesPreciseCollisionDetection = YES;
self.physicsBody.restitution = 0;

0 个答案:

没有答案