Logo screen ready.

This commit is contained in:
Miguel Astor
2014-10-08 08:46:05 -04:30
parent 78e8fa3d34
commit b2bea761de
3 changed files with 67 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View File

@@ -30,6 +30,7 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.gamejolt.mikykr5.poukemon.states.BaseState;
import com.gamejolt.mikykr5.poukemon.states.LogoScreen;
import com.gamejolt.mikykr5.poukemon.states.MainMenuState;
public class GameCore extends Game {
@@ -84,24 +85,29 @@ public class GameCore extends Game {
fadeTexture = new Texture(pixmap);
pixmap.dispose();
alpha = new MutableFloat(0.0f);
fadeOut = Tween.to(alpha, 0, 0.5f).target(1.0f).ease(TweenEquations.easeInQuint);
fadeIn = Tween.to(alpha, 0, 0.5f).target(0.0f).ease(TweenEquations.easeInQuint);
fading = false;
alpha = new MutableFloat(1.0f);
fadeOut = Tween.to(alpha, 0, 2.5f).target(1.0f).ease(TweenEquations.easeInQuint);
fadeIn = Tween.to(alpha, 0, 2.5f).target(0.0f).ease(TweenEquations.easeInQuint);
fadeIn.start();
fading = true;
// Create application states.
states = new BaseState[game_states_t.getNumStates()];
try{
states[game_states_t.LOGO_SCREEN.getValue()] = new LogoScreen(this);
states[game_states_t.MAIN_MENU.getValue()] = new MainMenuState(this);
states[game_states_t.IN_GAME.getValue()] = null;
states[game_states_t.LOADING.getValue()] = null;
states[game_states_t.QUIT.getValue()] = null;
}catch(IllegalArgumentException e){
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument caught creating states: ", e);
System.exit(1);
return;
}
// Set the current and next states.
currState = game_states_t.MAIN_MENU;
// Set the initial current and next states.
currState = game_states_t.LOGO_SCREEN;
nextState = null;
this.setScreen(states[currState.getValue()]);
states[currState.getValue()].onStateEnabled();
@@ -183,6 +189,13 @@ public class GameCore extends Game {
public void dispose(){
super.dispose();
// Dispose screens.
for(BaseState state : states){
if(state != null)
state.dispose();
}
fadeTexture.dispose();
batch.dispose();
}
}

View File

@@ -16,19 +16,63 @@
package com.gamejolt.mikykr5.poukemon.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.gamejolt.mikykr5.poukemon.GameCore;
import com.gamejolt.mikykr5.poukemon.GameCore.game_states_t;
public class LogoScreen extends BaseState {
private static final String CLASS_NAME = LogoScreen.class.getSimpleName();
private Texture logo;
private long then;
public LogoScreen(final GameCore core){
if(core == null)
throw new IllegalArgumentException(CLASS_NAME + ": Core is null.");
this.core = core;
then = System.currentTimeMillis();
logo = new Texture(Gdx.files.internal("data/gfx/textures/monkey.png"));
}
@Override
public void render(float delta) {
// TODO Auto-generated method stub
public void render(float _){
long now, delta;
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
core.batch.setProjectionMatrix(this.pixelPerfectCamera.combined);
core.batch.begin();{
core.batch.draw(logo, -logo.getWidth() / 2, -logo.getHeight() / 2);
}core.batch.end();
now = System.currentTimeMillis();
delta = now - then;
if(delta > 8000L){
core.nextState = game_states_t.MAIN_MENU;
then = now;
}
}
@Override
public void dispose() {
// TODO Auto-generated method stub
logo.dispose();
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button){
then = 0L;
return true;
};
@Override
public boolean keyDown(int keycode){
then = 0L;
return true;
};
}