sklabelnode

Align multiple SKLabelNodes by Baseline

╄→尐↘猪︶ㄣ 提交于 2019-12-11 01:11:10
问题 I have a collection of SKLabelNodes . Each node represents a letter of a word. Each node is the child of an SKSpriteNode . The spriteNode has an explicit hight set on it (the hight returned by [text sizeWithAttributes:@{NSFontAttributeName : font}]; ), and has the same width as the labelNode . The labelNode is then centred inside the spriteNode , and has verticalAlignmentMode = SKLabelVerticalAlignmentModeBaseline . At a later stage, I will need to set a background image on each letter (which

SKLabelNode without transparent background

故事扮演 提交于 2019-12-10 23:28:25
问题 Hi I'm using a custom font on a SKLabelNode. I'm able to set the font colour but ok, but the inner parts of the text, are transparent. Is there a way i can set this colour to white for example? my code so far scoreLabel.fontColor = [SKColor colorWithRed:0.0 green:0 blue:0.0 alpha:1.0]; 回答1: The easiest way I found is to combine an SKSpriteNode and a SKLabelNode. You simply add the SKLabelNode as a child to the SKSpriteNode. SKLabelNode *label = [[SKLabelNode alloc]initWithFontNamed:@"Courier"

SKLabelNode removes leading and trailing spaces - How can I stop that?

喜你入骨 提交于 2019-12-08 22:08:18
问题 I wanted to create an SKLabelNode, which is supposed to have always the same length (for a word guessing game). Unfortunately SKLabelNode decides to always cut off any leading and trailing spaces. This behavior is not described in the documentation. How can I avoid/switch off that behavior? 回答1: If you simply want labels to line up so that they are right aligned, then use a right alignment mode. myLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeRight; However, if you are trying

SKLabelNode text with two different fonts and colour. How is this possible?

谁说胖子不能爱 提交于 2019-12-08 02:05:16
问题 I have an SKLabelNode which is set up to show the Score Variable followed by the Highscore variable scoreLabel.text = "\(score)/\(classicHScoreInt)" Now, everything shows fine but i would like the classicHScoreInt to be a smaller font and maybe a different colour. How is this possible? classicHScoreInt is (as stated) an integer and so is score 回答1: You cannot set two fonts to the same SKLabelNode instance. Instead you can write subclasses to create a custom node which contains multiple

Making SKLabelNode as a crop node of SKShapeNode

对着背影说爱祢 提交于 2019-12-08 00:12:14
问题 Can't find in web, how to make SKLabelNode cropping SKShapeNode. When i colorize the background, my goal is colorize the label too with the same method, so both of them have to colorize simultaneously. But can't imagine how to crop SKShapeNode with this label. Help me please! 回答1: But can't imagine how to crop SKShapeNode with this label. If I understand you correctly, you can set SKLabelNode as a mask of a SKCropNode, like this: override func didMoveToView(view: SKView) { backgroundColor =

SKAction.colorizeWithColor makes SKLabelNode disappear

眉间皱痕 提交于 2019-12-07 22:51:31
问题 I'm using SKLabelNode. I'm creating it and add it to my scene as a child and it displays with no problem, but when I try to change it's color (not fontColor) with the colorizeWithColor() method the label fades out. Here is the line with the problem: myLabel.runAction(SKAction.colorizeWithColor(SKColor.blueColor(), colorBlendFactor: 1.0, duration: duration)) I printed to the console the myLabel.color property after the completion of this action and here is what I get: Optional

Multi-line label in swift 2 sprite-kit?

蹲街弑〆低调 提交于 2019-12-06 18:44:52
问题 I need to be able to make a multi-line label in swift 2 sprite-kit for a game. The text needs to wrap around rather than go off of the screen. Bellow is what I have but I do not know what to do import Foundation import UIKit import SpriteKit class JDQuotes: SKLabelNode { var number = 0 init(num: Int) { super.init() if num == 1 { text = "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. laborum.\"" } } required init?

SKLabelNode text with two different fonts and colour. How is this possible?

本小妞迷上赌 提交于 2019-12-06 09:40:30
I have an SKLabelNode which is set up to show the Score Variable followed by the Highscore variable scoreLabel.text = "\(score)/\(classicHScoreInt)" Now, everything shows fine but i would like the classicHScoreInt to be a smaller font and maybe a different colour. How is this possible? classicHScoreInt is (as stated) an integer and so is score You cannot set two fonts to the same SKLabelNode instance. Instead you can write subclasses to create a custom node which contains multiple SKLabelNodes with different font sizes. For example, Your scoreLabel can be an instance of the following class.

Centre a SKLabelNode on a SKSpriteNode

落爺英雄遲暮 提交于 2019-12-05 15:21:02
问题 I have an SKLabelNode that is the child of a SKSpriteNode because I'm trying to create a Button class to create buttons in an easier way. I've tried a couple of things using the anchor point of the SKSpriteNode, but I don't quite understand exactly what is going on. How do I centre the label onto the sprite (it's parent node)? 回答1: I realized how to solve this...here's what i did. Keep in mind that I have a class called Button that is a subclass of SKSpriteNode. In the Button.m class I have

Add custom “number” images to SKLabelNode in as a Score in SpriteKit with Swift

风流意气都作罢 提交于 2019-12-04 16:53:09
I basically want to add custom font numbers (with images) in Singles and add them for my score in my game with SpriteKit. This is the font image style They are numbers from 0 to 9 I have been trying to figure this out for a while. I'm not sure if you can add it to SKLabelNode or if you would have to make it in a class. Mobile Ben SKLabelNode would not allow for bitmap fonts. If your custom font was TTF, you would be able to use the custom font with SKLabelNode . An explanation how is here: SKlabelNode custom font In your case, since you want to use bitmap fonts, you will need to create a class