Permalink
Browse files

Agregar ElementoInterfaz

  • Loading branch information...
1 parent b278daa commit 83208510adcf6b8315d66b89658978b4a517fd53 @Luraguse Luraguse committed Mar 13, 2013
@@ -29,7 +29,7 @@
import com.lumpundform.eventos.Evento;
import com.lumpundform.excepciones.ActorNoDefinidoException;
import com.lumpundform.excepciones.EscenarioSinHeroeException;
-import com.lumpundform.interfaz.BotonBase;
+import com.lumpundform.interfaz.ElementoInterfaz;
import com.lumpundform.lumpundform.CamaraJuego;
import com.lumpundform.pociones.PocionBase;
import com.lumpundform.pociones.PocionMana;
@@ -450,29 +450,20 @@ public void continuarConversacionActual(String nombre) {
* Hace un toggle del UI. Si está visible, la esconde, si no, la muestra.
*/
public void toggleUI() {
- for (Actor actor : getActors()) {
- if (actor.getClass().getSimpleName().contains("Boton")
- || actor.getClass().getSimpleName().contains("Barra")) {
- if (actor.isVisible()) {
- SequenceAction sequence = new SequenceAction();
- sequence.addAction(Actions.fadeOut(0.30f));
- sequence.addAction(Actions.delay(0.30f));
- if (actor.getClass().getSimpleName().equals("BotonMenu")
- || actor.getClass().getSimpleName().contains("Pocion")) {
- ((BotonBase) actor).setFadeOut();
- }
- sequence.addAction(Actions.hide());
- actor.addAction(sequence);
- } else {
- SequenceAction sequence = new SequenceAction();
- sequence.addAction(Actions.show());
- sequence.addAction(Actions.fadeIn(0.30f));
- if (actor.getClass().getSimpleName().equals("BotonMenu")
- || actor.getClass().getSimpleName().contains("Pocion")) {
- ((BotonBase) actor).setFadeIn();
- }
- actor.addAction(sequence);
- }
+ for (ElementoInterfaz elemento : getActores(ElementoInterfaz.class)) {
+ if (elemento.isVisible()) {
+ SequenceAction sequence = new SequenceAction();
+ sequence.addAction(Actions.fadeOut(0.30f));
+ sequence.addAction(Actions.delay(0.30f));
+ elemento.setFadeOut();
+ sequence.addAction(Actions.hide());
+ elemento.addAction(sequence);
+ } else {
+ SequenceAction sequence = new SequenceAction();
+ sequence.addAction(Actions.show());
+ sequence.addAction(Actions.fadeIn(0.30f));
+ elemento.setFadeIn();
+ elemento.addAction(sequence);
}
}
}
@@ -3,20 +3,17 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
-import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.lumpundform.escenario.EscenarioBase;
import com.lumpundform.lumpundform.CamaraJuego;
import com.lumpundform.utilerias.Fuentes;
-public class BotonBase extends Button {
+public class BotonBase extends ElementoInterfaz {
private CamaraJuego camara;
private float xBase;
private float yBase;
BitmapFont bmf = Fuentes.regular();
-
- protected boolean fadeIn = false;
- protected boolean fadeOut = false;
+
private float alfa = 1.0f;
private float velocidadFade = 3.5f;
@@ -58,16 +55,6 @@ public void setxBase(float xBase) {
this.xBase = xBase;
}
- public void setFadeIn() {
- fadeIn = true;
- fadeOut = false;
- }
-
- public void setFadeOut() {
- fadeOut = true;
- fadeIn = false;
- }
-
private void fadeIn() {
if (alfa <= 0.00f)
alfa = alfa + (Gdx.graphics.getDeltaTime() * velocidadFade);
@@ -0,0 +1,25 @@
+package com.lumpundform.interfaz;
+
+import com.badlogic.gdx.scenes.scene2d.ui.Button;
+import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
+
+public class ElementoInterfaz extends Button {
+
+ protected boolean fadeIn = false;
+ protected boolean fadeOut = false;
+
+ public ElementoInterfaz(NinePatchDrawable ninePatchDrawable) {
+ super(new NinePatchDrawable(ninePatchDrawable));
+ }
+
+ public void setFadeIn() {
+ fadeIn = true;
+ fadeOut = false;
+ }
+
+ public void setFadeOut() {
+ fadeOut = true;
+ fadeIn = false;
+ }
+
+}

0 comments on commit 8320851

Please sign in to comment.