我在 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"];
对此有什么想法吗?
发现问题。有 2 个 Action 具有相同的 animationKey @"next_arrow"。
[self runAction:[self animateNextArrowFadeIn] withKey:@"next_arrow"];
第二个 Action 在第一个 Action 完成之前开始。第二个 Action 尝试从队列中删除带有该键的动画,但没有使用该键的 Action ,因为第一个 Action 从队列中删除了该键。
解决方法是重命名第二个动画的操作键。
[self runAction:[self animateNextArrowFadeIn] withKey:@"next_arrow_down"];
感谢大家的支持!
关于ios - Sprite Kit iOS 7.1 在 wasRemovedFromTargetAtTime 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22615396/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |