How to change the alpha of a bitmap font in libgdx

扶醉桌前 提交于 2019-12-30 09:32:23

问题


I want to make a message box that fade when you accept but I don't know how to change the alpha of a font,

here is how I do my font:

white = new BitmapFont(Gdx.files.internal("data/font/whitefont.fnt"),false);
white.setUseIntegerPositions(false);
white.setScale(0.025f);
white.draw(batchHUD, message.nom+":", 1000*0.1f+(1000*0.8f*0.3f), 625*0.1f+(1000*0.8f*0.625f*0.5f*0.1f)+1000*0.2f);

Can anyone help me ? :) I'm sorry for my english, it's not my native language.


回答1:


white.setColor(1, 1, 1, <alpha>);

This will change the alpha of the font for all following draws. So you would probably want to set it to full opaque again once you draw that message.

white.setColor(1, 1, 1, 1);


来源:https://stackoverflow.com/questions/20100529/how-to-change-the-alpha-of-a-bitmap-font-in-libgdx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!