title: How to add text on moving sprites in Cocos2D?
body: <p>This is my first game in Cocos2D. I am using Cocos2D 1.0.1. I want to add text on moving sprites which should be center aligned. I've taken a CCLabelTTF with a text on it but I cannot make it center aligned. This is what I've done so far:-</p>
  
  <p>-(void)addTarget {</p>
  
  <pre><code>int enType= arc4random() % 11;
  
  CCSprite *target=[CCSprite spriteWithFile:[NSString stringWithFormat:@"balloon%d.png",enType] rect:CGRectMake(0, 0, 100, 119)];
  
  label = [[CCLabelTTF alloc] initWithString:@"H!" dimensions:CGSizeMake([target contentSize].width, [target contentSize].height)  
                                   alignment:UITextAlignmentCenter fontName:@"verdana" fontSize:20.0f];
  
   label.color = ccc3(60,60,60);
  
  [target addChild:label z: 10];
  </code></pre>
  
  <p>// Create the actions</p>
  
  <pre><code>id actionMove = [CCMoveTo actionWithDuration:rangeDuration position:ccp(actualX,winSize.height+target.contentSize.height)];
  
  [target runAction:[CCSequence actions:actionMove, nil]];
  
  //[label setPosition:target.position];
  
  
  // Add to targets array 
  
  [targets addObject:target];
  </code></pre>
  
  <p>}   </p>
  
  <p>Somewhere I've read that adding "[label setPosition:target.position];" in action of sprite will make it center aligned but in vain.</p>