ios - SpriteKit Label Node not appearing -


I have a strange problem. I'm using a label node in one of my projects last time when I Custom font was adding and since that moment my label nodes are not working properly. If I set a font on my label (such as for example under this text), the label will not appear on the screen only, but if the app works properly click on the button, then load the game It takes some time (I think the font is loading?):

  label1 = [SKLabelNode labelNodeWithFontNamed: @ "Arial"];  

But if I do not set any font on my label, the app simply crashes and I get a warning:

  * ** Exception exception to 'attach to add neil node', reason: 'Attempting to add zodiac node to parent: & lt; SKScene & gt; Name: '(empty)' frame: {{0,}, {568, 320}} ' 

I've read many posts here with people with problems with fonts. But I can not get any equal right now.

The code where the error appears (calling the node to see the stopwatch is calling the function):

  - (zero) addStopwatch {stopwatch.position = CGPointMake (self. Frame.size width / 16, self.frame.size.height); Stopwatch = [Skelebell node labeled NodeWith fonts nominated: @ "Aerial"]; Stopwatch.font size = 25; Stopwatch.fontColor = [UIColor whiteColor]; Stopwatch.text = [NSString stringWithFormat: @ "% s", "00:00"]; Stopwatch Name = @ "stopw" "; [Add child: stopwatch]; }  

Stopwatch spree has been declared in .h file:

  SKLabelNode * stopwatch;  

Try it ...

  - ( Zero) addStopwatch {SKLabelNode * stopwatch = [SKLabelNode labeled nodewith fonts named: @ "Aerial"]; // This view places the label node in the stopwatch. Low = cp pointmake (self frames .is with / 2, selffame size.height / 2); Stopwatch.font size = 25; Stopwatch.fontColor = [UIColor whiteColor]; Stopwatch.text = [NSString stringWithFormat: @ "% s", "00:00"]; Stopwatch Name = @ "stopw" "; [Add child: stopwatch]; }  EDIT:  The issue was not that the variable was global. The label was not visible because it was not in the view ( y = self.frame.size.height ). You can access labels in the name from other parts of your code by using 

  SKLabelNode * label = (SKLabelNode *) [child.7] by itself; Label.text = ...  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -