0
我有一個簡單的CCLayer
子類與圓形作爲背景圖像。我還有一個CCLabelTTF
作爲子節點。 如何將標籤的文字置於背景圖片上?居中在CCSprite CCLabelTTF
這是我有:
// in MyCCLayer's init method
CCSprite *backgroundImage = [CCSprite spriteWithFile:@"circle.png"];
[self addChild:backgroundImage];
self.contentSize = backgroundImage.contentSize;
CCLabelTTF *label = [CCLabelTTF labelWithString:@"0"
dimensions:self.contentSize
alignment:UITextAlignmentCenter
fontName:@"Arial"
fontSize:32];
[self addChild:label];
我試圖改變anchorPoint和位置的標籤上,但我不能只是將背景圖像上居中的文字。文字總是偏移。無論字體大小如何,我都希望讓文字居中。