added SplashScreen

This commit is contained in:
Anastron 2014-08-11 14:23:09 +02:00
parent 30f911bf4f
commit 57da84eb7a
4 changed files with 168 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,58 @@
package de.samdev.clorrunner.screens.menu;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Stage;
public class MainMenu implements Screen {
private Stage stage = new Stage();
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act();
stage.draw();
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void show() {
// TODO Auto-generated method stub
}
@Override
public void hide() {
dispose();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
stage.dispose();
}
}

View File

@ -0,0 +1,106 @@
package de.samdev.clorrunner.screens.menu;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
public class SplashScreen implements Screen {
private float loadTime = 0;
private int random = MathUtils.random(5);
private Texture logo = new Texture("images/samlogo.png");
private OrthographicCamera cam = new OrthographicCamera();
private SpriteBatch sB;
@Override
public void render(float delta) {
if(random == 0){
Gdx.gl.glClearColor(0.4f, 0, 0, 1); // Rot
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}else if (random == 1){
Gdx.gl.glClearColor(0.8f, 0.8f, 0, 1); //Gelb
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}else if ((random == 2)){
Gdx.gl.glClearColor(1, 0.5f, 0.25f, 1); //Orange
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}else if (random == 3){
Gdx.gl.glClearColor(0.25f, 0.5f, 1, 1); //Blau
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}else if (random == 4){
Gdx.gl.glClearColor(0, 0.8f, 0.3f, 1); //Grün
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}else if (random == 5){
Gdx.gl.glClearColor(1, 1, 1, 1); //Weiß
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
sB.begin();
sB.draw(logo, -9,
-8, 18, 16);
sB.end();
loadTime += delta;
if (loadTime > 0.5)
((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen());
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void show() {
sB = new SpriteBatch();
this.cam = new OrthographicCamera(20,40);
this.cam.position.set(20 / 2, 40 / 2, 0);
sB.setProjectionMatrix(cam.combined);
cam.update();
}
@Override
public void hide() {
dispose();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
logo.dispose();
}
}

View File

@ -2,18 +2,19 @@ package de.samdev.colorrunner;
import com.badlogic.gdx.Game;
import de.samdev.clorrunner.screens.menu.SplashScreen;
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
public class CRGame extends Game {
private GameScreen gameScreen;
private SplashScreen SplashScreen;
@Override
public void create() {
gameScreen = new GameScreen();
SplashScreen = new SplashScreen();
//----------------------------------
setScreen(gameScreen);
setScreen(SplashScreen);
}
}