Hello I use Scene2d for menus.
My Problem is that sometimes the clickListener doesn't register the click on Android. At times I have to do the click up to 8 times until the Listener registers something.
On PC is everything fine, but on Android that is problematic. On some Smartphones or Tablets that problem coming up oftener than on others.
Strange: If I touch the button or checkbox I see that the background changes (button_up/button_down) even so the Listener doesn't work well. (I tried clicked, touchUp, touchDown and isPressed)
Here is some code:
stage = new Stage(new FillViewport(800, 800 * Gdx.graphics.getHeight() / Gdx.graphics.getWidth()));
Gdx.input.setInputProcessor(stage);
skin = Assets.manager.get(Assets.skin);
settingsTable = new Table(skin);
checkBoxMusic = new CheckBox("", skin);
checkBoxMusic.setChecked(Assets.isMusicEnabled());
checkBoxMusic.addListener(new ClickListener()
{
@Override
public void clicked(InputEvent event, float x, float y) // I tried touchUp, touchDown and isPressed too
{
Assets.setMusicEnabled(checkBoxMusic.isChecked());
System.out.println("Worked \(*o*)/");
}
}
checkBoxSound = new CheckBox("", skin); //Second Box
checkBoxSound.setChecked(Assets.isSoundEnabled());
checkBoxSound.addListener(new ClickListener()
{
@Override
public void clicked(InputEvent event, float x, float y)
{
Assets.setSoundEnabled(checkBoxSound.isChecked());
System.out.println("Worked \(*o*)/");
}
});
settingsTable.add("MUSIC", "gameOverStats").padTop(20f).align(Align.left);
settingsTable.add(checkBoxMusic).height(75f).width(75f).padTop(20f).padLeft(20f).align(Align.left);
settingsTable.row();
settingsTable.add("SOUNDS", "gameOverStats").padTop(20f).align(Align.left);
settingsTable.add(checkBoxSound).height(75f).width(75f).padLeft(20f).padTop(20f).align(Align.left);
settingsTable.row();
stage.addActor(settingsTable);
Thanks in advance!
0 comments:
Post a Comment