69 lines
1.5 KiB
Java
69 lines
1.5 KiB
Java
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;
|
|
static final int SELEC=2;
|
|
static final int BATTLE=3;
|
|
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("iconos.png", 14, 39, 49, 15, 40, 40, false);
|
|
}
|
|
|
|
abstract public int draw(SpriteBatch batch, float delta);
|
|
|
|
public void dispose() {
|
|
font.dispose();
|
|
selector.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();
|
|
}
|