Java LibGDX BitmapFont setScale方法不起作用 [英] Java LibGDX BitmapFont setScale method not working

查看:159
本文介绍了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 class。

This method doesn't exist anymore in the BitmapFont class.

LibGDX 1.5.6(2015年4月发布)引入了Bitmap *类的 API更改 )如本 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方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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