Skip to content

Commit

Permalink
Adds MainScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
netodevel committed Nov 12, 2017
1 parent fd236c4 commit 8aafe89
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
Binary file added android/assets/fundo0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/assets/fundo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion core/src/br/com/varchar/MainClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class MainClass extends Game {

@Override
public void create () {
setScreen(new MainScreen());
setScreen(new MainScreen(this));
}

}
44 changes: 41 additions & 3 deletions core/src/br/com/varchar/MainScreen.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,62 @@
package br.com.varchar;

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.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.FillViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

/**
* Created by josevieira on 11/11/17.
*/

public class MainScreen implements Screen {

private Game game;
private Viewport viewport;
private SpriteBatch spriteBatch;
private Texture[] menuTexture;
private float time;

public MainScreen(Game game) {
this.game = game;
}

@Override
public void show() {
time = 70;
spriteBatch = new SpriteBatch();

viewport = new FillViewport(1000, 1500);
viewport.apply();

menuTexture = new Texture[2];

menuTexture[0] = new Texture("fundo0.png");
menuTexture[1] = new Texture("fundo1.png");
}

@Override
public void render(float delta) {
time += delta;

spriteBatch.setProjectionMatrix(viewport.getCamera().combined);

Gdx.gl.glClearColor(0.29f, 0.894f, 0.373f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

spriteBatch.begin();

spriteBatch.draw(menuTexture[(int)time%2], 0, 0, 1000, 1500);

spriteBatch.end();
}

@Override
public void resize(int width, int height) {

viewport.update(width, height, true);
}

@Override
Expand All @@ -40,6 +76,8 @@ public void hide() {

@Override
public void dispose() {

spriteBatch.dispose();
menuTexture[0].dispose();
menuTexture[1].dispose();
}
}

0 comments on commit 8aafe89

Please sign in to comment.