libgdx and android application. Image as background(libgdx 和安卓应用程序.图像作为背景)
问题描述
我是新手,刚开始使用 libgdx.我想知道如何在我的游戏中将分辨率为 960x640 的 image.png 作为背景?这个有可能?感谢您的建议和宽容.也许你有一个简单的教程?这是我的渲染类:
I am new and I just start my journey with libgdx. I would like to know how I can do image.png in resolution 960x640 as background in my game? This is possible? Thx for advices and forbearance. Maybe you hava a simply tutorial? This is my render class:
public void render() {
texture = new Texture(Gdx.files.internal("E:/background.png"));
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(texture, 0, 0);
batch.end();
}
第二个问题.我需要插入两个活动图像,活动意味着当我单击该图像时,下一个图像会显示在屏幕上.我想在点击该图片时执行操作.
Second question. I need to insert two active images, active means when I click on that image, the next image show me on the screen. I want to implement action when I click on that picture.
推荐答案
在你的 create() 方法中,创建一个引用你的 image.png 的新纹理,然后使用你现有的 SpriteBatch 在 render() 循环中渲染它.在您调用 GL.clear() 之后,立即执行 batch.draw(backgroundTexture, 0. 0) 并确保您的相机处于 OrthographicProjection 模式.
In your create() method, create a new Texture referencing your image.png, and then use your existing SpriteBatch to render it in the render() loop. Immediately after your GL.clear() call, go your batch.draw(backgroundTexture, 0. 0) and make sure you're in OrthographicProjection mode for your camera.
这篇关于libgdx 和安卓应用程序.图像作为背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:libgdx 和安卓应用程序.图像作为背景


基础教程推荐
- 大摇大摆的枚举 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01