www.pudn.com > Simple-shooting-game.zip > LoadingScene.m, change:2012-02-07,size:1666b


//
//  LoadingScene.m
//  Cocos2DGame
//
//  Created by Yang QianFeng on 11-12-29.
//  Copyright (c) 2011年 千锋3G www.mobiletrain.org. All rights reserved.
//

#import "LoadingScene.h"
#import "GameScene.h"


@implementation LoadingScene
@synthesize progressBar = _progressBar;


+(id) scene
{
	CCScene* sc = [CCScene node];
	
	LoadingScene* ss = [LoadingScene node];
	
	[sc addChild:ss];
	
	return sc;
}

-(id) init {
	if ((self = [super init])) {
        CGSize winSize = [[CCDirector sharedDirector] winSize];
        CCSprite *bgSprite = [CCSprite spriteWithFile:@"progressbar1.png"];
        bgSprite.anchorPoint = CGPointMake(0.0f, 0.0f);
        CGFloat startX = (winSize.width-bgSprite.contentSize.width)/2.0;
        CGFloat startY = 100;
        
        bgSprite.position = CGPointMake(startX, startY);
        [self addChild:bgSprite];
        
        self.progressBar = [CCSprite spriteWithFile:@"progressbar2.png"];
        _progressBar.anchorPoint = CGPointMake(0.0f, 0.0f);
        
        _progressBarSize = [_progressBar contentSize];
        _startPoint = CGPointMake(startX, startY);
        _progressBar.position = _startPoint;
        _progressBar.scaleX = 0.0f;
        [self addChild:_progressBar];
        
        [self schedule:@selector(update) interval:0.1f];
	}
	return self;
}
- (void) update
{
    CGFloat scalex = [_progressBar scaleX]+0.2;
    [_progressBar setScaleX:scalex];
    if (scalex >= 1.0f) {

        [self unschedule:@selector(update)];
        CCScene * sc = [GameScene scene];

        [[CCDirector sharedDirector] replaceScene:sc];
    }
}

-(void) dealloc
{
    self.progressBar = nil;
	[super dealloc];
}
@end