test with backgrounds

This commit is contained in:
Armin Benz 2017-04-14 03:20:33 +02:00
parent 2253d55fd2
commit dba41061a4
4 changed files with 34 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 KiB

View File

@ -3,6 +3,9 @@ package de.samdev.colorrunner.screens.menu;
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.Gdx2DPixmap;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
@ -24,7 +27,8 @@ public class MainMenu implements Screen {
private Stage stage = new Stage();
private Table table = new Table();
private CRGame game;
private OrthographicCamera cam = new OrthographicCamera();
private Texture background = new Texture("images/background2.jpg");
private Skin skin = new Skin(Gdx.files.internal("skins/menuSkin.json"),
new TextureAtlas(Gdx.files.internal("skins/menuSkin.pack")));
@ -34,6 +38,7 @@ public class MainMenu implements Screen {
private TextButton buttonPlay2 = new TextButton("Play Endless", skin);
private TextButton buttonExit = new TextButton("Exit", skin);
private TextButton buttonOption = new TextButton("Option", skin);
private Label title = new Label("Color Runner", skin);
@ -41,7 +46,17 @@ public class MainMenu implements Screen {
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
cam.setToOrtho(false, (float)Gdx.graphics.getWidth() / 2.0F, (float)Gdx.graphics.getHeight() / 2.0F);
SpriteBatch sb = new SpriteBatch();
sb.setProjectionMatrix(cam.combined);
sb.begin();
sb.draw(background, 0, 0);
sb.end();
stage.act();
stage.draw();

View File

@ -4,6 +4,9 @@ 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.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
@ -19,19 +22,31 @@ public class OptionMenuScreen implements Screen{
private Stage stage = new Stage();
private Table table = new Table();
private Texture background = new Texture("images/background2.jpg");
private OrthographicCamera cam = new OrthographicCamera();
private Skin skin = new Skin(Gdx.files.internal("skins/menuSkin.json"),
new TextureAtlas(Gdx.files.internal("skins/menuSkin.pack")));
public OptionMenuScreen() {
//cam.setToOrtho(false, (float)Gdx.graphics.getWidth() / 2, (float)Gdx.graphics.getHeight() / 2);
}
private Label title = new Label("Option", skin);
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
cam.setToOrtho(false, (float)Gdx.graphics.getWidth() / 2.0F, (float)Gdx.graphics.getHeight() / 2.0F);
SpriteBatch sb = new SpriteBatch();
sb.setProjectionMatrix(cam.combined);
sb.begin();
sb.draw(background, 0, 0);
sb.end();
stage.act();
stage.draw();

View File

@ -40,7 +40,7 @@ public class SplashScreen implements Screen {
sB.end();
loadTime += delta;
if (loadTime > 1.9)
if (loadTime > 0.9)
((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
}