3

没有问题,但在 iOS 7.1 更新后,对象正在碰撞 2pipes 的间隙。之前有人说过,可能是因为“yScale”,但我找不到解决方案。

一些代码;

  Pipe *pipe = [[Pipe alloc] initWithImageNamed:pipeImageName];
  [pipe setCenterRect:CGRectMake(26.0/kPipeWidth, 26.0/kPipeWidth, 4.0/kPipeWidth, 4.0/kPipeWidth)];
  [pipe setYScale:height/pipe.size.height];
  [pipe setPosition:CGPointMake(320+(pipe.size.width/2), abs(pipeYOffset + (pipe.size.height/2)))];

  pipe.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:pipe.size];
  [pipe.physicsBody setAffectedByGravity:NO];
  [pipe.physicsBody setDynamic:NO];

任何帮助将不胜感激。谢谢!

4

2 回答 2

6
  Pipe *pipe = [[Pipe alloc] initWithImageNamed:pipeImageName];
  [pipe setCenterRect:CGRectMake(26.0/kPipeWidth, 26.0/kPipeWidth, 4.0/kPipeWidth, 4.0/kPipeWidth)];

//set the physicsBody before X/Yscale
  pipe.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:pipe.size];

  [pipe setYScale:height/pipe.size.height];
  [pipe setPosition:CGPointMake(320+(pipe.size.width/2), abs(pipeYOffset + (pipe.size.height/2)))];

  [pipe.physicsBody setAffectedByGravity:NO];
  [pipe.physicsBody setDynamic:NO];

这可能会对您有所帮助。我认为这是ios7.1中的一个错误。

于 2014-03-12T03:59:04.737 回答
1

I have the same problem, my game got released tonight and is now unplayable! That totally sucks. In my opinion the old behaviour of iOS 7.0 was buggy since PhysicsBodyies didn't scale with the sprite.

Since iOS7.1, PhysicsBodies apparently adapt their size to the sprite's scale. I'm not 100% sure yet if this is in fact so, but I'll find out soon enough. Just downloading the Xcode update, I'll let you know after I've done some testing.

于 2014-03-12T06:59:33.860 回答