我尝试在我的Android游戏中在libgdx上绘制简单文本,但它看起来很清晰.如何使文本在不同的分辨率下看起来流畅?我的代码:
private BitmapFont font;
font = new BitmapFont();
font.scale((ppuX*0.02f));
font.draw(spb, "Score:", width/2-ppuX*2f, height-0.5f*ppuY);
Run Code Online (Sandbox Code Playgroud) 我喜欢在我的应用程序中打印中文文本.
1.当我尝试这个时,屏幕将是空的.控制台没有错误.
创建方法:
FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal("fonts/DFLS1B.TTF"));
font = gen.generateFont(40, "?", false);
Run Code Online (Sandbox Code Playgroud)
渲染方法:
spriteBatch.setColor(1, 1, 1, 1);
spriteBatch.begin();
font.draw(spriteBatch, "?", 10, 100);
spriteBatch.end();
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,屏幕上会出现3个不同的汉字,但我不知道为什么这些字符在哪里画.asd和三个字符之间没有连接
创建方法:
FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal("fonts/DFLS1B.TTF"));
font = gen.generateFont(40);
Run Code Online (Sandbox Code Playgroud)
渲染方法:
spriteBatch.setColor(1, 1, 1, 1);
spriteBatch.begin();
font.draw(spriteBatch, "asd", 10, 100);
spriteBatch.end();
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在libgdx中正确绘制中文字符(我使用当前版本的libgdx)?例如:你好吗?- 你好吗? - 你好吗?
问候
编辑:这是一个完整的例子,它将在屏幕上显示预期的中文字符.我从这里下载了字体:http: //www.study-area.org/apt/firefly-font/
package com.mytest;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.scenes.scene2d.Stage;
public class ChineseFontTest implements ApplicationListener {
private Stage stage;
private …Run Code Online (Sandbox Code Playgroud) 我有libgdx显示Cyrillic的以下问题.我举个例子:
这工作:
System.out.println("??????");
Run Code Online (Sandbox Code Playgroud)
但它没有显示:
field = new TextField("??????", style);
Run Code Online (Sandbox Code Playgroud)
并尝试没有成功.
try {
mmm = new String(t.getBytes(), "UTF-8");
} catch (UnsupportedEncodingException e) {
// Will it ever be thrown?
}
field = new TextField(mmm, style);
Run Code Online (Sandbox Code Playgroud)
如果有人有解决方案,我会很高兴,很多人会很感激.