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

查看:99
本文介绍了奇怪的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天全站免登陆