HelloWorld 層クラスで変数メンバーを使用します。
@interface HelloWorldLayer: CCLayer
{
int number;
}
@property(nonautomatic, assign) int number;
@end
@implementation HelloWorldLayer
@synthesize number;
+(CCScene *) sceneWithNumber:(int)inNumber
{
CCScene *scene = [CCScene node];
HelloWorldLayer *layer = [[[HelloWorldLayer alloc] initWithId:inNumber] autorelease];
[scene addChild: layer z:Z_SCENE tag:TAG_SCENE];
return scene;
}
-(id) initWithId:(int)inNumber
{
if( (self=[super init])) {
self.number= inNumber;
}
return self;
}
@end
シーンの代わりに sceneWithNumber を呼び出します
- (void) changeScenePlay
{
CCScene *testscene = [HelloWorldLayer sceneWithNumber:1];
[[CCDirector sharedDirector] replaceScene:testscene];
}