// Semi-Singleton: you can access MultiLayerScene only as long as it is the active scene.
static MultiLayerScene* multiLayerSceneInstance;

+(MultiLayerScene*) sharedLayer
{
    NSAssert(multiLayerSceneInstance != nil, @"MultiLayerScene not available!");
    return multiLayerSceneInstance;
}

-(void) dealloc
{
    multiLayerSceneInstance = nil;

    // don't forget to call "super dealloc"
    [super dealloc];
}

与普通的单例不同的是,它不能被初始化

 

使用单例的方法

 

MultiSceneLayer *sceneLayer=[MultiSceneLayer shareLayer];

 

posted on 2011-12-10 09:12  晃晃悠悠  阅读(231)  评论(0)    收藏  举报