0
我使用cocos2d的遊戲教程從http://www.raywenderlich.com/25736/how-to-make-a-simple-iphone-game-with-cocos2d-2-x-tutorial後我添加了比分scorelabel,得分增加,但以前的分數是沒有得到刪除,新的分數較早得分的標籤顯示得分重疊
代碼上面添加得到:
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCLabelTTF * label1 = [CCLabelTTF labelWithString:@"_monsterdestroyed" fontName:@"Arial" fontSize:32];
score=score + 2;
[label1 setString:[NSString stringWithFormat:@"%d",score]];
label1.color = ccc3(0,0,0);
label1.position = ccp(winSize.width/2, winSize.height/2);
[self addChild:label1];