Skip to content Skip to sidebar Skip to footer

How Can I Add Action To A Texture Packer In Libgdx?

I'm trying to create eventListner on each image (playIcon,pauseIcon) but its not working using touchUp and touchDown here is my code: TextureAtlas buttonsPlayPause = new Textur

Solution 1:

If I understand correctly, you want this button to toggle between Play and Pause, calling either pause() or resume() based on current state.

The Button class already has a built-in internal InputListener, so all you need is a ChangeListener to react to button presses:

//pause/playActionbutton.addListener(new ChangeListener() {
    @Override
    public void changed (ChangeEvent event, Actor actor) {
        if (button.isChecked())
            resume();
        else
            play();
    }
});

Make sure you mark it final when you first declare it, so the listener can reference it:

//...finalTextButtonbutton=newTextButton("", textButtonStyle);
//...

Post a Comment for "How Can I Add Action To A Texture Packer In Libgdx?"