reorganizado, creado menu
This commit is contained in:
44
core/src/utilidades/Gifs.java
Normal file
44
core/src/utilidades/Gifs.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package utilidades;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
|
||||
public class Gifs {
|
||||
private Texture textura;
|
||||
private TextureRegion[] frames;
|
||||
private int n_estados;
|
||||
private float contadorEstado;
|
||||
|
||||
public Gifs(String ruta, int n_estados, int inicio_image, int desplazamiento,
|
||||
int anchura, int x, int y) {
|
||||
textura = new Texture(ruta);
|
||||
this.n_estados = n_estados;
|
||||
frames = new TextureRegion[n_estados];
|
||||
for(int i = 0; i<n_estados; i++) {
|
||||
frames[i] = new TextureRegion(textura, inicio_image+i*desplazamiento
|
||||
, anchura, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public Gifs(Texture textura, int n_estados, int inicio_image, int desplazamiento,
|
||||
int anchura, int x, int y) {
|
||||
this.textura = textura;
|
||||
this.n_estados = n_estados;
|
||||
frames = new TextureRegion[n_estados];
|
||||
for(int i = 0; i<n_estados; i++) {
|
||||
frames[i] = new TextureRegion(textura, inicio_image+i*desplazamiento
|
||||
, anchura, x, y);
|
||||
}
|
||||
}
|
||||
public void avanzar(int speed, float delta) {
|
||||
this.contadorEstado+=delta*speed;
|
||||
if(this.contadorEstado > this.n_estados) {
|
||||
this.contadorEstado=0;
|
||||
}
|
||||
}
|
||||
public void draw(SpriteBatch batch, float x, float y) {
|
||||
batch.draw(this.frames[(int)contadorEstado], x, y);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user