gpt4 book ai didi

sprite-kit - 线程1 : EXEC_BAD_ACCESS (code=1), 地址=0x6000000000000018)

转载 作者:行者123 更新时间:2023-12-02 09:36:48 25 4
gpt4 key购买 nike

阅读所有关于此错误与内存相关并尝试访问不再存在的内容的帖子。

问题:几乎以随机的间隔弹出错误。它可以在杀死第一个敌人或杀死第N个敌人后出现。然而,它只会在敌人被杀死时出现。

测试:在 iPhone 5s 上运行 iOS 8 beta 5、Xcode 6 beta 5。

代码流程:

敌人 SKNodes 类实例在关卡开始时创建并存储在 NSMutableArray 中以供引用:

Goblin *newGoblin = [[Goblin alloc] initFacingDirection:1];
// set various properties…
[enemyGoblins addObject:newGoblin];

玩家的剑与敌人接触:

NSMutableArray *discardedItems = [NSMutableArray array];

for(Goblin *object in enemyGoblins)
{
[object runBloodBurst:true damagePoints:_player.swordDamage];
if(object.goblinHealth < 0)
[discardedItems addObject:object];
}

if([discardedItems count] > 0)
[enemyGoblins removeObjectsInArray:discardedItems];

在 Goblin 类中,“die”代码是:

if(self.goblinHealth < 0)
{
SKAction *wait0 = [SKAction waitForDuration:1.0];

SKAction *block0 = [SKAction runBlock:^{
[self removeActionForKey:@"animation"];
[self runAction:[_animations goblin_dieLeft]];
}];

SKAction *block1 = [SKAction runBlock:^{
[self removeFromParent];
}];

[self runAction:[SKAction sequence:@[block0, wait0, block1]]];

}

我尝试过的:我禁用了“discardedItems”代码,因为我认为一旦引用丢失,ARC 可能会从内存中转储对象,并且后续的 Goblin 类的“die 动画”会导致崩溃,但这并没有解决问题。我尝试了僵尸和断点,但也没有得到任何有用的线索。

对于我所尝试的内容,我是否找错了方向,或者有人在 Beta 5 中遇到过类似的问题吗?

编辑

这是回溯:

(lldb) bt * thread #1: tid = 0x3264b, 0x000000018cb13434 SpriteKitSKCSprite::update(double) + 404, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x7000000000000018)
frame #0: 0x000000018cb13434 SpriteKit
SKCSprite::update(double) + 404 frame #1: 0x000000018cb13440 SpriteKitSKCSprite::update(double) + 416
frame #2: 0x000000018cb13440 SpriteKit
SKCSprite::update(double) + 416 frame #3: 0x000000018cacbf28 SpriteKit-[SKScene _update:] + 140
frame #4: 0x000000018cae63f8 SpriteKit
-[SKView(Private) _update:] + 568 frame #5: 0x000000018cae3a10 SpriteKit-[SKView renderCallback:] + 764
frame #6: 0x000000018cae0a9c SpriteKit
__29-[SKView setUpRenderCallback]_block_invoke + 60 frame #7: 0x000000018cb0d890 SpriteKit-[SKDisplayLink _callbackForNextFrame:] + 272
frame #8: 0x000000010042ca9c libglInterpose.dylib
-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168 frame #9: 0x000000018c615b90 QuartzCoreCA::Display::DisplayLinkItem::dispatch() + 32
frame #10: 0x000000018c615a28 QuartzCore
CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 324 frame #11: 0x00000001897dddc0 IOKitIODispatchCalloutFromCFMessage + 376
frame #12: 0x00000001885dcf34 CoreFoundation
__CFMachPortPerform + 180 frame #13: 0x00000001885f1b38 CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
frame #14: 0x00000001885f1a98 CoreFoundation
__CFRunLoopDoSource1 + 436 frame #15: 0x00000001885efa18 CoreFoundation__CFRunLoopRun + 1640
frame #16: 0x000000018851d664 CoreFoundation
CFRunLoopRunSpecific + 396 frame #17: 0x000000019154f5a4 GraphicsServicesGSEventRunModal + 168
frame #18: 0x000000018ccd6164 UIKit
UIApplicationMain + 1488 * frame #19: 0x0000000100165530 CarcerQuestmain(argc=1, argv=0x000000016fdab9d8) + 116 at main.m:16
frame #20: 0x000000019885aa08 libdyld.dylib
start + 4 (lldb)

最佳答案

改变

[self runAction:[SKAction 序列:@[block0, wait0, block1]]];

[self runAction:[SKAction 序列:@[block0, wait0]] 完成:^{
[_self 从Parent 删除];
}];

在更新 IOS7 代码以在 IOS8 上运行时,我遇到了同样的问题,并使用完成 block 修复了该问题。

关于sprite-kit - 线程1 : EXEC_BAD_ACCESS (code=1), 地址=0x6000000000000018),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25140981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com