0

我正在制作一个 Cocos2d 游戏,当我运行我的应用程序时出现此错误:“线程 1:EXC_BAD_ACCESS(code=1, address=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 和 Objective c 非常陌生,所以我不知道这是否是你要找的东西,但无论如何:

libobjc.A.dylib`objc_msgSend_stret:
0x2267328: movl 12(%esp), %ecx
0x226732c: movl 8(%esp), %eax
0x2267330: testl %eax, %eax
0x2267332: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: 0x2267399; objc_msgSend_stret + 113
0x2267350:cmpl 8(%edx),%eax
0x2267353: 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:0x2267399;objc_msgSend_stret + 113
0x2267372:cmpl 8(%edx),%eax
0x2267375: 0x2267383; objc_msgSend_stret + 91
0x2267377: subl $8, %eax
0x226737a: cmpl (%eax), %ecx
0x226737c:jne 0x226736d;objc_msgSend_stret + 69
0x226737e: 测试 %eax, %eax
0x2267380: jmpl *4(%eax)
0x2267383: pushl %ebp
0x2267384: 移动 %esp, %ebp
0x2267386: 推 $0
0x2267388: 推送 $0
0x226738a: pushl $0
0x226738c: pushl %edx
0x226738d: pushl %ecx
0x226738e: movl 12(%ebp), %ecx
0x2267391: pushl %ecx
0x2267392:调用0x2255720;objc_msgSend_corrupt_cache_error
0x2267397:无    
0x2267398: 回复    
0x2267399: movl 12(%esp), %ecx
0x226739d: movl 8(%esp), %eax
0x22673a1: pushl %ebp
0x22673a2: 移动 %esp, %ebp
0x22673a4: subl $12, %esp
0x22673a7: pushl %edx
0x22673a8: pushl %ecx
0x22673a9: pushl %eax
0x22673aa: 调用 0x225f017 ;_class_lookupMethodAndLoadCache3
0x22673af:离开  
0x22673b0: 测试 %eax, %eax
0x22673b2: jmpl *%eax

希望这有助于@bbum

4

0 回答 0