I'm developing a game with Xcode using Cocos2d 2.0fc0 and I've gotten hung up. I'd like to set a BOOL property when loading the CCLayer/CCScene Game class to define whether second player is local or a remote (Game Center) player. Problem is I'm not exactly sure how to do that under the circumstances. Here is what I've got so far:
@interface RemoteGame : CCLayer <GameCenterControllerDelegate> {
BOOL isRemote;
}
@property (assign, readwrite) BOOL isRemote;
+(CCScene *) sceneIsRemote: (BOOL) b;
-
@implementation RemoteGame
@synthesize isRemote;
+(CCScene *) sceneIsRemote: (BOOL) b {
CCScene *scene = [CCScene node];
RemoteGame *layer = [RemoteGame node];
layer.isRemote = b;
[scene addChild: layer];
return scene;
}
-(id) init {
if((self=[super init])) {
if (isRemote) {
[GameCenterController sharedController].delegate = self;
}
}
}
Then I'm loading the scene like so:
CCScene *trans = [CCTransitionFlipX transitionWithDuration:.75 scene:[RemoteGame sceneIsRemote: YES]];
[[CCDirector sharedDirector] replaceScene:trans];
[self presentGCTurnViewController];
The scene loads fine, but the BOOL is not getting set correctly.