52 lines
1.2 KiB
Java
52 lines
1.2 KiB
Java
|
package sagittarius.view;
|
||
|
|
||
|
import com.badlogic.gdx.Gdx;
|
||
|
import com.badlogic.gdx.graphics.GL20;
|
||
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||
|
import com.badlogic.gdx.Screen;
|
||
|
|
||
|
public abstract class BaseScreen implements Screen {
|
||
|
|
||
|
protected Stage mainStage;
|
||
|
protected Stage uiStage;
|
||
|
|
||
|
public BaseScreen() {
|
||
|
mainStage = new Stage();
|
||
|
uiStage = new Stage();
|
||
|
initialize();
|
||
|
}
|
||
|
|
||
|
public abstract void initialize();
|
||
|
public abstract void update(float dt);
|
||
|
|
||
|
@Override
|
||
|
public void render(float dt) {
|
||
|
|
||
|
// update actors
|
||
|
uiStage.act(dt);
|
||
|
mainStage.act(dt);
|
||
|
|
||
|
// update
|
||
|
update(dt);
|
||
|
|
||
|
// clear screen
|
||
|
Gdx.gl.glClearColor(0,0,0,1);
|
||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||
|
|
||
|
// draw actors on screnn
|
||
|
mainStage.draw();
|
||
|
uiStage.draw();
|
||
|
}
|
||
|
|
||
|
@Override public void dispose() {
|
||
|
uiStage.dispose();
|
||
|
mainStage.dispose();
|
||
|
}
|
||
|
|
||
|
// methods required by Screen interface
|
||
|
@Override public void resize(int width, int height) {}
|
||
|
@Override public void pause() {}
|
||
|
@Override public void resume(){}
|
||
|
@Override public void show() {}
|
||
|
@Override public void hide() {}
|
||
|
}
|