Sprite Kit-iOS 7.1更新后,对象因缩放而发生碰撞 [英] Sprite Kit - object colliding because of scale after iOS 7.1 update
本文介绍了Sprite Kit-iOS 7.1更新后,对象因缩放而发生碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
没有问题,但是在iOS 7.1更新之后,对象正在碰撞2pipes的间隙.之前有人说过,可能是因为"yScale",但是我找不到解决方案.
There was no problem but after iOS 7.1 update, object is colliding 2pipes' gap. Someone said before, it can be because of 'yScale' but I couldn't find the solution.
某些代码;
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];
任何帮助将不胜感激.谢谢!
Any help will be appreciated. Thank you!
推荐答案
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中的错误.
This may help you. I think this is a bug in ios7.1.
这篇关于Sprite Kit-iOS 7.1更新后,对象因缩放而发生碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文