Skip to content

Commit

Permalink
Agregar ElementoInterfaz
Browse files Browse the repository at this point in the history
  • Loading branch information
Luraguse committed Mar 13, 2013
1 parent b278daa commit 8320851
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
39 changes: 15 additions & 24 deletions lumpundform/src/com/lumpundform/escenario/EscenarioBase.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.lumpundform.eventos.Evento; import com.lumpundform.eventos.Evento;
import com.lumpundform.excepciones.ActorNoDefinidoException; import com.lumpundform.excepciones.ActorNoDefinidoException;
import com.lumpundform.excepciones.EscenarioSinHeroeException; import com.lumpundform.excepciones.EscenarioSinHeroeException;
import com.lumpundform.interfaz.BotonBase; import com.lumpundform.interfaz.ElementoInterfaz;
import com.lumpundform.lumpundform.CamaraJuego; import com.lumpundform.lumpundform.CamaraJuego;
import com.lumpundform.pociones.PocionBase; import com.lumpundform.pociones.PocionBase;
import com.lumpundform.pociones.PocionMana; import com.lumpundform.pociones.PocionMana;
Expand Down Expand Up @@ -450,29 +450,20 @@ public void continuarConversacionActual(String nombre) {
* Hace un toggle del UI. Si está visible, la esconde, si no, la muestra. * Hace un toggle del UI. Si está visible, la esconde, si no, la muestra.
*/ */
public void toggleUI() { public void toggleUI() {
for (Actor actor : getActors()) { for (ElementoInterfaz elemento : getActores(ElementoInterfaz.class)) {
if (actor.getClass().getSimpleName().contains("Boton") if (elemento.isVisible()) {
|| actor.getClass().getSimpleName().contains("Barra")) { SequenceAction sequence = new SequenceAction();
if (actor.isVisible()) { sequence.addAction(Actions.fadeOut(0.30f));
SequenceAction sequence = new SequenceAction(); sequence.addAction(Actions.delay(0.30f));
sequence.addAction(Actions.fadeOut(0.30f)); elemento.setFadeOut();
sequence.addAction(Actions.delay(0.30f)); sequence.addAction(Actions.hide());
if (actor.getClass().getSimpleName().equals("BotonMenu") elemento.addAction(sequence);
|| actor.getClass().getSimpleName().contains("Pocion")) { } else {
((BotonBase) actor).setFadeOut(); SequenceAction sequence = new SequenceAction();
} sequence.addAction(Actions.show());
sequence.addAction(Actions.hide()); sequence.addAction(Actions.fadeIn(0.30f));
actor.addAction(sequence); elemento.setFadeIn();
} else { elemento.addAction(sequence);
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);
}
} }
} }
} }
Expand Down
17 changes: 2 additions & 15 deletions lumpundform/src/com/lumpundform/interfaz/BotonBase.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch; 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.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.lumpundform.escenario.EscenarioBase; import com.lumpundform.escenario.EscenarioBase;
import com.lumpundform.lumpundform.CamaraJuego; import com.lumpundform.lumpundform.CamaraJuego;
import com.lumpundform.utilerias.Fuentes; import com.lumpundform.utilerias.Fuentes;


public class BotonBase extends Button { public class BotonBase extends ElementoInterfaz {
private CamaraJuego camara; private CamaraJuego camara;
private float xBase; private float xBase;
private float yBase; private float yBase;
BitmapFont bmf = Fuentes.regular(); BitmapFont bmf = Fuentes.regular();


protected boolean fadeIn = false;
protected boolean fadeOut = false;
private float alfa = 1.0f; private float alfa = 1.0f;
private float velocidadFade = 3.5f; private float velocidadFade = 3.5f;


Expand Down Expand Up @@ -58,16 +55,6 @@ public void setxBase(float xBase) {
this.xBase = xBase; this.xBase = xBase;
} }


public void setFadeIn() {
fadeIn = true;
fadeOut = false;
}

public void setFadeOut() {
fadeOut = true;
fadeIn = false;
}

private void fadeIn() { private void fadeIn() {
if (alfa <= 0.00f) if (alfa <= 0.00f)
alfa = alfa + (Gdx.graphics.getDeltaTime() * velocidadFade); alfa = alfa + (Gdx.graphics.getDeltaTime() * velocidadFade);
Expand Down
25 changes: 25 additions & 0 deletions lumpundform/src/com/lumpundform/interfaz/ElementoInterfaz.java
Original file line number Original file line Diff line number Diff line change
@@ -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.