mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 13:59:27 +02:00
Using global coordinate directly
This commit is contained in:
parent
c9e2a8a99f
commit
2787f2e26c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user