Libgdx pile up images

past909

I created an array of images that are all displayed onto the screen, as well as adding a click listener on each of the images in the array so each image moves to the same location on the screen. However theirs a problem where when the user touches the last image that is displayed on the screen (the last image in the array) and it moves to the specified location, the next image the user touches is sent to the back of the image the user had previously touched rather than sending it to the front of previous chosen image.

 for (int r=0;r<imagine.size;r++){
        stage.addActor(imagine.get(r));
        x+=50;
        imagine.get(r).setPosition(x,0);
        final Image img = imagine.get(r);
        imagine.get(r).addListener(new ClickListener(){
            @Override
            public void clicked(InputEvent event, float x, float y) {
                img.addAction(Actions.moveTo(90,70));
            }
        });
    }

EDIT

  @Override
public void draw(Batch batch, float parentAlpha) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.input.setInputProcessor(stage);

    stage.act();
    stage.draw();
}
past909

I didn't need to use a stack but only use the method .toFront()for the actors in my array

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive