私のアプリは iPhone で正常にコンパイルされていますが、iPad でコンパイルしようとすると、次のエラーがスローされます: EXC_BAD_ACCESS (code 1, address = 0xa0000008)
私のコードのこの時点で:
[self addChild:settings z:2];
なぜこれが起こっているのか分かりません...誰か?
mainMenu.m:
#import "mainMenu.h"
#import "gameData.h"
#import "gameDataParser.h"
BOOL settingsOut;
@implementation mainMenu
@synthesize iPad;
- (id)init{
if( (self=[super init])) {
CGSize screenSize = [CCDirector sharedDirector].winSize;
mainMenu *menuLayer = [[mainMenu alloc] autorelease];
[self addChild:menuLayer];
settingsMenu *settings = [settingsMenu node]; <----- app breaks at breakpoint here
[self addChild:settings z:2]; <----- receive error if breakpoint here
_settings = settings;
settingsOut = FALSE;
CGPoint offScreenPoint = ccp(screenSize.width+(screenSize.width/2), 0);
settings.position = offScreenPoint;
// gameData *gameData = [gameDataParser loadData];
// [gameDataParser saveData:gameData];
self.iPad = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
if (screenSize.height > 490){
CCSprite *background = [CCSprite spriteWithFile:@"mainBackgroundiPhoneFive.png"];
background.position = ccp(screenSize.width/2, screenSize.height/2);
[self addChild:background];
}
else{
CCSprite *background = [CCSprite spriteWithFile:@"mainBackground.png"];
background.position = ccp(screenSize.width/2, screenSize.height/2);
[self addChild:background];
}
[self addButtons: screenSize.height];
}
return self;
}
mainMenu.h:
#import "cocos2d.h"
#import "SceneManager.h"
#import "settingsMenu.h"
extern BOOL settingsOut;
@interface mainMenu : CCScene {
CCLayer * _settings;
CCMenu * _play;
}
@property (nonatomic, assign) BOOL iPad;
@property (nonatomic, retain) CCLayer *settings;
@property (nonatomic, retain) CCMenu *play;
- (void) addButtons: (int) screenSize;
@end
settingsMenu.h:
#import "gameData.h"
#import "gameDataParser.h"
#import "cocos2d.h"
@interface settingsMenu : CCLayer {
CCMenuItem *_musicOn;
CCMenuItem *_musicOff;
CCMenuItem *_invertControlsOn;
CCMenuItem *_invertControlsOff;
}
@property (nonatomic, assign) BOOL iPad;
@end
settingsMenu.m
#import "settingsMenu.h"
#import "SimpleAudioEngine.h"
#import "mainMenu.h"
#import "sceneManager.h"
BOOL settingsOut;
@implementation settingsMenu
- (id)init{
if((self=[super init])) {
// Determine Screen Size
CGSize screenSize = [CCDirector sharedDirector].winSize;
self.iPad = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
if (screenSize.height > 490){
CCSprite *background = [CCSprite spriteWithFile:@"settingsiPhoneFive.png"];
background.position = ccp(screenSize.width/2, screenSize.height/2);
[self addChild:background];
}
else{
CCSprite *background = [CCSprite spriteWithFile:@"settings.png"];
background.position = ccp(screenSize.width/2, screenSize.height/2);
[self addChild:background];
}
[self addButtons];
}
return self;
}