Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ScalableButton extends Image {
- public ScalableButton(TextureRegion t) {
- super(t);
- setOrigin(getWidth() / 2, getHeight() / 2);
- }
- public ScalableButton(Texture t) {
- super(t);
- setOrigin(getWidth() / 2, getHeight() / 2);
- }
- public boolean addMyListener(final RunnableAction clickAction) {
- EventListener clickListener = new InputListener() {
- @Override
- public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
- MusicHandler.playClick();
- addAction(Actions.scaleTo(0.8f, 0.8f, 0.03f, Interpolation.fade));
- return true;
- }
- @Override
- public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
- clearActions();
- addAction(Actions.scaleTo(1,1, 0.05f, Interpolation.fade));
- clickAction.run();
- super.touchUp(event, x, y, pointer, button);
- }
- };
- return super.addListener(clickListener);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement