0
I am unable to rescue the position of a Prite. I want to rescue the position of only one Prite as I do?
public class Cubos extends Actor {
Sprite azul, verde, vermelho, amarelo, cinza;
public Cubos(){
azul = new Sprite(new Texture(Gdx.files.internal("texture.png")), 160, 0, 96,96);
verde = new Sprite(new Texture(Gdx.files.internal("texture.png")), 0, 192, 64,64);
vermelho = new Sprite(new Texture(Gdx.files.internal("texture.png")), 160, 96, 96,96);
amarelo = new Sprite(new Texture(Gdx.files.internal("texture.png")), 64, 0, 96,96);
cinza = new Sprite(new Texture(Gdx.files.internal("texture.png")), 256, 0, 96,96);
}
public void act(float delta){
super.act(delta);
//Quero saber a posição X do azul ou amarelo eu faço "azul.getX() e retorna 0"
} }
If I write for ex. azul.getX()
returns "0.0" but if I write this.getX()
returns a position X do not know which color.
this.getX()
returns the position of Actor,azul.getX()
returns the position of Sprite. It is your responsibility to maintain/modify the position of Sprite depending on the position of Actor– ramaral
Hello @ramaral, the problem and when do I
azul.getX()
returns me 0.0. Why is it? Is it right to use one color for eachextends Actor
?– Emerson Barcellos
Returns
0
because that is the default position when creating an instance of Sprite. Regarding the second question it depends, as I do not know what is your purpose I can not answer. You should see/read a tutorial on Scene2d before trying to write code.– ramaral