2021-04-09 09:57:52 +00:00
|
|
|
package sagittarius.view;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.Gdx;
|
2021-04-12 18:45:09 +00:00
|
|
|
import com.badlogic.gdx.graphics.GL30;
|
2021-04-09 09:57:52 +00:00
|
|
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
2021-04-13 19:55:14 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
import com.badlogic.gdx.Screen;
|
|
|
|
|
|
|
|
public abstract class BaseScreen implements Screen {
|
2021-04-13 17:29:47 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
protected Stage mainStage;
|
|
|
|
protected Stage uiStage;
|
2021-04-13 17:29:47 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
public BaseScreen() {
|
|
|
|
mainStage = new Stage();
|
2021-05-12 15:51:21 +00:00
|
|
|
mainStage.getRoot().setTransform(false);
|
2021-04-09 09:57:52 +00:00
|
|
|
uiStage = new Stage();
|
2021-05-12 15:51:21 +00:00
|
|
|
uiStage.getRoot().setTransform(false);
|
2021-04-09 09:57:52 +00:00
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void initialize();
|
|
|
|
public abstract void update(float dt);
|
2021-04-13 17:29:47 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
@Override
|
|
|
|
public void render(float dt) {
|
2021-04-13 17:29:47 +00:00
|
|
|
|
|
|
|
// update
|
|
|
|
update(dt);
|
|
|
|
|
2021-04-09 10:01:00 +00:00
|
|
|
// update Stages
|
2021-04-09 09:57:52 +00:00
|
|
|
uiStage.act(dt);
|
|
|
|
mainStage.act(dt);
|
|
|
|
|
|
|
|
// clear screen
|
|
|
|
Gdx.gl.glClearColor(0,0,0,1);
|
2021-04-12 18:45:09 +00:00
|
|
|
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
|
2021-04-13 17:29:47 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
// draw actors on screnn
|
|
|
|
mainStage.draw();
|
|
|
|
uiStage.draw();
|
|
|
|
}
|
2021-04-13 17:29:47 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
@Override public void dispose() {
|
|
|
|
uiStage.dispose();
|
|
|
|
mainStage.dispose();
|
|
|
|
}
|
|
|
|
|
2021-04-09 10:01:00 +00:00
|
|
|
@Override public void resize(int width, int height) {
|
|
|
|
mainStage.getViewport().update(width, height, true);
|
|
|
|
}
|
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
@Override public void pause() {}
|
2021-04-09 12:56:36 +00:00
|
|
|
@Override public void resume() {}
|
2021-04-09 09:57:52 +00:00
|
|
|
@Override public void show() {}
|
|
|
|
@Override public void hide() {}
|
2021-04-09 12:56:36 +00:00
|
|
|
|
2021-04-09 09:57:52 +00:00
|
|
|
}
|