Using global coordinate directly

This commit is contained in:
Wlowscha 2025-08-17 16:42:02 +02:00
parent c9e2a8a99f
commit 2787f2e26c
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
4 changed files with 8 additions and 10 deletions

View File

@ -77,7 +77,7 @@ export class MoveInfoOverlay extends Phaser.GameObjects.Container implements Inf
TextStyle.BATTLE_INFO,
!options?.hideBg,
);
this.desc.createMask(globalScene, this.x, this.y);
this.desc.createMask(globalScene, this.x + this.desc.x, this.y + this.desc.y);
this.add(this.desc);
// prepare the effect box

View File

@ -55,7 +55,7 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
TextStyle.BATTLE_INFO,
true,
);
this.desc.createMask(globalScene, this.x, this.y);
this.desc.createMask(globalScene, this.x + this.desc.x, this.y + this.desc.y);
this.add(this.desc);
// hide this component for now

View File

@ -10,7 +10,7 @@ This takes various coordinates:
- The x and y coordinates relative to the parent container, this is typical behavior for Phaser.GameObjects.Container.
- The width and height of the box; these are needed to create the background.
The mask is not created right away (although this is possible in principle). Instead, we have a separate function,
which takes as input the _global_ coordinates of the parent. This is necessary to correctly position the mask in the scene.
which takes as input the _global_ coordinates of scrolling text object. This is necessary to correctly position the mask in the scene.
*/
const BORDER = 8;
@ -61,12 +61,10 @@ export default class ScrollingText extends Phaser.GameObjects.Container {
this.add(this.text);
}
createMask(scene: Phaser.Scene, parentX: number, parentY: number) {
createMask(scene: Phaser.Scene, globalX: number, globalY: number) {
// Adding the mask for the scrolling effect
const visibleX = parentX < 0 ? parentX + globalScene.scaledCanvas.width : parentX;
const visibleY = parentY < 0 ? parentY + globalScene.scaledCanvas.height : parentY;
const globalMaskX = visibleX + this.x + this.offsetX;
const globalMaskY = visibleY + this.y + this.offsetY;
const globalMaskX = globalX + this.offsetX;
const globalMaskY = globalY + this.offsetY;
const visibleWidth = this.descBg.width - (this.offsetX - 2) * 2;
const visibleHeight = this.descBg.height - this.offsetY * 2;

View File

@ -919,7 +919,7 @@ export class SummaryUiHandler extends UiHandler {
abilityInfo.ability?.description!, // initial content
TextStyle.WINDOW_ALT,
);
abilityInfo.description.createMask(globalScene, 110 - 7, 90.5 - 71);
abilityInfo.description.createMask(globalScene, 110, 90.5);
profileContainer.add(abilityInfo.description);
abilityInfo.description.activate();
@ -1161,7 +1161,7 @@ export class SummaryUiHandler extends UiHandler {
"", // initial content
TextStyle.WINDOW_ALT,
);
this.moveDescription.createMask(globalScene, 112 - 2, 130 - 84);
this.moveDescription.createMask(globalScene, 112, 130);
this.movesContainer.add(this.moveDescription);
break;
}