package com.pietv8x.graphics.buttons;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.pietv8x.game2048.TwentyFourtyGame;
import com.pietv8x.graphics.screens.ScreenHandler;
import com.pietv8x.utils.handlers.AssetHandler;
import com.pietv8x.utils.states.ContinuingState;

/**
 * A button to continue playing after having made a 2048 value tile. Extends the
 * TextButton class from the GDX library.
 */
public class ContinueButton extends TextButton {
	/** Constructs a new ContinueButton. */
	public ContinueButton() {
		super("Continue!", AssetHandler.getSkin());
		this.setX(480 / 2 - getPrefWidth() / 2);
		this.setY(this.getPrefHeight() + 2 * Gdx.graphics.getWidth() / 40);

		this.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent event, float x, float y) {
				ScreenHandler.restart();
				TwentyFourtyGame.setState(ContinuingState.getInstance());
			}
		});
	}
}
