我无法让我的墙体物理机构难以穿透。如果我的播放器节点物理主体以缓慢的“速度”与墙壁相撞,则停止。但是,如果它以“快速”的速度进行,它会穿过墙壁。我的球员被PanGestureRecognizer
移动。通过速度,我基本上是指如果突然出现“快速”滑动,或者手势不是缓慢移动的平移手势,那么玩家会穿过墙壁。这是我的节点属性:让SKPhysicsBody难以穿透?
self.player.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:self.player.size];
self.player.physicsBody.categoryBitMask = SVGPlayerCategory;
self.player.physicsBody.contactTestBitMask = SVGWallCategory;
self.player.physicsBody.collisionBitMask = SVGWallCategory;
self.player.physicsBody.dynamic = YES;
self.player.physicsBody.usesPreciseCollisionDetection = YES;
self.player.physicsBody.velocity = CGVectorMake(0, 0);
self.leftWall.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:self.leftWall.size];
self.leftWall.physicsBody.categoryBitMask = SVGWallCategory;
self.leftWall.physicsBody.contactTestBitMask = SVGPlayerCategory;
self.leftWall.physicsBody.collisionBitMask = SVGPlayerCategory;
self.leftWall.physicsBody.dynamic = NO;
self.leftWall.physicsBody.resting = YES;
如果有帮助,这是我的招法:
-(void)dragPlayer: (UIPanGestureRecognizer *)gesture {
CGPoint translation = [gesture translationInView:self.view];
SKAction *move = [SKAction moveByX:translation.x y:-translation.y duration:0];
[self.player runAction:move];
[gesture setTranslation:CGPointMake(0, 0) inView:self.view];
}
有什么我失踪?