FAQ Database Discussion Community


SKScene Pausing briefly When SKLabelNode's text is changed

swift,text,sprite-kit,sklabelnode
I am programming a small game using SpriteKit I added a SKLabelNode to my SKScene with the initial text of just "0". When I try and update the text of this SKLabel using: func updateScoreLabel() { scoreNumber++ scoreLabel.text = String(scoreNumber) } There is a short pause of the entire SKScene...

scoreLabel.text making game pause

swift,sprite-kit,sklabelnode
I'm setting a label let scoreLabel = SKLabelNode(fontNamed: "Edit Undo Line BRK") in a function func increaseScoreBy(increment: Int) { score += increment scoreLabel.text = "Score: 100" scoreLabel.removeAllActions() scoreLabel.runAction(scoreFlashAction) } and if I comment out the scoreLabel.text = "Score: 100" then it will run perfectly but the score obviously won't update....

How to cache or preload SKLabelNode font in spritekit

swift,sprite-kit,sklabelnode
I want to load the font once and use it for the other sklabel nodes let originalLabel: SKLabelNode = SKLabelNode(fontNamed: "fontName"); and later var labelNode = originalLabel; var labelNodeSecond = originalLabel; but that gives the following error Attemped to add a SKNode which already has a parent: SKLabelNode ...

Counting number of letters in a SKLabelNode

ios,swift,count,sklabelnode
I want to count the amount of letters in the text of a sklablenode, is this possible? So if: mySklabelnode = SKLabelNode() mySklabelnode.text = "testing" Than I want the result to be: 7 How can this be done?...

How do I make the text of one label node take up 2 lines?

xcode,string,swift,text,sklabelnode
I have this text below that is too long to fit on the screen when it runs. How can I make this 2 lines rather than one? myLabel.text = "The weather today is going to be partly cloudy with a chance of rain" ...

Programmatically Make a SKLabelNode Bold in swift

swift,fonts,sklabelnode
As the title states - I would like to make my SKLabelNodebold programmatically. How do I go about this?...

Setting background color for SKLabelNode?

ios,skspritenode,sklabelnode
I want to know is there a way to set background color for a SKLabelNode not font color. I'm looking for something like below mentioned code, which is available in ios apps. label.backgroundColor = [UIColor redColor]; ...

SKLabelNode will disappear but is still clickable

ios,swift,ios8,sprite-kit,sklabelnode
I am making a game using SpriteKit and Swift, running Xcode 6. I have an SKLabelNode, let's call it myLabelNode for this example. When I call myLabelNode.removeFromParent() it removes the node from the scene, as it should. The node count drops by 1, and it isn't visible anywhere on the...