在libGDX更新到最新版本后,font.setColor方法不起作用 [英] font.setColor method not working after libGDX update to latest version

查看:238
本文介绍了在libGDX更新到最新版本后,font.setColor方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在libGDX有一个3 - 4年的游戏项目。现在我决定更新它,并从Eclipse转移到Android工作室。所以,我安装了A.S.下载并安装新鲜的libGDX项目。然后添加我的旧源文件和资产。一切顺利,游戏运行有一些小改动。除了font.setColor不再工作 - 屏幕上的文本是黑色的。透明度也不行。所以,我的字体是用Hiero生成的,而且是白色的(我在其他一些问题上看到,它必须是白色的)。

p>

  font = new BitmapFont(Gdx.files.internal(fonts / bundy.fnt),
Gdx.files。 internal(fonts / bundy_0.png),false);
...

font.setColor(0.2f,0.5f,0.2f,1.0f);
font.draw(game.batch,MAP,835,580);

提及我使用了

  import com.badlogic.gdx.graphics.GL10; 

但现在我搬到了

  import com.badlogic.gdx.graphics.GL20; 

因为不再支持GL10。



<此外,现在我正在使用 GlyphLayout 类来获取文本边界。我没有看到任何可能对字体颜色有任何影响的其他变化。



任何想法为什么setColor不工作?是否还有一些新的步骤,我必须做的?

解决方案

确定找到了!



所以,旧的字体图像文件,在旧的libGDX上运行良好,但在新的不工作是在8位PNG灰度。现在我用最新的Hiero生成新的字体,它是在8位PNG,但在彩色模式下,用白色字母和透明背景和那么效果很好。



所以这是关于图像格式。



PS透明度仍然无法正常工作,但我可以忍受这一点。


I have some 3-4 years old game project in libGDX. Now I decided to update it and to move from Eclipse to Android studio. So, I installed A.S. downloaded and installed fresh libGDX project. Then added my old source files and assets. All went well, with some minor changes game runs. Except font.setColor is not working any more - text on screen is black. Transparency is not working neither. That worked well before.

So, my font is generated with Hiero, and it's white (I saw that in some other questions here that it must be white).

font = new BitmapFont(Gdx.files.internal("fonts/bundy.fnt"),
                Gdx.files.internal("fonts/bundy_0.png"), false);
...

font.setColor(0.2f, 0.5f, 0.2f, 1.0f);
font.draw(game.batch, "MAP" , 835,580);

To mention that I used

import com.badlogic.gdx.graphics.GL10;

but now I moved to

import com.badlogic.gdx.graphics.GL20;

since GL10 is not supported any more.

Also, now I'm using GlyphLayout class to get text boundaries. I don't see any other change that could have any influence to font color.

Any idea why setColor is not working? Is there some new step added meanwhile that I have to do?

解决方案

Ok found it!

So, old font image file, that was working well on old libGDX, but won't work in new was in 8 bit png grayscale. Letters were white and background was black.

Now I generated new font with latest Hiero and it was in 8bit png, but in color mode, with white letters and TRANSPARENT background and that works well.

So it was about image format.

P.S. Transparency is still not working...but I can live with that.

这篇关于在libGDX更新到最新版本后,font.setColor方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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