【发布时间】:2014-03-24 16:40:45
【问题描述】:
我在 iOS 7.1 上的 Sprite Kit 中发生了崩溃。我尝试使用 Xcode 5.0.2 和 5.1 构建。结果是一样的。在 iOS 7.1 设备上仍然崩溃。
这里附上截图。
我找到了导致崩溃的代码。
- (WATDirection *)panDown {
WATDirection *direction = [[WATDirection alloc] init];
CGFloat newY = 830;
@weakify(self)
[direction addStartHandler:^(WATDirection *direction) {
@strongify(self)
self.panningDown = YES;
[self runAction:[self animateNextArrowFadeOut] withKey:@"next_arrow"];
// Move the scene
SKAction *panDown = [SKAction moveToY:newY duration:1.5];
panDown.timingMode = SKActionTimingEaseInEaseOut;
[self.rootNode runAction:panDown withKey:@"panDown"];
// Fade in the pipes
SKNode *pipes = [self.rootNode childNodeWithName:@"pipes"];
SKAction *fadeIn = [SKAction sequence:@[
[SKAction waitForDuration:0.3],
[SKAction fadeAlphaTo:1 duration:0.6]
]];
[pipes runAction:fadeIn withKey:@"fadeIn"];
[pipes enumerateChildNodesWithName:@"pipe" usingBlock:^(SKNode *node, BOOL *stop) {
SKAction *fadeIn = [SKAction sequence:@[
[SKAction waitForDuration:1.1],
[SKAction fadeAlphaTo:1 duration:0.6],
]];
[node runAction:fadeIn withKey:@"fadeIn"];
}];
// Fade out the overlay
SKNode *pipesOverlay = [pipes childNodeWithName:@"pipes_overlay"];
SKAction *fadeOut = [SKAction sequence:@[
[SKAction waitForDuration:3.0],
[SKAction fadeAlphaTo:0 duration:0.5],
[SKAction removeFromParent]
]];
[pipesOverlay runAction:fadeOut withKey:@"fadeOut"];
[self runAction:[SKAction sequence:@[
[SKAction waitForDuration:3.5],
[SKAction runBlock:^{
[direction finish];
}]
]]];
}];
[direction addFinishHandler:^(WATDirection *direction) {
@strongify(self)
[self runAction:[self animateNextArrowFadeIn] withKey:@"next_arrow"];
self.panningDown = NO;
self.pannedDown = YES;
}];
[direction addCancelHandler:^(WATDirection *direction) {
@strongify(self)
SKAction *panDown = [SKAction moveToY:newY duration:0];
[self.rootNode runAction:panDown withKey:@"panDown"];
SKNode *pipesOverlay = [self childNodeWithName:@"//pipes_overlay"];
[pipesOverlay removeFromParent];
[self runAction:[self animateNextArrowFadeIn] withKey:@"next_arrow"];
self.panningDown = NO;
self.pannedDown = YES;
}];
return direction;
}
这两行是问题:
@strongify(self)
[self runAction:[self animateNextArrowFadeIn] withKey:@"next_arrow"];
对此有什么想法吗?
【问题讨论】:
-
你能发一些代码吗?
-
请设置异常断点,在crash附近做一些相关的源码排查,然后贴一些代码。
-
@Ilario 这是问题所在。我找不到产生此错误的代码。
-
@danh 我做到了。没有成功。启用僵尸会产生相同的结果。
标签: ios iphone ipad sprite-kit