Added buttons in code & tweaked GUI interactive nodes.

This commit is contained in:
Jeasonfire 2015-05-16 21:44:29 +03:00
parent 27457bc102
commit bf44ad78c9
6 changed files with 18 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -3,7 +3,6 @@ package com.saltosion.gladiator.gui.creators;
import com.saltosion.gladiator.gui.nodes.ButtonNode;
import com.saltosion.gladiator.gui.nodes.TextNode;
import com.saltosion.gladiator.util.AppUtil;
import com.saltosion.gladiator.util.Log;
import com.saltosion.gladiator.util.Name;
import com.saltosion.gladiator.util.SpriteLoader;
@ -17,8 +16,8 @@ public class MainMenuGUICreator implements GUICreator {
titleText.setPosition(0.23f, 0.8f);
AppUtil.guiManager.getRootNode().addChild(titleText);
ButtonNode playButton = new ButtonNode("Play Button", SpriteLoader.loadSprite(Name.BUTTON_PLAY_HOVER),
SpriteLoader.loadSprite(Name.BUTTON_PLAY)) {
ButtonNode playButton = new ButtonNode("Play Button", SpriteLoader.loadSprite(Name.BUTTON_BIG),
SpriteLoader.loadSprite(Name.BUTTON_BIG_HOVER)) {
@Override
public void pressed(int x, int y, int mouseButton) {
}
@ -29,6 +28,9 @@ public class MainMenuGUICreator implements GUICreator {
}
};
playButton.setPosition(0.5f, 0.5f);
TextNode playButtonText = new TextNode("Play Button Text", "Play");
playButtonText.setPosition(-0.0325f, 0.0175f);
playButton.addChild(playButtonText);
AppUtil.guiManager.getRootNode().addChild(playButton);
}

View File

@ -104,7 +104,7 @@ public class InputHandler implements InputProcessor {
float x1 = node.getPosition().x + width / 2;
float y0 = node.getPosition().y - height / 2;
float y1 = node.getPosition().y + height / 2;
x += 0.01f;
x += 0.0065f;
if (node instanceof InteractiveProperty) {
InteractiveProperty interactiveNode = (InteractiveProperty) node;

View File

@ -11,8 +11,12 @@ public class Name {
public static final String WALLIMG = "WALLIMG";
public static final String SWINGHITBOXIMG = "SWINGHITBOXIMG";
public static final String BUTTON_PLAY = "BUTTON_PLAY";
public static final String BUTTON_PLAY_HOVER = "BUTTON_PLAY_HOVER";
public static final String BUTTON_HUGE = "BUTTON_HUGE";
public static final String BUTTON_HUGE_HOVER = "BUTTON_HUGE_HOVER";
public static final String BUTTON_BIG = "BUTTON_BIG";
public static final String BUTTON_BIG_HOVER = "BUTTON_BIG_HOVER";
public static final String BUTTON_SMALL = "BUTTON_SMALL";
public static final String BUTTON_SMALL_HOVER = "BUTTON_SMALL_HOVER";
public static final String MOVE_LEFT = "MOVE_LEFT";
public static final String MOVE_RIGHT = "MOVE_RIGHT";

View File

@ -17,8 +17,12 @@ public class SpriteLoader {
loadTexture(Name.GROUNDIMG, "sprites/ground.png");
loadTexture(Name.WALLIMG, "sprites/wall.png");
loadTexture(Name.SWINGHITBOXIMG, "sprites/swinghitbox.png");
loadTexture(Name.BUTTON_PLAY, "sprites/buttons/play.png");
loadTexture(Name.BUTTON_PLAY_HOVER, "sprites/buttons/playHover.png");
loadTexture(Name.BUTTON_HUGE, "sprites/buttons/Button_Huge.png");
loadTexture(Name.BUTTON_HUGE_HOVER, "sprites/buttons/Button_Huge_Hover.png");
loadTexture(Name.BUTTON_BIG, "sprites/buttons/Button_Big.png");
loadTexture(Name.BUTTON_BIG_HOVER, "sprites/buttons/Button_Big_Hover.png");
loadTexture(Name.BUTTON_SMALL, "sprites/buttons/Button_Small.png");
loadTexture(Name.BUTTON_SMALL_HOVER, "sprites/buttons/Button_Small_Hover.png");
}
/**