feat: MouseInfo now extends BaseActor

This commit is contained in:
Laureηt 2021-04-13 19:29:47 +02:00
parent fd222f1dc7
commit 41a997b1d0
3 changed files with 22 additions and 25 deletions

View file

@ -1,29 +1,25 @@
package sagittarius.model;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Actor;
import sagittarius.view.GameScreen;
public class MouseInfo extends Actor {
public class MouseInfo extends BaseActor {
// ---------- ATTRIBUTEs ----------
private BitmapFont font = new BitmapFont();
// ---------- METHODs ----------
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
font.draw(batch, "screen=" + (int)GameScreen.screenCursor.x + "," + (int)GameScreen.screenCursor.y,
GameScreen.worldCursor.x, GameScreen.worldCursor.y + font.getCapHeight());
font.draw(batch, "world=" + (int)GameScreen.worldCursor.x + "," + (int)GameScreen.worldCursor.y,
GameScreen.worldCursor.x, GameScreen.worldCursor.y + font.getCapHeight()*2);
public void act(float delta) {
super.act(delta);
setX(GameScreen.worldCursor.x);
setY(GameScreen.worldCursor.y);
}
@Override
protected String getInfo() {
return
"screen=" + (int)GameScreen.screenCursor.x + "," + (int)GameScreen.screenCursor.y + "\n"
+ "world=" + (int)GameScreen.worldCursor.x + "," + (int)GameScreen.worldCursor.y
;
}
}

View file

@ -22,13 +22,13 @@ public abstract class BaseScreen implements Screen {
@Override
public void render(float dt) {
// update
update(dt);
// update Stages
uiStage.act(dt);
mainStage.act(dt);
// update
update(dt);
// clear screen
Gdx.gl.glClearColor(0,0,0,1);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);

View file

@ -59,6 +59,7 @@ public class GameScreen extends BaseScreen {
uiStage.addActor(mouseInfo);
mainStage.setDebugAll(true); // TODO: disable later
uiStage.setDebugAll(true); // TODO: disable later
}