加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – Sprite Kit – iOS 7.1更新后由于比例而导致的对

发布时间:2020-12-14 17:12:57 所属栏目:百科 来源:网络整理
导读:没有问题,但在iOS 7.1更新后,对象正在碰撞2管的差距.之前有人说,可能是因为’yScale’,但我找不到解决方案. 一些代码; Pipe *pipe = [[Pipe alloc] initWithImageNamed:pipeImageName]; [pipe setCenterRect:CGRectMake(26.0/kPipeWidth,26.0/kPipeWidth,4.0
没有问题,但在iOS 7.1更新后,对象正在碰撞2管的差距.之前有人说,可能是因为’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];

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

解决方法

Pipe *pipe = [[Pipe alloc] initWithImageNamed:pipeImageName];
  [pipe setCenterRect:CGRectMake(26.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中的一个错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读