libgdx和Android应用程序。图片作为背景 [英] libgdx and android application. Image as background

查看:114
本文介绍了libgdx和Android应用程序。图片作为背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的,我刚开始我的旅程libgdx。我想知道我可以在分辨率达到了960x640做image.png作为背景在我的游戏?这是可能的吗? THX的建议和忍。也许你哈瓦一个简单的教程? 这是我的呈现类:

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.

推荐答案

在你创建()方法,创建一个新的纹理引用您的image.png,然后使用现有的SpriteBatch以使其在渲染()循环。马上你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和Android应用程序。图片作为背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆