title: cocos2d loading scene failed
body: <p>I'm currently reading "Learn iPhone and iPad Cocos2D Game Development". i am not able to use a loading scene. i have HelloWorldScene.m, when i click it, it should show ScoreScene.m with a LoadingScene in between. and when i click it again, should go back. but it wont happen. the update method won't be executed(i added a CCLOG() there) here is my code: </p>
  
  <p>LoadingScene.m: </p>
  
  <pre><code>#import "LoadingScene.h"
  #import "ScoreScene.h"
  #import "HelloWorldScene.h"
  
  
  @implementation LoadingScene
  
  +(id) sceneWithTargetScene: (TargetScenes) targetScene {
      return [[[self alloc] initWithTargetScene: targetScene] autorelease];
   }
   -(id) initWithTargetScene: (TargetScenes) targetScene {
      if ((self = [super init])) {
          targetScene_ = targetScene;
  
          CCLabelTTF *label = [CCLabelTTF labelWithString:@"Loading..." fontName:@"Marker Felt" fontSize:64];
          [self addChild:label];
  
          CCLOG(@"this is inside initwithtargetscene");
          [self scheduleUpdate];
      }
      return self;
   }
  
  
  -(void) update: (ccTime) delta {
      CCLOG(@"this is inside update");
      [self unscheduleAllSelectors];
      switch (targetScene_) {
          case TargetSceneScoreScene:
              [[CCDirector sharedDirector] replaceScene:[ScoreScene scene]];
              break;
          case TargetSceneHelloWorld:
              [[CCDirector sharedDirector] replaceScene:[HelloWorld scene]];
              break;
  
  
          default:
              break;
      }
   }
  
   @end
  </code></pre>
  
  <p>ScoreScene.m:</p>
  
  <pre><code>#import "ScoreScene.h"
  #import "LoadingScene.h"
  
  
  @implementation ScoreScene
  
  
  +(id) scene
   {
      // 'scene' is an autorelease object.
      CCScene *scene = [CCScene node];
  
      // 'layer' is an autorelease object.
      ScoreScene *layer = [ScoreScene node];
  
      // add layer as a child to scene
      [scene addChild: layer];
  
      // return the scene
      return scene;
   }
  
  
  // on "init" you need to initialize your instance
   -(id) init
   {
      // always call "super" init
      // Apple recommends to re-assign "self" with the "super" return value
      if( (self=[super init] )) {
          for (int i = 0; i &lt; 4000000; i++) {
              int b = 343 / 247;
          }
  
          self.isTouchEnabled = YES;
          // create and initialize a Label
          CCLabelTTF *label = [CCLabelTTF labelWithString:@"this is a score" fontName:@"Marker Felt" fontSize:64];
  
          // ask director the the window size
          CGSize size = [[CCDirector sharedDirector] winSize];
  
          // position the label on the center of the screen
          label.position = ccp( size.width /2 , size.height/2 );
  
          // add the label as a child to this Layer
          [self addChild: label];
      }
      return self;
   }
  
  
  -(void) ccTouchesBegan: (NSSet *) touches withEvent: (UIEvent *) event {
      [LoadingScene sceneWithTargetScene: TargetSceneHelloWorld];
  
  
  }
  
  
  // on "dealloc" you need to release all your retained objects
   - (void) dealloc
   {
      // in case you have something to dealloc, do it in this method
      // in this particular example nothing needs to be released.
      // cocos2d will automatically release all the children (Label)
  
      // don't forget to call "super dealloc"
      [super dealloc];
   }
  
  
  @end
  </code></pre>
  
  <p>HelloWorldScene.m</p>
  
  <pre><code>    #import "HelloWorldScene.h"
   #import "LoadingScene.h"
   // HelloWorld implementation
   @implementation HelloWorld
  
  
  +(id) scene
   {
      // 'scene' is an autorelease object.
      CCScene *scene = [CCScene node];
  
      // 'layer' is an autorelease object.
      HelloWorld *layer = [HelloWorld node];
  
      // add layer as a child to scene
      [scene addChild: layer];
  
      // return the scene
      return scene;
   }
  
  
  // on "init" you need to initialize your instance
   -(id) init
   {
      // always call "super" init
      // Apple recommends to re-assign "self" with the "super" return value
      if( (self=[super init] )) {
          self.isTouchEnabled = YES;
          // create and initialize a Label
          CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64];
  
  
          // ask director the the window size
          CGSize size = [[CCDirector sharedDirector] winSize];
  
          // position the label on the center of the screen
          label.position = ccp( size.width /2 , size.height/2 );
  
          // add the label as a child to this Layer
          [self addChild: label];
      }
      return self;
   }
  
  
  
  
  - (void) ccTouchesBegan:(NSSet*) touches withEvent: (UIEvent *) event {
      CCLOG(@"this is inside touches began");
      [LoadingScene sceneWithTargetScene:TargetSceneScoreScene];
   }
  
   // on "dealloc" you need to release all your retained objects
   - (void) dealloc
   {
      // in case you have something to dealloc, do it in this method
      // in this particular example nothing needs to be released.
      // cocos2d will automatically release all the children (Label)
  
      // don't forget to call "super dealloc"
      [super dealloc];
   }
  
   @end
  </code></pre>