I have the following Actor:
public class Carta extends Actor {
Sprite sprite;
public static int val, pos, peso;
Texture texture;
public Carta(int valor, int posicao) {
val = valor;
pos = posicao;
switch (val) {
case 1:
texture = new Texture("espada.png");
peso = 3;
break;
case 2:
texture = new Texture("basto.jpg");
peso = 2;
break;
case 3:
texture = new Texture("tres.jpg");
peso = 1;
break;
}
sprite = new Sprite(texture);
}
public void draw(Batch batch, float pAlfa) {
final Color c = getColor();
batch.setColor(c.r, c.g, c.b, c.a * pAlfa);
batch.draw(sprite, getX(), getY(), this.getWidth() / 2, 0, getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation());
batch.setColor(c.r, c.g, c.b, 1f);
//this.setOrigin(this.getWidth() / 2, this.getHeight());
}
public void act(float delta) {
super.act(delta);
}
}
And I call this actor:
...
carta1 = new Carta(1,2);
carta1.setBounds(100,200, 100, 250);
carta2 = new Carta(2,3);
carta2.setBounds(100,300, 100, 250);
stage.addActor(carta1);
stage.addActor(carta2);
...
So I redeem the variable int peso
with carta1.peso
or carta2.peso
, and I always return the weight of the actor carta2
, does anyone know why that happens?