问题描述
我是新手,刚开始使用 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 和安卓应用程序.图像作为背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)