GUI Rendering fixed
This commit is contained in:
parent
7a04b439ac
commit
a20e960c19
@ -173,13 +173,15 @@ public class GladiatorBrawler extends ApplicationAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initializeTestGUI() {
|
public void initializeTestGUI() {
|
||||||
Sprite img = SpriteLoader.loadSprite(Name.GROUNDIMG);
|
Sprite img1 = SpriteLoader.loadSprite(Name.WALLIMG, 0, 0, 32, 64);
|
||||||
ButtonNode button = new ButtonNode("test-button", img, img) {
|
Sprite img2 = SpriteLoader.loadSprite(Name.WALLIMG, 1, 0, 32, 64);
|
||||||
|
ButtonNode button = new ButtonNode("test-button", img1, img2) {
|
||||||
@Override
|
@Override
|
||||||
public void click(float x, float y, Input.Buttons mouseButton) {
|
public void click(float x, float y, Input.Buttons mouseButton) {
|
||||||
Log.info("I should never be pressed!");
|
Log.info("I should never be pressed!");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
button.setPosition(0.12f, 0.5f);
|
||||||
guiManager.getRootNode().addChild(button);
|
guiManager.getRootNode().addChild(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ public class GUIManager {
|
|||||||
private final GUINode rootNode;
|
private final GUINode rootNode;
|
||||||
|
|
||||||
public GUIManager() {
|
public GUIManager() {
|
||||||
this.rootNode = new GUINode("root");
|
this.rootNode = new GUINode("root").setPosition(-.5f, -.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUINode getRootNode() {
|
public GUINode getRootNode() {
|
||||||
|
@ -21,7 +21,10 @@ import com.saltosion.gladiator.components.CRenderedObject;
|
|||||||
import com.saltosion.gladiator.gui.GUINode;
|
import com.saltosion.gladiator.gui.GUINode;
|
||||||
import com.saltosion.gladiator.gui.ImageNode;
|
import com.saltosion.gladiator.gui.ImageNode;
|
||||||
import com.saltosion.gladiator.util.AppUtil;
|
import com.saltosion.gladiator.util.AppUtil;
|
||||||
|
import com.saltosion.gladiator.util.Global;
|
||||||
import com.saltosion.gladiator.util.Log;
|
import com.saltosion.gladiator.util.Log;
|
||||||
|
import com.saltosion.gladiator.util.Name;
|
||||||
|
import com.saltosion.gladiator.util.SpriteLoader;
|
||||||
import com.saltosion.gladiator.util.SpriteSequence;
|
import com.saltosion.gladiator.util.SpriteSequence;
|
||||||
|
|
||||||
public class RenderingSystem extends EntitySystem {
|
public class RenderingSystem extends EntitySystem {
|
||||||
@ -84,7 +87,7 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
float nextFrame = renderedObject.getCurrentFrame() + deltaTime * currSequence.getPlayspeed();
|
float nextFrame = renderedObject.getCurrentFrame() + deltaTime * currSequence.getPlayspeed();
|
||||||
renderedObject.setCurrentFrame(nextFrame % currSequence.frameCount());
|
renderedObject.setCurrentFrame(nextFrame % currSequence.frameCount());
|
||||||
}
|
}
|
||||||
renderGUINode(AppUtil.guiManager.getRootNode(), Vector2.Zero);
|
renderGUINode(AppUtil.guiManager.getRootNode(), new Vector2(0, 0));
|
||||||
|
|
||||||
batch.end();
|
batch.end();
|
||||||
|
|
||||||
@ -111,10 +114,9 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
public void renderGUINode(GUINode node, Vector2 position) {
|
public void renderGUINode(GUINode node, Vector2 position) {
|
||||||
position.add(node.getPosition());
|
position.add(node.getPosition());
|
||||||
if (node instanceof ImageNode) {
|
if (node instanceof ImageNode) {
|
||||||
Log.info("Node found with ImageNode");
|
|
||||||
Sprite s = ((ImageNode) node).getImage();
|
Sprite s = ((ImageNode) node).getImage();
|
||||||
s.setPosition(position.x*AppUtil.VPHEIGHT_CONST*aspectratio+camera.position.x,
|
s.setPosition(position.x*AppUtil.VPHEIGHT_CONST*aspectratio-s.getWidth()/2+camera.position.x,
|
||||||
position.y*AppUtil.VPHEIGHT_CONST+camera.position.y);
|
position.y*AppUtil.VPHEIGHT_CONST-s.getHeight()/2+camera.position.y);
|
||||||
s.draw(batch);
|
s.draw(batch);
|
||||||
}
|
}
|
||||||
for (GUINode child : node.getChildren()) {
|
for (GUINode child : node.getChildren()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user