Logo screen ready.
This commit is contained in:
BIN
android/assets/data/gfx/textures/monkey.png
Normal file
BIN
android/assets/data/gfx/textures/monkey.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
@@ -30,6 +30,7 @@ import com.badlogic.gdx.graphics.Texture;
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||||
import com.gamejolt.mikykr5.poukemon.states.BaseState;
|
import com.gamejolt.mikykr5.poukemon.states.BaseState;
|
||||||
|
import com.gamejolt.mikykr5.poukemon.states.LogoScreen;
|
||||||
import com.gamejolt.mikykr5.poukemon.states.MainMenuState;
|
import com.gamejolt.mikykr5.poukemon.states.MainMenuState;
|
||||||
|
|
||||||
public class GameCore extends Game {
|
public class GameCore extends Game {
|
||||||
@@ -84,24 +85,29 @@ public class GameCore extends Game {
|
|||||||
fadeTexture = new Texture(pixmap);
|
fadeTexture = new Texture(pixmap);
|
||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
|
|
||||||
alpha = new MutableFloat(0.0f);
|
alpha = new MutableFloat(1.0f);
|
||||||
fadeOut = Tween.to(alpha, 0, 0.5f).target(1.0f).ease(TweenEquations.easeInQuint);
|
fadeOut = Tween.to(alpha, 0, 2.5f).target(1.0f).ease(TweenEquations.easeInQuint);
|
||||||
fadeIn = Tween.to(alpha, 0, 0.5f).target(0.0f).ease(TweenEquations.easeInQuint);
|
fadeIn = Tween.to(alpha, 0, 2.5f).target(0.0f).ease(TweenEquations.easeInQuint);
|
||||||
fading = false;
|
fadeIn.start();
|
||||||
|
fading = true;
|
||||||
|
|
||||||
// Create application states.
|
// Create application states.
|
||||||
states = new BaseState[game_states_t.getNumStates()];
|
states = new BaseState[game_states_t.getNumStates()];
|
||||||
|
|
||||||
try{
|
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.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){
|
}catch(IllegalArgumentException e){
|
||||||
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument caught creating states: ", e);
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument caught creating states: ", e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the current and next states.
|
// Set the initial current and next states.
|
||||||
currState = game_states_t.MAIN_MENU;
|
currState = game_states_t.LOGO_SCREEN;
|
||||||
nextState = null;
|
nextState = null;
|
||||||
this.setScreen(states[currState.getValue()]);
|
this.setScreen(states[currState.getValue()]);
|
||||||
states[currState.getValue()].onStateEnabled();
|
states[currState.getValue()].onStateEnabled();
|
||||||
@@ -183,6 +189,13 @@ public class GameCore extends Game {
|
|||||||
public void dispose(){
|
public void dispose(){
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
||||||
|
// Dispose screens.
|
||||||
|
for(BaseState state : states){
|
||||||
|
if(state != null)
|
||||||
|
state.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
fadeTexture.dispose();
|
fadeTexture.dispose();
|
||||||
|
batch.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,63 @@
|
|||||||
package com.gamejolt.mikykr5.poukemon.states;
|
package com.gamejolt.mikykr5.poukemon.states;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
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 {
|
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
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float _){
|
||||||
// TODO Auto-generated method stub
|
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
|
@Override
|
||||||
public void dispose() {
|
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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user