-1

I'm new to this sprite kit.I want to display the text randomly.Actually i'm having 3 words i need to display those 3 words randomly using SKLabelNode.I don't know how to implement this.Let us take Air,Land and sea these 3 words should be randomly displayed .please help me regarding this issue.Thanks in Advance.

 SKLabelNode  * scoreLbl =  [SKLabelNode labelNodeWithFontNamed:@"Futura-Bold"];
[scoreLbl setText:@"Sea"];



[scoreLbl setFontSize:50*_distanceMultiPlayer];


[scoreLbl setPosition:CGPointMake(scoreLbl.position.x, scoreLbl.position.y + (10 *_distanceMultiPlayer) )];
scoreLbl.fontColor=[UIColor blueColor];
[scoreLbl setFontSize:12.0];
[self     addChild:scoreLbl];
[scoreLbl setName:@"scoreLabel"];
App Developer
  • 419
  • 1
  • 3
  • 16

2 Answers2

2
scoreLbl.text = @[@"Air", @"Land", @"Sea"][arc4random() % 3];
Droppy
  • 9,691
  • 1
  • 20
  • 27
1

I Got the answer.I have given my code as scoreLbl.text= @[@"Air", @"Land", @"Sea"][arc4random() % 3];

Thank guys for helping me

App Developer
  • 419
  • 1
  • 3
  • 16