gpt4 book ai didi

objective-c - Sprite Kit - iOS 7.1 更新后对象因缩放而发生碰撞

转载 作者:搜寻专家 更新时间:2023-10-30 19:57:42 26 4
gpt4 key购买 nike

没有问题,但在 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];

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

最佳答案

  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 中的错误。

关于objective-c - Sprite Kit - iOS 7.1 更新后对象因缩放而发生碰撞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22336221/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com