“线程1:EXC_BAD_ACCESS(代码= 1,地址= 0xe000000c)错误”,问题出在哪里?

时间:2013-08-11 04:36:56

标签: objective-c cocos2d-iphone thread-safety

我正在制作一个Cocos2d游戏,我收到此错误:“线程1:EXC_BAD_ACCESS(代码= 1,地址= 0xe000000c)错误”当我运行我的应用程序时。这是我认为导致问题的代码,但我无法弄清楚问题。

这是代码。

#import "BlueEnemy.h"


@implementation BlueEnemy
+(id)createBlueEnemy{
    return [[[self alloc]init]autorelease];
}

-(id)init{
    if ((self = [super init])) {
        CGSize size = [[CCDirector sharedDirector]winSize];
        screenWidth = size.width;
        screenHeight = size.height;

        screenBounds = [[UIScreen mainScreen] bounds];

        blueEnemyFlameCounter = 1;

        xPointBlueEnemy = screenWidth - 50;
        yPointBlueEnemy = screenHeight - 100;

        [self schedule:@selector(blueEnemyFlight:)interval:28.0f/1.0f];
    }
    return self;
}

-(void)blueEnemyFlight:(ccTime)delta{
    blueEnemy = [CCSprite spriteWithFile:@"blueenemy.png"];
    blueEnemy.position = ccp(xPointBlueEnemy, yPointBlueEnemy);
    [self addChild:blueEnemy z:-1];

    CCMoveTo* blueEnemyMoveDown  = [CCMoveTo actionWithDuration:3.0        position:ccp(xPointBlueEnemy, 70)];
    CCMoveTo* blueEnemyMoveUp = [CCMoveTo actionWithDuration:3.0 position:ccp(xPointBlueEnemy, yPointBlueEnemy - 60)];
    CCSequence* blueEnemyFloatingSequence = [CCSequence actions:blueEnemyMoveDown, blueEnemyMoveUp, nil];
    CCRepeat* blueEnemyFloatingRepeat = [CCRepeat actionWithAction:blueEnemyFloatingSequence times:3];
    [blueEnemy runAction:blueEnemyFloatingRepeat];

    [self schedule:@selector(shootTheWaterBullets:)interval:1.0f/2.0f];

    [self schedule: @selector(blueEnemyFlame:)interval:1.0f/5.0f];

    [self schedule: @selector(removeTheBlueEnemy:)interval:20.0f/1.0f];
}

-(void)blueEnemyFlame:(ccTime)delta{
    blueEnemyFlameCounter ++;

    if (blueEnemyFlameCounter % 2){
        [blueEnemy setTexture:[[CCSprite spriteWithFile:@"blueenemy2.png"]texture]];
    }else{
        [blueEnemy setTexture:[[CCSprite spriteWithFile:@"blueenemy.png"]texture]];
    }
}

-(void)removeTheBlueEnemy:(ccTime)delta{
    CCMoveBy* moveUpBlueEnemy = [CCMoveBy actionWithDuration:0.5 position:ccp(70, 100)];
    [blueEnemy runAction:moveUpBlueEnemy];
    [blueEnemy removeChild:blueEnemy cleanup:YES];
    [self unschedule:@selector(removeTheBlueEnemy:)];
}
@end

我对cocos2d和目标c都很陌生,所以我不知道这是不是你想要的,但无论如何:

libobjc.A.dylib`objc_msgSend_stret:
0x2267328:  movl   12(%esp), %ecx
0x226732c:  movl   8(%esp), %eax
0x2267330:  testl  %eax, %eax
0x2267332:  je     0x2267398                 ; objc_msgSend_stret + 112
0x2267334:  movl   (%eax), %edx
0x2267336:  movzwl 12(%edx), %eax
0x226733a:  andl   %ecx, %eax
0x226733c:  shll   $3, %eax
0x226733f:  addl   8(%edx), %eax
0x2267342:  cmpl   (%eax), %ecx
0x2267344:  jne    0x226734b                 ; objc_msgSend_stret + 35
0x2267346:  testl  %eax, %eax
0x2267348:  jmpl   *4(%eax)
0x226734b:  cmpl   $0, (%eax)
0x226734e:  je     0x2267399                 ; objc_msgSend_stret + 113
0x2267350:  cmpl   8(%edx), %eax
0x2267353:  je     0x2267361                 ; objc_msgSend_stret + 57
0x2267355:  subl   $8, %eax
0x2267358:  cmpl   (%eax), %ecx
0x226735a:  jne    0x226734b                 ; objc_msgSend_stret + 35
0x226735c:  testl  %eax, %eax
0x226735e:  jmpl   *4(%eax)
0x2267361:  movzwl 12(%edx), %eax
0x2267365:  shll   $3, %eax
0x2267368:  addl   8(%edx), %eax
0x226736b:  jmp    0x226737a                 ; objc_msgSend_stret + 82
0x226736d:  cmpl   $0, (%eax)
0x2267370:  je     0x2267399                 ; objc_msgSend_stret + 113
0x2267372:  cmpl   8(%edx), %eax
0x2267375:  je     0x2267383                 ; objc_msgSend_stret + 91
0x2267377:  subl   $8, %eax
0x226737a:  cmpl   (%eax), %ecx
0x226737c:  jne    0x226736d                 ; objc_msgSend_stret + 69
0x226737e:  testl  %eax, %eax
0x2267380:  jmpl   *4(%eax)
0x2267383:  pushl  %ebp
0x2267384:  movl   %esp, %ebp
0x2267386:  pushl  $0
0x2267388:  pushl  $0
0x226738a:  pushl  $0
0x226738c:  pushl  %edx
0x226738d:  pushl  %ecx
0x226738e:  movl   12(%ebp), %ecx
0x2267391:  pushl  %ecx
0x2267392:  calll  0x2255720                 ; objc_msgSend_corrupt_cache_error
0x2267397:  nop    
0x2267398:  ret    
0x2267399:  movl   12(%esp), %ecx
0x226739d:  movl   8(%esp), %eax
0x22673a1:  pushl  %ebp
0x22673a2:  movl   %esp, %ebp
0x22673a4:  subl   $12, %esp
0x22673a7:  pushl  %edx
0x22673a8:  pushl  %ecx
0x22673a9:  pushl  %eax
0x22673aa:  calll  0x225f017                 ; _class_lookupMethodAndLoadCache3
0x22673af:  leave  
0x22673b0:  testl  %eax, %eax
0x22673b2:  jmpl   *%eax

希望这有助于@bbum

0 个答案:

没有答案