2014-08-10 00:42:19 +02:00
|
|
|
package de.samdev.colorrunner.screens.gameScreen;
|
2014-08-10 00:24:45 +02:00
|
|
|
|
|
|
|
import com.badlogic.gdx.Gdx;
|
2014-08-10 01:59:18 +02:00
|
|
|
import com.badlogic.gdx.InputMultiplexer;
|
2014-08-10 00:24:45 +02:00
|
|
|
import com.badlogic.gdx.Screen;
|
|
|
|
import com.badlogic.gdx.graphics.GL20;
|
2014-08-10 01:59:18 +02:00
|
|
|
import com.badlogic.gdx.input.GestureDetector;
|
2014-08-10 00:24:45 +02:00
|
|
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
|
|
|
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
|
|
|
|
2014-08-10 01:59:18 +02:00
|
|
|
import de.samdev.colorrunner.actors.CRPlayer;
|
|
|
|
import de.samdev.colorrunner.input.CRGameInputProcessor;
|
|
|
|
import de.samdev.colorrunner.input.GameInputListener;
|
|
|
|
import de.samdev.colorrunner.input.SwipeDirection;
|
2014-08-10 00:24:45 +02:00
|
|
|
|
2014-08-10 01:59:18 +02:00
|
|
|
public class GameScreen implements Screen, GameInputListener {
|
2014-08-10 00:24:45 +02:00
|
|
|
private Stage stage;
|
|
|
|
|
2014-08-10 01:59:18 +02:00
|
|
|
private CRPlayer player;
|
|
|
|
|
2014-08-10 00:24:45 +02:00
|
|
|
public GameScreen() {
|
2014-08-10 01:59:18 +02:00
|
|
|
stage = new Stage(new ExtendViewport(967, 544));
|
2014-08-10 00:42:19 +02:00
|
|
|
|
2014-08-10 01:59:18 +02:00
|
|
|
player = new CRPlayer();
|
|
|
|
stage.addActor(player);
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(float delta) {
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
stage.act(delta);
|
|
|
|
stage.draw();
|
2014-08-10 01:59:18 +02:00
|
|
|
|
|
|
|
// stage.getViewport().getCamera().position.x = player.getX();
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void resize(int width, int height) {
|
2014-08-10 01:59:18 +02:00
|
|
|
Gdx.app.log("GameScreen", "resize called");
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void show() {
|
2014-08-10 01:59:18 +02:00
|
|
|
CRGameInputProcessor ip = new CRGameInputProcessor(this);
|
|
|
|
Gdx.input.setInputProcessor(new InputMultiplexer(stage, ip, new GestureDetector(ip)));
|
|
|
|
|
2014-08-10 00:42:19 +02:00
|
|
|
Gdx.app.log("GameScreen", "show called");
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void hide() {
|
2014-08-10 01:59:18 +02:00
|
|
|
Gdx.input.setInputProcessor(null);
|
|
|
|
|
2014-08-10 00:42:19 +02:00
|
|
|
Gdx.app.log("GameScreen", "hide called");
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void pause() {
|
2014-08-10 00:42:19 +02:00
|
|
|
Gdx.app.log("GameScreen", "pause called");
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void resume() {
|
2014-08-10 00:42:19 +02:00
|
|
|
Gdx.app.log("GameScreen", "resume called");
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void dispose() {
|
2014-08-10 00:42:19 +02:00
|
|
|
Gdx.app.log("GameScreen", "dispose called");
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
2014-08-10 01:59:18 +02:00
|
|
|
@Override
|
|
|
|
public void doJump() {
|
|
|
|
player.jump();
|
|
|
|
|
|
|
|
Gdx.app.log("GameScreen", "[DO] Jump");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void switchColor(SwipeDirection sd) {
|
|
|
|
player.switchColorState(sd);
|
|
|
|
|
|
|
|
Gdx.app.log("GameScreen", "[DO] Switch + " + sd.toString());
|
|
|
|
}
|
|
|
|
|
2014-08-10 00:24:45 +02:00
|
|
|
}
|