2014-02-28 18 views
1

我看到崩溃时,已经分配路径的精灵在64位iOS设备上结束该路径,并且仅当我移动时在完成路径的精灵。SpriteKit在完成路径后移动精灵时发生崩溃,仅在64位设备上

下面是堆栈跟踪(?)。

enter image description here

而且这里是我使用的创建路径的代码。

UIBezierPath *path1 = [[UIBezierPath alloc] init]; 

[path1 moveToPoint: CGPointMake(249, 430)]; 
[path1 addCurveToPoint: CGPointMake(154.7, 236.44) controlPoint1: CGPointMake(68.12, 359.17) controlPoint2: CGPointMake(117, 278.5)]; 
[path1 addCurveToPoint: CGPointMake(316, 127) controlPoint1: CGPointMake(192.41, 194.38) controlPoint2: CGPointMake(280.07, 195.64)]; 
[path1 addCurveToPoint: CGPointMake(249, -93) controlPoint1: CGPointMake(351.93, 58.36) controlPoint2: CGPointMake(327.18, -48.95)]; 

SKAction *firstPath = [SKAction followPath:[path1 CGPath] asOffset:NO orientToPath:NO duration:1.65]; 

当我运行代码,我要做的就是告诉精灵来运行这个行动,并完成时 -

这是代码,导致崩溃的行。

[sprite runAction: [SKAction moveToPoint:CGPointMake(-100, -100)]]; 

我试过打开NSZombie,我没有看到任何东西。另外,我将精灵设置为一个强大的属性,但仍然没有区别。

此次崩溃只发生在64位iOS设备上,而不是在32位设备上。

任何有关在哪里寻找解决方案的建议?

回答

1

UIBezierPath CGPath documentation

的路径对象本身是由UIBezierPath对象所拥有的,是 有效期至您做进一步的修改路径。

我假定通过将路径传递给Sprite Kit,动作将最终释放它不拥有的路径,从而过度释放它。

尝试使路径的副本:

SKAction *firstPath = [SKAction followPath:CGPathCreateCopy([path1 CGPath]) 
            asOffset:NO 
           orientToPath:NO 
            duration:1.65]; 
+0

感谢您的回答,我给它一个尝试,让你知道它是如何工作的。 –

+0

@steffen这种解决方案仅适用于64位设备是不是有点疯狂?到目前为止,我已经看到2次崩溃,其中sprite套件只在64位设备上崩溃。有兴趣听到你的想法。 – Mazyod