开发者

objective-c : iphone programming, add label over a scene cocos2d

i use this code to add a label in my cocos2d game

CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64];

        CGSize size = [[CCDirector sharedDirector] winSize];

        label.position =  ccp( size.width /2 , size.height/2 );

        [self addChild: label z:1];

I'm making a tower defense game , so the user can scroll the scene. I want to have a label at the top showing the score. But when i do that it stick with 开发者_如何学JAVAthe scene. I want another layer over my game layer that show the score of the game. thats it


Create two CCLayer objects and add them to you scene. Use one as you're currently using the scene itself for adding your game world and moving it around. To the other add your label.

Typically you'll want to construct your scenes using several layers, for example one for the background, one for sprites, one for controls and one for scores and labels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜