diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index 1d17de8..544d9f9 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -173,13 +173,15 @@ public class GladiatorBrawler extends ApplicationAdapter { } public void initializeTestGUI() { - Sprite img = SpriteLoader.loadSprite(Name.GROUNDIMG); - ButtonNode button = new ButtonNode("test-button", img, img) { + Sprite img1 = SpriteLoader.loadSprite(Name.WALLIMG, 0, 0, 32, 64); + Sprite img2 = SpriteLoader.loadSprite(Name.WALLIMG, 1, 0, 32, 64); + ButtonNode button = new ButtonNode("test-button", img1, img2) { @Override public void click(float x, float y, Input.Buttons mouseButton) { Log.info("I should never be pressed!"); } }; + button.setPosition(0.12f, 0.5f); guiManager.getRootNode().addChild(button); } diff --git a/core/src/com/saltosion/gladiator/gui/GUIManager.java b/core/src/com/saltosion/gladiator/gui/GUIManager.java index bd7fb43..92ebd52 100644 --- a/core/src/com/saltosion/gladiator/gui/GUIManager.java +++ b/core/src/com/saltosion/gladiator/gui/GUIManager.java @@ -4,7 +4,7 @@ public class GUIManager { private final GUINode rootNode; public GUIManager() { - this.rootNode = new GUINode("root"); + this.rootNode = new GUINode("root").setPosition(-.5f, -.5f); } public GUINode getRootNode() { diff --git a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java index 17f8534..4b5ca5f 100644 --- a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java +++ b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java @@ -21,7 +21,10 @@ import com.saltosion.gladiator.components.CRenderedObject; import com.saltosion.gladiator.gui.GUINode; import com.saltosion.gladiator.gui.ImageNode; import com.saltosion.gladiator.util.AppUtil; +import com.saltosion.gladiator.util.Global; import com.saltosion.gladiator.util.Log; +import com.saltosion.gladiator.util.Name; +import com.saltosion.gladiator.util.SpriteLoader; import com.saltosion.gladiator.util.SpriteSequence; public class RenderingSystem extends EntitySystem { @@ -84,7 +87,7 @@ public class RenderingSystem extends EntitySystem { float nextFrame = renderedObject.getCurrentFrame() + deltaTime * currSequence.getPlayspeed(); renderedObject.setCurrentFrame(nextFrame % currSequence.frameCount()); } - renderGUINode(AppUtil.guiManager.getRootNode(), Vector2.Zero); + renderGUINode(AppUtil.guiManager.getRootNode(), new Vector2(0, 0)); batch.end(); @@ -111,10 +114,9 @@ public class RenderingSystem extends EntitySystem { public void renderGUINode(GUINode node, Vector2 position) { position.add(node.getPosition()); if (node instanceof ImageNode) { - Log.info("Node found with ImageNode"); Sprite s = ((ImageNode) node).getImage(); - s.setPosition(position.x*AppUtil.VPHEIGHT_CONST*aspectratio+camera.position.x, - position.y*AppUtil.VPHEIGHT_CONST+camera.position.y); + s.setPosition(position.x*AppUtil.VPHEIGHT_CONST*aspectratio-s.getWidth()/2+camera.position.x, + position.y*AppUtil.VPHEIGHT_CONST-s.getHeight()/2+camera.position.y); s.draw(batch); } for (GUINode child : node.getChildren()) {