Skip to content

Commit

Permalink
Adjust text button
Browse files Browse the repository at this point in the history
  • Loading branch information
Golen87 committed Apr 25, 2024
1 parent 0fdb737 commit 518bb1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
36 changes: 6 additions & 30 deletions src/components/Deck.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GameScene, State } from "@/scenes/GameScene";
import { Button } from "./elements/Button";
import { TextButton } from "./TextButton";
import { Card } from "./Card";
import { RoundRectangle } from "./elements/RoundRectangle";
import { Color } from "@/utils/colors";
Expand All @@ -14,7 +14,7 @@ export class Deck extends Phaser.GameObjects.Container {

private cardSlots: { x: number }[];
private cards: Card[];
private button: Button;
private button: TextButton;

private activeCardIndex: number;
private activeMultiCard: boolean;
Expand All @@ -37,35 +37,11 @@ export class Deck extends Phaser.GameObjects.Container {

this.executeTimer = scene.addEvent(0, () => {});

this.button = new Button(this.scene, this.scene.CX, this.scene.H - 80);
let bx = this.scene.W - 230;
let by = this.scene.H - 110;
this.button = new TextButton(this.scene, bx, by, 260, 100, "Go!");
this.add(this.button);

let buttonBr = new RoundRectangle(this.scene, {
width: 200 + 16,
height: 80 + 16,
radius: 16 + 8,
color: Color.White,
});
this.button.add(buttonBr);

let buttonBg = new RoundRectangle(this.scene, {
width: 200,
height: 80,
radius: 16,
color: Color.Blue700,
});
this.button.add(buttonBg);

let buttonText = this.scene.addText({
size: 40,
color: "white",
text: "Go!",
});
buttonText.setOrigin(0.5);
this.button.add(buttonText);

this.button.setVisible(false);
this.button.bindInteractive(buttonBg);
this.button.on("click", this.execute, this);
}

Expand Down Expand Up @@ -189,7 +165,7 @@ export class Deck extends Phaser.GameObjects.Container {
let y = (1.5 + i) * this.scene.H;
let data = this.deck[i];
let card = new Card(this.scene, x, y, data.type, data.image, data.text);
card.setScale(0.95);
card.setScale(1.1);
this.add(card);
this.cards.push(card);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Intermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class Intermission extends Phaser.GameObjects.Container {

/* Button */

this.button = new TextButton(scene, scene.CX, scene.H - 120, 300, 120);
this.button = new TextButton(scene, scene.CX, scene.H - 120, 300, 120, "Go!");
this.add(this.button);
this.button.on("click", () => {
this.emit("restartLevel");
Expand Down
7 changes: 4 additions & 3 deletions src/components/TextButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export class TextButton extends Button {
x: number,
y: number,
width: number,
height: number
height: number,
text: string
) {
super(scene, x, y);
this.scene = scene;
Expand All @@ -35,9 +36,9 @@ export class TextButton extends Button {
this.add(background);

let buttonText = this.scene.addText({
size: 60,
size: height / 2,
color: "white",
text: "Start!",
text,
});
buttonText.setOrigin(0.5);
this.add(buttonText);
Expand Down

0 comments on commit 518bb1e

Please sign in to comment.