The Actor's boundaries are not centered at the ButtonText but I used the setBounds() method. The higher the Y position is, the less centered is the boundary. The weird thing is that i only created and added to the Stage one button but the screen shows two. When i click the top button, the bottom one is the one highlighted.
How can i fix that?
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
public class MyGame extends Game {
Stage stage;
@Override
public void create() {
stage=new Stage();
FileHandle skinFile = new FileHandle("data/resources/uiskin/uiskin.json");
Skin skin = new Skin(skinFile);
TextButton sas=new TextButton("dd",skin);
sas.setBounds(0, 500, 100, 100);
stage.addActor(sas);
Gdx.input.setInputProcessor(stage);
}@Override
public void dispose() {
super.dispose();
}
@Override
public void render() {
super.render();
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
@Override
public void resize(int width, int height) {
super.resize(width, height);
}
@Override
public void pause() {
super.pause();
}
@Override
public void resume() {
super.resume();
}
}
No comments:
Post a Comment