如何使用位图字体作为场景 2d 演员? [英] How to use Bitmap font as scene 2d actor?

查看:16
本文介绍了如何使用位图字体作为场景 2d 演员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 libgdx 框架开发游戏.如何在位图字体对象上实现 scene2d 动作?这样我就可以写一些文本,比如得分、消息和像场景 2d 演员一样运行动作.

I am developing a game using libgdx framework. How can i achieve scene2d action on bitmap font object ? so that i can write some text like score,message and run action like scene2d actor.

推荐答案

看看 Label 类,特别是采用 CharSequence 和 LabelStyle.初始化 LabelStyle 时,您可以提供 BitmapFont.

Take a look at the Label class, particularly the constructor that takes a CharSequence and a LabelStyle. When you initialize your LabelStyle you can supply a BitmapFont.

请注意,如果您想缩放或旋转标签,您需要将其包装在 Container 或将其添加到 Table 启用了 setTransform().(这会刷新 SpriteBatch,因此请明智地使用它.)

Please note, if you'd like to scale or rotate the label you'll need to wrap it in a Container or add it to Table with setTransform() enabled. (This flushes the SpriteBatch so use it wisely.)

这篇关于如何使用位图字体作为场景 2d 演员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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