Java 在libgdx中更改图像

Java 在libgdx中更改图像,java,image,libgdx,textures,coordinates,Java,Image,Libgdx,Textures,Coordinates,所以我是libGDX的新手,我正在制作一个游戏,如果你按下图像,它会旋转,这意味着它会改变另一个图像。 但是我不知道该由谁来做,我想得到一些帮助 @Override public void create () { spriteBatch = new SpriteBatch(); font = new BitmapFont(true); camera = new OrthographicCamera(); texture = new Texture(Gdx.fi

所以我是libGDX的新手,我正在制作一个游戏,如果你按下图像,它会旋转,这意味着它会改变另一个图像。 但是我不知道该由谁来做,我想得到一些帮助

@Override
public void create () {

    spriteBatch = new SpriteBatch();
    font = new BitmapFont(true);
    camera = new OrthographicCamera();

    texture = new Texture(Gdx.files.internal("cable_side.png"));
    textureRegion = new TextureRegion(texture);
    textureRegion.flip(false, true);

    texture2 = new Texture(Gdx.files.internal("cable_l_1.png"));
    textureRegion2 = new TextureRegion(texture2);
    textureRegion2.flip(false, true);

    camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());


}

@Override
public void render () {


    Gdx.gl.glClearColor(0.4f, 0.4f, 0.4f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();
    spriteBatch.setProjectionMatrix(camera.combined);

    spriteBatch.begin();
    //font.draw(spriteBatch, "Hacking Time", 0, 0);
    spriteBatch.draw(textureRegion2, 0, 0);
    spriteBatch.draw(textureRegion, 32, 0);
    spriteBatch.draw(textureRegion, 64, 0);
    spriteBatch.draw(textureRegion, 96, 0);
    spriteBatch.draw(textureRegion, 128, 0);
    spriteBatch.draw(textureRegion, 160, 0);
    spriteBatch.draw(textureRegion, 192, 0);
    spriteBatch.draw(textureRegion, 224, 0);
    spriteBatch.end();
    }
这是我所拥有的,水平面上的第二个纹理区域,我想把它放在垂直面上,去掉前一个。
请帮忙

有很多方法可以满足您的需求,因此我建议您尝试阅读网站上的一些文档,并提供一些好的教程

但这不是你要的所以。。。实现您想要的最简单的方法之一是使用

操作步骤:

  • 创造一个场景
  • 将Gdx输入处理器与工作台关联
  • 创建一个皮肤来存储UI资源
  • 使用原始图像的up参数创建ImageButtonStyle,并选中要交换的图像
  • 使用以前的ImageButtonStyle创建ImageButtons
  • 在另一个用户中,DannyBit提供了一个代码剪,它通过一个textbutton做了类似的事情