We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Button; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.viewport.StretchViewport;
public class MyGame3 extends ApplicationAdapter {
//图片控件 Stage stage; Button button; Texture up; Texture drown; TextureRegionDrawable u; TextureRegionDrawable d; @Override public void create() { up = new Texture(Gdx.files.internal("anniu/QQ20240820-103716.png")); drown = new Texture(Gdx.files.internal("anniu/QQ20240820-103704.png")); u = new TextureRegionDrawable(up); d = new TextureRegionDrawable(drown); // 创建ButtonStyle Button.ButtonStyle style = new Button.ButtonStyle(); style.up = u; style.down = d; // 创建按钮 button = new Button(style); stage = new Stage(new StretchViewport(800, 480)); stage.addActor(button); button.setPosition(100, 100); } @Override public void render() { Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(); stage.draw(); } @Override public void dispose() { stage.dispose(); }
} 点击图片按钮没有变化不知道为什么(图片文件路径没有问题)
The text was updated successfully, but these errors were encountered:
Gdx.input.setInputProcessor(stage);将对应演员所在的舞台作为参数传递
Sorry, something went wrong.
No branches or pull requests
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.viewport.StretchViewport;
public class MyGame3 extends ApplicationAdapter {
}
点击图片按钮没有变化不知道为什么(图片文件路径没有问题)
The text was updated successfully, but these errors were encountered: