1

So I have a scene in my game which displays the levels, like any other game with level, I subclass SKSpriteNode to make a custom level button and within this subclass i Add a SKLabelNode to display the level title ( level 1, level 2 .....). The problem know is that i have a lot of draw calls because each SKLabelNode renders as one texture instant of combining them into an atlas. I would like to know if someone can help me reduce these draw calls. I dont want to use Glyph designer because this game is going to be in a lot of different languages like Japanese Chinese and more. Any advice?

-(void)setText: (NSString *)text{

_label = [SKLabelNode labelNodeWithFontNamed:@"CooperBlack"];
_label.text = text;
_label.fontColor = [UIColor blackColor];
_label.fontSize = 11;
_label.zPosition = 2;
_label.verticalAlignmentMode = SKLabelVerticalAlignmentModeCenter;
_label.position = CGPointMake(0, 0);
[self addChild: _label];

}

1 Answers1

2

Depending on what you're doing and when, you could render out the contents of the labels into textures at runtime (pre-loading / caching), and then manipulate them in any ways you'd like.

SKLabelNode *theThingToBecomeATexture;
   //OR
SKSpriteNode *theThingToBecomeATexture;

SKTexture *theTexture = [theView textureFromNode:theThingToBecomeATexture];

But my follow up question or comment would be: I have a difficult time believing that you are running into performance problems by showing a few dozen label nodes on the screen. I can understand you hitting a load spike if you are trying to alloc and init a number of them all at the same time, in which case, I would preload them, or alloc them not on the main thread.

Cooper Buckingham
  • 2,503
  • 2
  • 15
  • 23
  • i dont have a huge performance problem. The main problem is that sometimes it forgets to render some of the labels. so sometimes it doesnt show some labels. – David Villarreal Jul 30 '14 at 00:21
  • That sounds like a logic issue rather than a performance issue, which is what draw calls would normally be associated with. – Cooper Buckingham Jul 30 '14 at 13:59