我有以下代码
static const CGFloat kPipeWidth=56;
(void)topObstacle {
Obstacle *pipeTop = [Obstacle spriteNodeWithImageNamed:@"pipetop-1"];
[pipeTop setCenterRect:CGRectMake(26.0/kPipeWidth, 26.0/kPipeWidth, 4.0/kPipeWidth, 4.0/kPipeWidth)];
[pipeTop setYScale:pipeTopHeight/kPipeWidth];
[pipeTop setPosition:CGPointMake(self.size.width+(pipeTop.size.width/2),
self.size.height-(pipeTop.size.height/2))];
[self addChild:pipeTop];
pipeTop.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:pipeTop.size];
[pipeTop.physicsBody setAffectedByGravity:NO];
[pipeTop.physicsBody setDynamic:NO];
[pipeTop.physicsBody setCategoryBitMask:kPipeCategory];
[pipeTop.physicsBody setCollisionBitMask:kplayerCategory];
}
管道图片显示正确,但碰撞区域设置不正确。我的代码有什么问题!
谢谢你的帮助