sklabelnode

Resize a SKLabelNode font size to fit?

拜拜、爱过 提交于 2019-11-30 14:19:42
I'm creating a label inside of sprite kit and setting an initial size. Since the app is to be localized, words may appear longer in other languages than their english version. Therefore how can I adjust the font size of the label to fit within a certain width which in this case is the button. myLabel = SKLabelNode(fontNamed: "Arial") myLabel.text = "Drag this label" myLabel.fontSize = 20 Edward I was able to solve this thanks to a comment by @InvalidMemory and the answer by @mike663. Basically you scale the label in proportion to the rectangle that contains the label. func

How to set font size of SKLabelNode to fit in fixed size (Swift)

让人想犯罪 __ 提交于 2019-11-30 04:48:36
I have a square (200X200) with a SKLabelNode in it. The label shows score and it my be reach a large number. I want fit the number in the square. How can i change text size (or Size) of a SKLabelNode to fit it in a fixed size. mike663 The size of the frame of the SKLabelNode can be compared against the given rectangle. If you scale the font in proportion to the sizes of the label's rectangle and the desired rectangle, you can determine the best font size to fill the space as much as possible. The last line conveniently moves the label to the center of the rectangle. (It may look off-center if

How to set font size of SKLabelNode to fit in fixed size (Swift)

三世轮回 提交于 2019-11-29 02:16:35
问题 I have a square (200X200) with a SKLabelNode in it. The label shows score and it my be reach a large number. I want fit the number in the square. How can i change text size (or Size) of a SKLabelNode to fit it in a fixed size. 回答1: The size of the frame of the SKLabelNode can be compared against the given rectangle. If you scale the font in proportion to the sizes of the label's rectangle and the desired rectangle, you can determine the best font size to fill the space as much as possible.

How to cache or preload SKLabelNode font?

℡╲_俬逩灬. 提交于 2019-11-27 05:29:41
I'm making a Sprite Kit app and in my scene I added an SKLabelNode. I noticed a pretty large lag-spike when I load the SKScene. After profiling the app I found it came from creating an SKLabelNode with a papyrus font(though the font doesn't matter). When I remove the label the scene starts up almost instantaneously, but with the label it takes an extra 1-3 seconds. I am pretty sure it's from loading the font as when I go back to the main menu and play the game again it starts up instantly again. Now is there a way to preload the font earlier so when the player selects the level there isn't a

How to cache or preload SKLabelNode font?

浪尽此生 提交于 2019-11-26 11:36:38
问题 I\'m making a Sprite Kit app and in my scene I added an SKLabelNode. I noticed a pretty large lag-spike when I load the SKScene. After profiling the app I found it came from creating an SKLabelNode with a papyrus font(though the font doesn\'t matter). When I remove the label the scene starts up almost instantaneously, but with the label it takes an extra 1-3 seconds. I am pretty sure it\'s from loading the font as when I go back to the main menu and play the game again it starts up instantly