at the moment I'm coding a little app with SpriteKit, which works perfectly fine, but the only problem is an SKLabelNode, which I initialize with the following normal piece of code:
self.scoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Futura"];
self.scoreLabel.fontSize = 190.0f;
self.scoreLabel.color = [SKColor whiteColor];
self.scoreLabel.alpha = .2;
self.scoreLabel.text = @"00";
self.scoreLabel.position = CGPointMake(screenWidth/2,self.scoreLabel.frame.size.height/2);
[self addChild:self.scoreLabel];
There a many more things to initialize, but they doesn't affect anything. If I comment out the code above, the app loads in the usual time. With the SKLabelNode it delays the loading by few seconds...
Hope anyone can help me.
Actually, you don't need to preload the font for an SKLabelNode. The delay is caused by the fact that you're using the wrong font name. There's no "Futura" font on iOS - what you probably mean is "Futura-Medium". Replace "Futura" with "Futura-Medium", and you should see the load time drastically fall.
(You can still preload your fonts, but it's not necessary; lazy loading is pretty fast provided you use a correct font name.)
Be careful you aren't loading the entire font family. If I load "Chalkboard SE" it will take 4-6 seconds, and appear to work.
But if I load ChalkboardSE-Regular , it's virtually instantaneous ~100ms or less.
If you want to know more, I've got various links and timings on my humble blog. https://gilesey.wordpress.com/2015/01/14/ios-spritekit-font-loading-times-of-sklabelnodes/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With