奇怪的 EXC_BAD_ACCESS SpriteKit removeSubsprite 崩溃 [英] Strange EXC_BAD_ACCESS SpriteKit removeSubsprite crash

查看:23
本文介绍了奇怪的 EXC_BAD_ACCESS SpriteKit removeSubsprite 崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 SpriteKit 的新手,刚刚构建了我的第一个游戏.在 iOS 7.1 之前,一切都运行良好.现在,经过几次升级到一个新的水平并呈现一个新的Scene,它崩溃了.我不认为我以不正确的方式呈现它:

I am new to SpriteKit and just built my first game. Everything was working great until iOS 7.1. Now, after a few times of advancing to a new level and presenting a new Scene, it crashes. I don't think I am presenting it in an incorrect way:

ZSSMyScene *nextLevel = [[ZSSMyScene alloc] initWithSize:self.size level:self.level score:score];
[self.view presentScene:nextLevel];

我收到一个 EXC_BAD_ACCESS 错误,它看起来好像发生在 removeSubsprite 上,但我在代码中找不到要删除子精灵的任何地方:

I get a EXC_BAD_ACCESS error, and it looks like it is happening on removeSubsprite, but I can't find anywhere in my code that I would be removing a subsprite:

不确定要提供哪些其他信息,因为这只是我更新到 iOS 7.1 SDK 时似乎开始的一个模糊错误.

Not sure what other info to provide as this is just an obscure error that seemed to start when I updated to iOS 7.1 SDK.

推荐答案

这似乎是一个错误,可能只有 SKShapeNodes.

This appears to be a bug, possibly only with SKShapeNodes.

我的解决方案是创建一个 SKNode 类别,并在我要删除的任何节点有子节点时调用此清理方法.

My solution was to create an SKNode category and call this cleanup method when any node i'm removing has children.

- (void)cleanUpChildrenAndRemove {
    for (SKNode *child in self.children) {
        [child cleanUpChildrenAndRemove];
    }
    [self removeFromParent];
}

这篇关于奇怪的 EXC_BAD_ACCESS SpriteKit removeSubsprite 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆