概述或阴影字体的最佳方法是什么? [英] What would be the best approach for outlining or dropshadowing a font?

查看:28
本文介绍了概述或阴影字体的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有在 Sprite Kit 中找到任何对阴影或字体轮廓的支持.对于投影,我猜我可以创建第二个 SKLabelNode 并将其偏移到另一个后面.

I'm not finding any support for dropshadow or outline of a font in Sprite Kit. For the dropshadow, I'm guessing I could create a second SKLabelNode and offset it behind the other.

有没有什么方法可以利用 SKEffectNode 来绘制轮廓或阴影?可能使 SKLabelNode 成为 SKEffectNode 的子节点?

Is there some way that I could utilize a SKEffectNode for the outline or dropshadow ? Possibly make the SKLabelNode a child of the SKEffectNode ?

更新:

我能够使用第一个后​​面的第二个 SKLabelNode 获得一个不错的阴影,即黑色和偏移.仍然对其他潜在选择感兴趣,但这似乎效果很好.

I was able to get a decent dropshadow using a second SKLabelNode behind the first, that is black and offset. Still interested in other potential options, but that seems to work well.

推荐答案

这很可能是您正在做的事情,但它有效且简单.

This is most likely what you are doing, but it works and is simple.

- (SKLabelNode *) makeDropShadowString:(NSString *) myString
{
    int offSetX = 3;
    int offSetY = 3;

    SKLabelNode *completedString = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
    completedString.fontSize = 30.0f;
    completedString.fontColor = [SKColor yellowColor];
    completedString.text = myString;


    SKLabelNode *dropShadow = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
    dropShadow.fontSize = 30.0f;
    dropShadow.fontColor = [SKColor blackColor];
    dropShadow.text = myString;
    dropShadow.zPosition = completedString.zPosition - 1;
    dropShadow.position = CGPointMake(dropShadow.position.x - offSetX, dropShadow.position.y - offSetY);

    [completedString addChild:dropShadow];

    return completedString;
}

也将尝试制作轮廓...但我感觉它会更加棘手...必须有一种使用位图字体的方法.. ???bmGlyph ...

Will try and make outline one as well... but I have a feeling it'll be more tricky... there must be a way to use bitmap fonts .. ??? bmGlyph ...

这篇关于概述或阴影字体的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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