Java LibGDX BitmapFont setScale method not working(Java LibGDX BitmapFont setScale 方法不起作用)
问题描述
我目前正在尝试缩放字体,但收到错误消息方法 setScale(float, float) 未定义 BitmapFont 类型"这是我收到错误的代码部分,特别是在第 2 行和第 4 行.
I am currently trying to scale a font but I am receiving the error "the method setScale(float, float) is undefined for the type BitmapFont" This is the code section where I am getting the error, specifically in lines 2 and 4.
font = new BitmapFont(Gdx.files.internal("text.fnt"));
font.setScale (.25f, -.25f);
shadow = new BitmapFont(Gdx.files.internal("shadow.fnt"));
shadow.setScale (.25f -.25f);
我在这里创建了变量
public static BitmapFont font;
public static BitmapFont shadow;
当我检查使用 setScale 函数的其他示例时,这似乎是使用的格式.关于为什么会发生这种情况的任何想法?
When I check other examples of using the setScale function, this seems to be the format used. Any ideas as to why this is occurring?
推荐答案
这个方法在 BitmapFont 类.
LibGDX 1.5.6(发布于2015 年 4 月),如 libgdx 团队博客文章中所述.您遵循的教程现在可能已经过时了.
An API change for the Bitmap* classes has been introduced with LibGDX 1.5.6 (released in April 2015) as explained in this libgdx team blog post. The tutorial you followed is probably now outdated.
长话短说,使用最新的 libgdx 版本,您应该可以做到:
Long story short, with the latest libgdx version, you should be able to do :
font.getData().setScale(.25f,.25f);
这篇关于Java LibGDX BitmapFont setScale 方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java LibGDX BitmapFont setScale 方法不起作用
基础教程推荐
- 将 double 转换为 Int,向下舍入 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
