fix: adjust Battleship UI layout and positioning
Repositions ship pips and placement buttons to prevent overlap and improve visual alignment. Updates Y-coordinates for Randomize, Clear, and Ready buttons to fit within the game area, and shifts ship labels left for better spacing.
This commit is contained in:
parent
81d3a28195
commit
651ef51633
|
|
@ -235,11 +235,11 @@ export default class BattleshipGame extends Phaser.Scene {
|
|||
const w = 26, gap = 8;
|
||||
SHIPS.forEach((spec, i) => {
|
||||
const totalH = SHIPS.length * (w + gap);
|
||||
const y = top + 26 + i * (w + gap) - totalH / 2 + totalH / 2;
|
||||
const x = cx - (spec.len * 9);
|
||||
const y = top + 46 + i * (w + gap);
|
||||
const x = cx - (spec.len * 9) - 65;
|
||||
const g = this.add.graphics().setDepth(DEPTH.ui);
|
||||
this.drawPip(g, x, y, spec, 0);
|
||||
const t = this.add.text(cx + 84, y, spec.name, {
|
||||
const t = this.add.text(cx + 9, y, spec.name, {
|
||||
fontFamily: '"Julius Sans One"', fontSize: '13px', color: COLORS.mutedHex,
|
||||
}).setOrigin(0, 0.5).setDepth(DEPTH.ui);
|
||||
pips.push({ g, t, spec, x, y });
|
||||
|
|
@ -326,13 +326,17 @@ export default class BattleshipGame extends Phaser.Scene {
|
|||
|
||||
buildPlacementUI() {
|
||||
const bx = EX / 2;
|
||||
const bottom = GAME_HEIGHT - 40;
|
||||
const readyY = bottom - 56;
|
||||
const clearY = readyY - 70;
|
||||
const randomY = clearY - 70;
|
||||
this.placementUI = [
|
||||
new Button(this, bx, 470, 'Randomize', () => this.randomizePlacement(),
|
||||
new Button(this, bx, randomY, 'Randomize', () => this.randomizePlacement(),
|
||||
{ width: 200, height: 50, fontSize: 22 }).setDepth(DEPTH.ui),
|
||||
new Button(this, bx, 540, 'Clear', () => this.clearPlacement(),
|
||||
new Button(this, bx, clearY, 'Clear', () => this.clearPlacement(),
|
||||
{ variant: 'ghost', width: 200, height: 50, fontSize: 22 }).setDepth(DEPTH.ui),
|
||||
];
|
||||
this.readyBtn = new Button(this, bx, 620, 'Ready', () => this.startBattle(),
|
||||
this.readyBtn = new Button(this, bx, readyY, 'Ready', () => this.startBattle(),
|
||||
{ width: 200, height: 56, fontSize: 26 }).setDepth(DEPTH.ui);
|
||||
this.placementUI.push(this.readyBtn);
|
||||
this.updateReadyButton();
|
||||
|
|
|
|||
Loading…
Reference in New Issue