Skip to content
Snippets Groups Projects
Commit 12317115 authored by Luboš Horáček's avatar Luboš Horáček
Browse files

#11 Game start button pressed state

parent d1a75ff2
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,9 @@ package cz.nic.tablexia.screen.gamemenu.pages;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.AlphaAction;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
......@@ -43,26 +45,17 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener {
// Start button
Texture start = getScreen().getTexture(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.STARTBUTTON));
Image startButton = new Image(start);
final Image startButton = new Image(start);
int startY = (int) (screen.getStage().getWidth() * 0.1);
int startHeight = (int) (screen.getStage().getHeight() * 0.25);
int startWidth = (int) (startHeight * ((float) start.getWidth() / (float) start.getHeight()));
int startX = (int) screen.getStage().getWidth() / 2 - startWidth / 2;
startButton.setSize(startWidth, startHeight);
startButton.setPosition(startX, startY);
addActor(startButton);
startButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
GameMenuPage.this.game.performAction(); // TODO launch game using events
}
});
// Start button
// Start button down
Texture startDown = getScreen().getTexture(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.STARTBUTTON_PRESSED));
Image startDownButton = new Image(start);
final Image startDownButton = new Image(startDown);
int startDownY = (int) (screen.getStage().getWidth() * 0.1);
int startDownHeight = (int) (screen.getStage().getHeight() * 0.25);
int startDownWidth = (int) (startDownHeight * ((float) startDown.getWidth() / (float) startDown.getHeight()));
......@@ -70,8 +63,33 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener {
startDownButton.setSize(startDownWidth, startDownHeight);
startDownButton.setPosition(startDownX, startDownY);
startDownButton.setVisible(false);
addActor(startDownButton);
addActor(startButton);
startButton.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
startButton.addAction(new AlphaAction());
startDownButton.setVisible(true);
return super.touchDown(event, x, y, pointer, button);
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
AlphaAction aa = new AlphaAction();
aa.setAlpha(1);
startButton.addAction(aa);
startDownButton.setVisible(false);
super.exit(event, x, y, pointer, toActor);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
GameMenuPage.this.game.performAction(); // TODO launch game using events
}
});
// Labels for diffuculty slider
Skin skin = new Skin(Gdx.files.internal("uiskin.json"));
......@@ -87,7 +105,6 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener {
addActor(medium);
addActor(hard);
// Difficulty bar
Texture diffBar = getScreen().getTexture(GameMenuAssets.DIFF_BAR);
Image diffBarImage = new Image(diffBar);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment