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();
|
||||
}
|
||||
Reference in New Issue
Block a user