【发布时间】:2015-01-18 18:48:34
【问题描述】:
我仍然遇到这个问题,我感觉我的头要炸了。可以说,我有这个用于绘制我创建的纹理的代码。
public MainMenuScreen(TheSpring game) {
this.game = game;
//camera for interface
guiCam = new OrthographicCamera(1020, 640);
guiCam.position.set(1020 / 2, 640/2, 0);
//buttons
play = new Button(10, 120, 400, 300, AssetLoader.play);
highscores = new Button(460, 10, 82, 102, AssetLoader.highscores);
sound = new Button(10, 10, 72, 72, AssetLoader.soundEnabled);
sound.AddTexture(AssetLoader.soundDisabled);
if (!Settings.soundEnabled)
sound.SwitchTexture();
help = new Button(120, 160, 80, 15, "Help", Color.WHITE);
//enable buttons
play.Enable(true);
highscores.Enable(true);
sound.Enable(true);
help.Enable(true);
//touchpoint for unproject
touchpoint = new Vector3();
}`
我为播放按钮创建的纹理也是 400x300。 问题是,当我尝试运行这个“应用程序”时,我的纹理是模糊的。 Button 是我的类,我正在使用它的绘图方法。
public void Draw(SpriteBatch batcher) {
if (enabled){
if (text != null) {
AssetLoader.ComicFont.setColor(clr);
AssetLoader.ComicFont.setScale(ScaleWidth, ScaleHeight);
AssetLoader.ComicFont.draw(batcher, text, x, y + height);
}
if (texture != null) {
batcher.draw(texture, x, y, width, height);
}
}
}
结果是这样的(请不要以我的绘画技巧来评判我,这是唯一的测试版本)
比如按钮的右边,也应该有黑线,线应该是直的。你能帮我么? :)
【问题讨论】:
-
也许这个答案与你的问题无关,但也许可以看看 path9 可以从这里开始github.com/libgdx/libgdx/wiki/Ninepatches也许你可以帮忙。
-
您好,感谢您的回复,我已经阅读了这篇文章,可能是这样,但我相信,每个试图在 libgdx 中使用 Spritebatch 和 orthographicCamera 绘制东西的人都没有使用这个 Ninepatch方法。我只是想绘制纹理,它保持它的比例,例如:纹理 140x140,我希望按钮 70x70 上面有这个纹理。结果与主文章中的打印屏幕相同。
标签: android graphics libgdx 2d