Text SKLabelHorizontalAlignmentMode
有人能给我举个如何使用SKLabelHorizontalAlignmentMode的例子吗 以下是我如何定义我的标签:Text SKLabelHorizontalAlignmentMode,text,alignment,Text,Alignment,有人能给我举个如何使用SKLabelHorizontalAlignmentMode的例子吗 以下是我如何定义我的标签: RunningLevelLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster" ]; RunningLevelLabel.text = [NSString stringWithFormat:@"%i",numberOfBonusAlienPoints]; RunningLevelLabel.fontSize = 36
RunningLevelLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster" ];
RunningLevelLabel.text = [NSString stringWithFormat:@"%i",numberOfBonusAlienPoints];
RunningLevelLabel.fontSize = 36;
RunningLevelLabel.position = CGPointMake(-10,-50); // offscreen
RunningLevelLabel.fontColor = [SKColor grayColor];
[StartScreenWindow addChild:RunningLevelLabel];
谢谢,
里奇还没有得到答复,我只是自己在找这个。。。 参见第二行…垂直对齐的工作方式相同
SKLabelNode *RunningLevelLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster" ];
[RunningLevelLabel setHorizontalAlignmentMode:SKLabelHorizontalAlignmentModeCenter];
RunningLevelLabel.text = [NSString stringWithFormat:@"%i",numberOfBonusAlienPoints];
RunningLevelLabel.fontSize = 36;
RunningLevelLabel.position = CGPointMake(-10,-50); // offscreen
RunningLevelLabel.fontColor = [SKColor grayColor];
[StartScreenWindow addChild:RunningLevelLabel];
还没有回答,我只是自己在找这个。。。 参见第二行…垂直对齐的工作方式相同
SKLabelNode *RunningLevelLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster" ];
[RunningLevelLabel setHorizontalAlignmentMode:SKLabelHorizontalAlignmentModeCenter];
RunningLevelLabel.text = [NSString stringWithFormat:@"%i",numberOfBonusAlienPoints];
RunningLevelLabel.fontSize = 36;
RunningLevelLabel.position = CGPointMake(-10,-50); // offscreen
RunningLevelLabel.fontColor = [SKColor grayColor];
[StartScreenWindow addChild:RunningLevelLabel];
首先创建一个标签:
SKLabelNode *scoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
scoreLabel.text = @"00000";
scoreLabel.fontSize = 18;
scoreLabel.fontColor = [UIColor blackColor];
scoreLabel.position = CGPointMake(200, 300);
[self addChild: scoreLabel];
现在,您可以将标签与以下内容对齐:
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
或
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeRight;
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft;
或
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeRight;
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft;
该输出如下图所示:
继续编码…………:) 首先创建一个标签:
SKLabelNode *scoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
scoreLabel.text = @"00000";
scoreLabel.fontSize = 18;
scoreLabel.fontColor = [UIColor blackColor];
scoreLabel.position = CGPointMake(200, 300);
[self addChild: scoreLabel];
现在,您可以将标签与以下内容对齐:
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
或
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeRight;
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft;
或
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeRight;
scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft;
该输出如下图所示:
继续编码…………:)