我在物理体上设置了碰撞位掩码,这样它就不会发生碰撞,但仍然会发生碰撞。
-(void) createPlayer{
player = [SKSpriteNode spriteNodeWithImageNamed:@"GonGonRed"];
player.position = CGPointMake(40, 100);
player.size = CGSizeMake(35*self.frame.size.height/320, 35*self.frame.size.height/320);
player.zPosition = 7;
player.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:player.size.width/2-1];
player.physicsBody.dynamic = NO;
player.physicsBody.allowsRotation = NO;
player.physicsBody.usesPreciseCollisionDetection = YES;
player.physicsBody.categoryBitMask = 1;
player.physicsBody.contactTestBitMask = 4;
player.physicsBody.collisionBitMask = 2;
player.physicsBody.mass = 0.013963;
[self addChild:player];
}
SKSpriteNode *wheel = [SKSpriteNode spriteNodeWithImageNamed:@"wheel"];
wheel.size = CGSizeMake(newwidth, newheight);
wheel.position = CGPointMake(px, py);
wheel.name = @"wheel";
wheel.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:newwidth/2];
wheel.physicsBody.dynamic = NO;
wheel.physicsBody.restitution = obstacleRestitution;
wheel.physicsBody.usesPreciseCollisionDetection = YES;
wheel.physicsBody.categoryBitMask = 3;
wheel.physicsBody.collisionBitMask = 0;
wheel.physicsBody.contactTestBitMask = 0;
wheel.zPosition = 5;
轮子和玩家不应该发生碰撞,但确实如此。一世