【发布时间】:2017-02-16 19:08:57
【问题描述】:
我是 Libgdx 的新手,我正在开发一款菜单屏幕有声音按钮的游戏。默认情况下它是打开的,我想在触摸时将其更改为关闭 png 的其他声音意味着我想更改该精灵的纹理,但下面的代码似乎不起作用。
@Override
public void show(){
s = new Sprite(new Texture(Gdx.files.internal("soundon.png")));
}
@Override
public void render(float delta) {
camera.update();
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
batch.begin();
s.draw(batch);
s.setBounds(w-w/7,h*asp-w/7, w/10,w/10);
batch.end();
}
public boolean touchUp (int x, int y, int pointer, int button) {
if(s.getBoundingRectangle().contains(x,y)){
s.setTexture(new Texture(Gdx.files.internal("soundoff.png"));
}
return true;
}
【问题讨论】: