真的没有办法给 SKLabelNode 设置样式吗? [英] Is there really no way to style SKLabelNode?

查看:24
本文介绍了真的没有办法给 SKLabelNode 设置样式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的没有办法给 SKLabelNode 设置样式吗?我的意思是改变字体和颜色.我知道我可以通过在第一个 SKLabelNode 后面创建第二个 SKLabelNode 来添加阴影之类的操作(已经很老套了).由于显而易见的原因,为我的字体创建图像也很糟糕.似乎很奇怪,您无法摆脱无聊的扁平文本.

Is there really no way to style SKLabelNode? I mean beyond changing the font, and the color. I know I can do something like adding a drop shadow by creating a second SKLabelNode behind the first (already sort've hacky).. Creating images for my font would be terrible too for obvious reasons. It seems odd theres nothing you can do to break out of boring flat text.

我的意思是..即使 spritekit 节点数也有很酷的渐变样式...这是怎么做到的?!

I mean.. even the spritekit node count has a cool gradient style... how is THAT done?!

好的,所以我在这里尝试重新创建渐变效果.我已经尝试了混合模式的每一种组合,以及多种颜色组合和 colorBlendFactor.

okay so here i am trying to recreate a gradient effect. I've tried every combination of blend mode, and multiple combinations of color, and colorBlendFactor.

阿尔法

相乘

添加

这里是代码

let testNode = SKLabelNode(text: "hey there")
testNode.fontSize = 30
testNode.color = SKColor.blueColor()
testNode.colorBlendFactor = 1
testNode.fontName = "Helvetica-Bold"
testNode.blendMode = SKBlendMode.Multiply
testNode.colorBlendFactor = 0.6
testNode.position = CGPoint(x: self.size.width/2, y: self.size.height/2)

self.addChild(testNode)

推荐答案

SKLabelNode 没有任何方法或属性可以让您实现渐变样式.正如评论中的链接所述,SpriteKit 确实有一个 SKBitmapFont 私有类,但这对您没有帮助.

There is no method or property of SKLabelNode that will enable you to achieve the gradient style. As noted in the link in the comments, SpriteKit does have a SKBitmapFont private class, but that's not going to help you.

您可以推出自己的解决方案或尝试字形设计器:https://71squared.com/glyphdesigner

You can either roll your own solution or try glyph designer : https://71squared.com/glyphdesigner

这篇关于真的没有办法给 SKLabelNode 设置样式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆