reorganizado, creado menu
This commit is contained in:
65
core/src/menus/Menu.java
Normal file
65
core/src/menus/Menu.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package menus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
|
||||
import utilidades.Gifs;
|
||||
|
||||
public abstract class Menu {
|
||||
String[] opciones;
|
||||
int resolucion;
|
||||
int position;
|
||||
int n_opciones;
|
||||
boolean pres;
|
||||
static final int MIN=0;
|
||||
static final int HD=1;
|
||||
static final int FHD=2;
|
||||
static final int INICIAL=0;
|
||||
static final int OPCIONES=1;
|
||||
int local;
|
||||
static int resolution;
|
||||
BitmapFont font;
|
||||
static Gifs selector;
|
||||
public static ArrayList<Menu> menus=new ArrayList<Menu>();
|
||||
public Menu() {
|
||||
this.position=0;
|
||||
this.pres=true;
|
||||
font = new BitmapFont(Gdx.files.internal("CentieSans.fnt"));
|
||||
selector = new Gifs("125760.png", 14, 39, 49, 15, 40, 40);
|
||||
}
|
||||
|
||||
abstract public int draw(SpriteBatch batch, float delta);
|
||||
|
||||
void dispose() {
|
||||
font.dispose();
|
||||
}
|
||||
|
||||
int cambiarSeleccionado() {
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
|
||||
if(!this.pres) {
|
||||
this.position++;
|
||||
this.pres=true;
|
||||
}
|
||||
}else if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
|
||||
if(!this.pres) {
|
||||
this.position--;
|
||||
this.pres=true;
|
||||
}
|
||||
}else if (Gdx.input.isKeyPressed(Input.Keys.ENTER)){
|
||||
if(!this.pres) {
|
||||
return darSeleccionado();
|
||||
}
|
||||
}else if(this.pres) {
|
||||
this.pres=false;
|
||||
}
|
||||
this.position%=this.n_opciones;
|
||||
if(this.position<0)this.position=this.n_opciones-1;
|
||||
return this.local;
|
||||
}
|
||||
|
||||
abstract int darSeleccionado();
|
||||
}
|
||||
39
core/src/menus/MenuInicio.java
Normal file
39
core/src/menus/MenuInicio.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package menus;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
|
||||
public class MenuInicio extends Menu{
|
||||
public MenuInicio() {
|
||||
super();
|
||||
this.n_opciones=2;
|
||||
this.local=Menu.INICIAL;
|
||||
}
|
||||
@Override
|
||||
public int draw(SpriteBatch batch, float delta) {
|
||||
Menu.selector.avanzar(10, delta);
|
||||
switch(this.position) {
|
||||
case 0:{
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5, Gdx.graphics.getHeight()/2.2f);
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+200, Gdx.graphics.getHeight()/2.2f);
|
||||
break;
|
||||
}
|
||||
case 1:{
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5, Gdx.graphics.getHeight()/5f);
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+400, Gdx.graphics.getHeight()/5f);
|
||||
}
|
||||
}
|
||||
font.draw(batch, "iniciar", Gdx.graphics.getWidth()/3.75f,Gdx.graphics.getHeight()/2);
|
||||
font.draw(batch, "configuracion", Gdx.graphics.getWidth()/5,Gdx.graphics.getHeight()/4);
|
||||
return this.cambiarSeleccionado();
|
||||
}
|
||||
|
||||
int darSeleccionado() {
|
||||
switch(this.position) {
|
||||
case 0:return 2;
|
||||
case 1:return Menu.OPCIONES;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
42
core/src/menus/MenuOpcions.java
Normal file
42
core/src/menus/MenuOpcions.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package menus;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
|
||||
public class MenuOpcions extends Menu{
|
||||
|
||||
public MenuOpcions() {
|
||||
super();
|
||||
this.n_opciones=2;
|
||||
this.pres=true;
|
||||
this.local=Menu.OPCIONES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int draw(SpriteBatch batch, float delta) {
|
||||
Menu.selector.avanzar(10, delta);
|
||||
switch(this.position) {
|
||||
case 0:{
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5, Gdx.graphics.getHeight()/2.2f);
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+200, Gdx.graphics.getHeight()/2.2f);
|
||||
break;
|
||||
}
|
||||
case 1:{
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5, Gdx.graphics.getHeight()/4.2f);
|
||||
Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+400, Gdx.graphics.getHeight()/4.2f);
|
||||
}
|
||||
}
|
||||
font.draw(batch, "resolucion", Gdx.graphics.getWidth()/3.75f,Gdx.graphics.getHeight()/2);
|
||||
font.draw(batch, "fondo:", Gdx.graphics.getWidth()/5,Gdx.graphics.getHeight()/4);
|
||||
return this.cambiarSeleccionado();
|
||||
}
|
||||
|
||||
int darSeleccionado() {
|
||||
switch(this.position) {
|
||||
case 0:return 3;
|
||||
case 1:return Menu.OPCIONES;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user