Skip to content

Commit

Permalink
TurretSelectionScreen has images which will provide a visual represen…
Browse files Browse the repository at this point in the history
…tation of the towers
  • Loading branch information
jiajiejackie committed Sep 11, 2023
1 parent ef1e65c commit 0af0866
Showing 1 changed file with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import com.csse3200.game.physics.PhysicsService;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.ServiceLocator;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import java.util.*;

public class TurretSelectionScreen extends ScreenAdapter {
Expand Down Expand Up @@ -91,6 +93,19 @@ public void clicked(InputEvent event, float x, float y) {
}

TowerType turret = turretList.get(index);

// Create a nested table for each turret
Table turretTable = new Table();
turretTable.center(); // Center the contents of the nested table

// Load the turret image
Texture turretTexture = new Texture(Gdx.files.internal(turret.getImagePath()));
Image turretImage = new Image(turretTexture);

// Add the image to the nested table
turretTable.add(turretImage).pad(10).row();

// Create a TextButton for the turret name
TextButton turretButton = new TextButton(turret.getTowerName(), skin);
turretButton.addListener(new ClickListener() {
@Override
Expand Down Expand Up @@ -124,22 +139,29 @@ public void clicked(InputEvent event, float x, float y) {

// You can change the button appearance to indicate selection
}

}
});

table.add(turretButton).pad(10); // Add padding to separate the buttons
// Add the turret name button to the nested table
turretTable.add(turretButton).center();

// Add the nested table to the main table
table.add(turretTable).pad(10).center();

// Center the contents of the main table cell
table.getCells().peek().center();
}
table.row(); // Start a new row

// Center the entire row
table.row().center();

}

// Centered the "continue" button
table.add(confirmButton).center().colspan(4).padBottom(20).row();

// Center the table within the stage
table.center();


stage.addActor(table);
table.setFillParent(true);
Gdx.input.setInputProcessor(stage);
Expand Down

0 comments on commit 0af0866

Please sign in to comment.