From eff64db70e21d901376a92f473c6527d41646499 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 9 Apr 2024 13:59:46 -0400 Subject: [PATCH] Use bitmap text for modifier text for optimization --- public/fonts/item-count.png | Bin 0 -> 607 bytes public/fonts/item-count.xml | 1 + src/loading-scene.ts | 3 +++ src/modifier/modifier.ts | 22 +++++----------------- 4 files changed, 9 insertions(+), 17 deletions(-) create mode 100644 public/fonts/item-count.png create mode 100644 public/fonts/item-count.xml diff --git a/public/fonts/item-count.png b/public/fonts/item-count.png new file mode 100644 index 0000000000000000000000000000000000000000..85cfe88e902ffa2c2014e58317ec2ff68b5b0ace GIT binary patch literal 607 zcmV-l0-*hgP)Px%8A(JzR7gveR!f${APh5CBdfr9Lsrez=(9n_rqIrGQ$mS9vLqUah+>SDC=gNQ zM|z%zA1EHNQVkTS(hGZXmOp;~h_Tilg1`8DXn~1JDe_86slD5imAgMSR?K4N4ad>qOO5rVbgM+J1~c66%E3JSb0m2*31hXZS0 zX{P6SwK>En(6&mm&I1TAngf<2)^ZifDakl}r9E*@^t?RgsMyY;56f4+!`!vrCuh$h z7!SXcOXnut=MIasc^84xVh9FV7U`ZO3zX8SIV|J&=Z>Qvl(Z@wAGP_FC1BG9Xo_EW zPlse*_97bc`n5loqV!_1pv|3NtTLG`3RfT*_-Am#76{>+VA_yx#hTYSooWv@fm7&A z!xb~uYHaqffMtjX71_$0#RRDi^F;yXIV!UOpRND_kDl}PlSj>7`Iff}j@A91` z?u@BB \ No newline at end of file diff --git a/src/loading-scene.ts b/src/loading-scene.ts index c59a0224d58..5c8f879ebce 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -129,6 +129,9 @@ export class LoadingScene extends SceneBase { } }); + // Load bitmap fonts + this.load.bitmapFont('item-count', 'fonts/item-count.png', 'fonts/item-count.xml'); + // Load trainer images this.loadAtlas('trainer_m_back', 'trainer'); this.loadAtlas('trainer_m_back_pb', 'trainer'); diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 50f64c403e9..5c7d57ac974 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -183,26 +183,14 @@ export abstract class PersistentModifier extends Modifier { return container; } - getIconStackText(scene: BattleScene, virtual?: boolean): Phaser.GameObjects.Text { + getIconStackText(scene: BattleScene, virtual?: boolean): Phaser.GameObjects.BitmapText { if (this.getMaxStackCount(scene) === 1 || (virtual && !this.virtualStackCount)) return null; - const isStackMax = this.getStackCount() >= this.getMaxStackCount(scene); - const maxColor = '#f89890'; - const maxStrokeColor = '#984038'; - - if (virtual) { - const virtualText = addTextObject(scene, 27, 12, `+${this.virtualStackCount.toString()}`, TextStyle.PARTY, { fontSize: '66px', color: !isStackMax ? '#40c8f8' : maxColor }); - virtualText.setShadow(0, 0, null); - virtualText.setStroke(!isStackMax ? '#006090' : maxStrokeColor, 16) - virtualText.setOrigin(1, 0); - - return virtualText; - } - - const text = addTextObject(scene, 8, 12, this.stackCount.toString(), TextStyle.PARTY, { fontSize: '66px', color: !isStackMax ? '#f8f8f8' : maxColor }); - text.setShadow(0, 0, null); - text.setStroke('#424242', 16); + const text = scene.add.bitmapText(10, 15, 'item-count', this.stackCount.toString(), 11); + text.letterSpacing = -0.5; + if (this.getStackCount() >= this.getMaxStackCount(scene)) + text.setTint(0xf89890) text.setOrigin(0, 0); return text;