commit 34960a23212b292ede4872bfc9b47142891748f5 Author: Brian Fertig Date: Tue Aug 18 20:23:33 2026 -0600 Initial Commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..daee8eb --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +# Monsterplex + +A Trials-style physics driving game starring a school bus, crossed with +Snuggle Truck: land badly enough and the g-force throws your passengers off. +Built with **Phaser 4**, plain **ES6 modules**, and **no package manager**. + +## Running it + +Browsers block ES module imports over `file://`, so serve the folder with any +static file server. No install needed - this ships with Python 3: + +```sh +python3 -m http.server 8000 +``` + +Then open `http://localhost:8000/`. + +## Controls + +- **Arrow Up / W** - throttle +- **Arrow Down / S** - brake / reverse +- **Arrow Left/Right / A/D** - lean the bus left/right + +Land smoothly or the g-force throws a kid off the bus. Lose all of them and +the level fails. + +## Project layout + +``` +index.html entry point, import map -> vendor/phaser.esm.js +vendor/phaser.esm.js vendored local copy of Phaser 4 (see below) +src/main.js Phaser.Game config + scene list +src/config.js every tunable constant (physics, g-force threshold, camera, ...) +src/scenes/ Boot -> Preload -> Intro -> MainMenu -> LevelSelect -> Play -> LevelComplete/LevelFailed +src/entities/ Bus, Kid, Terrain +src/systems/ GForceMonitor, KidManager, InputController, CameraRig +src/data/levels/ the 3 hand-authored levels +src/util/ asset manifest, placeholder-texture generator, localStorage progress, small UI helper +assets/ where real art goes (see manifest below) - currently empty +``` + +## Adding real art + +No art assets exist yet - `src/util/assetManifest.js` lists every image the +game expects, and `PreloadScene` falls back to a synthesized colored +placeholder (via `src/util/placeholderTextures.js`) for anything missing. +**Drop a real PNG at the exact path below and it's picked up automatically - +no code changes needed.** + +| key | path | size | notes | +|---|---|---|---| +| `bus_chassis` | `assets/sprites/bus_chassis.png` | 170x64 | scaled to this size regardless of source resolution | +| `bus_wheel` | `assets/sprites/bus_wheel.png` | 52x52 | used for both wheels | +| `kid_idle` | `assets/sprites/kid_idle.png` | 28x28 | passenger while aboard | +| `kid_ejected` | `assets/sprites/kid_ejected.png` | 28x28 | passenger after being thrown off | +| `bg_far` | `assets/backgrounds/bg_far.png` | 256x540 | tiled, slowest parallax layer | +| `bg_mid` | `assets/backgrounds/bg_mid.png` | 256x540 | tiled, mid parallax layer | +| `bg_near` | `assets/backgrounds/bg_near.png` | 256x540 | tiled, fastest parallax layer | +| `icon_kid` | `assets/ui/icon_kid.png` | 24x24 | HUD "kids aboard" icon | +| `favicon` | `assets/favicon.png` | 32x32 | browser tab icon | + +## Tuning the feel + +Everything worth tweaking lives in `src/config.js`, notably: + +- `GFORCE.ejectThresholdG` - how hard a landing has to be before a kid is + thrown off. Not physically derived - tune by playtesting. +- `GFORCE.gracePeriodMs` / `ejectCooldownMs` - ignore-window after level + start/restart, and minimum time between two ejections so one bad landing + doesn't empty the whole bus at once. +- `BUS.*` - suspension stiffness/damping, wheel friction, throttle/lean torque + and their clamps. + +Set `DEBUG = true` in `config.js` to show a live g-force readout and Matter's +physics debug overlay in `PlayScene`. + +## Phaser 4 loading + +Phaser is vendored locally at `vendor/phaser.esm.js` (downloaded once from +jsDelivr's CDN build) and wired up via an import map in `index.html`, so +every source file just does `import Phaser from 'phaser'` like a normal npm +project would - the only place that knows about the vendored file is that one +import map line. This keeps the project working fully offline with no +runtime dependency on a third-party CDN staying up. + +To upgrade Phaser later: download a newer `phaser.esm.js` build over +`vendor/phaser.esm.js` and re-verify `Bus.js` against the Matter physics +Factory API in the new file (grep for `class Factory` under the Matter +section). diff --git a/assets/sprites/bus_chassis.png b/assets/sprites/bus_chassis.png new file mode 100644 index 0000000..fd3b739 Binary files /dev/null and b/assets/sprites/bus_chassis.png differ diff --git a/assets/sprites/bus_wheel.png b/assets/sprites/bus_wheel.png new file mode 100644 index 0000000..4421e0f Binary files /dev/null and b/assets/sprites/bus_wheel.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..54f4a78 --- /dev/null +++ b/index.html @@ -0,0 +1,42 @@ + + + + + +Monsterplex + + + + + +
+ + + diff --git a/sprites.md b/sprites.md new file mode 100644 index 0000000..aedfda8 --- /dev/null +++ b/sprites.md @@ -0,0 +1,100 @@ +# Adding real art + +Nothing in the code needs to change to swap in real art. `src/util/assetManifest.js` +lists every image the game expects, with an exact `path`. `PreloadScene` tries to +load each one; if the file doesn't exist (or fails to load), it falls back to a +synthesized colored placeholder shape instead. **Drop a real PNG at the exact path +below, refresh the page, and it's used automatically.** + +## Where files go + +All paths are relative to the project root (`/home/brianfertig/git/monsterplex/`). +The folders already exist and are currently empty. + +| key | path | size used in-game | shape | notes | +|---|---|---|---|---| +| `bus_chassis` | `assets/sprites/bus_chassis.png` | 340 x 128 | rectangle | see "Bus" below | +| `bus_wheel` | `assets/sprites/bus_wheel.png` | 104 x 104 | circle | one image, used for both wheels | +| `kid_idle` | `assets/sprites/kid_idle.png` | 56 x 56 | circle | passenger while aboard the bus | +| `kid_ejected` | `assets/sprites/kid_ejected.png` | 56 x 56 | circle | passenger after being thrown off | +| `bg_far` | `assets/backgrounds/bg_far.png` | tiled, 512 x 1080 native | - | slowest-scrolling parallax layer (sky/distant) | +| `bg_mid` | `assets/backgrounds/bg_mid.png` | tiled, 512 x 1080 native | - | mid-speed parallax layer | +| `bg_near` | `assets/backgrounds/bg_near.png` | tiled, 512 x 1080 native | - | fastest-scrolling parallax layer (closest) | +| `icon_kid` | `assets/ui/icon_kid.png` | 48 x 48 | - | small HUD "kids aboard" icon, top-left | +| `favicon` | `assets/favicon.png` | 32 x 32 | - | browser tab icon - see caveat below | + +"Size used in-game" is the size the game actually displays the image at +(`setDisplaySize`), **not** a requirement on the source file's resolution - see +"Resolution" below. + +These numbers are the game's current 1920x1080 resolution (`WORLD_SCALE = 2` +in `src/config.js`) - if that changes again, every size in this table changes +with it (same ratios, just re-derive from that one constant). + +## Bus + +- `bus_chassis.png` and `bus_wheel.png`, transparent background (PNG alpha). +- **The bus always faces right** (nose/front toward positive x - the direction + it drives at level start) and there's no left/right flip when reversing, so + draw the chassis facing right. +- The chassis's rectangle *is* the physics hitbox (with rounded corners baked + in by the physics engine, not the art). Keep the bus's silhouette roughly + filling a 340x128 box so the visual matches where it actually collides. +- `bus_wheel.png` is used for **both** wheels (front and rear) - same image, + no separate left/right variant needed. It's a real physics body, so it + visually spins as the bus drives; a plain hubcap/circle reads better at + speed than fine detail. +- If you want a bus with different proportions (longer, taller, etc.) than + 340x128, tell me the size you want art at - that number is also the physics + body size in `src/config.js` (`BUS.chassisWidth`/`chassisHeight`), so it + needs a matching code change, not just a differently-shaped image. + +## Kids + +- `kid_idle.png` (aboard) and `kid_ejected.png` (mid-air after being thrown + off) - two separate images, swapped automatically when a kid is ejected. +- Physics shape is a circle, but the *image* itself renders as a full square + at 56x56 - draw the character centered in a square canvas with transparent + padding around them rather than filling every corner, or they'll look like + they're poking out past their own collision circle. +- `kid_ejected` is a good place to show some "yikes" energy (arms out, + startled face, etc.) since it only appears for the ~2 seconds after a kid + gets thrown clear. + +## Parallax backgrounds + +- `bg_far` / `bg_mid` / `bg_near` are rendered as horizontally **tiling** + strips (`TileSprite`), not single stretched images - whatever you supply + repeats sideways as the camera scrolls. +- Make the **left and right edges match** so the seam is invisible when it + tiles (or design something patternable, like scattered clouds/hills on a + transparent background). +- far/mid/near are layered back-to-front and scroll at different speeds for + depth (far moves slowest, near moves fastest) - a plain sky for far, hills + or treeline silhouettes for mid, and closer foreground detail for near + works well. +- Native resolution isn't locked to 512x1080 the way the bus/kid sprites are - + a wider or taller source image just changes how often the tile repeats, so + use whatever gives a clean seamless loop. + +## Favicon + +- `favicon.png` is the one asset **without** a placeholder fallback for its + actual purpose - the browser tab icon comes from a plain `` tag in + `index.html`, not from Phaser's loader, so until a real file exists at + `assets/favicon.png` the browser just shows its default icon (nothing + broken, just nothing shown). + +## Resolution + +Supply art at the "size used in-game" from the table above, or a clean +multiple of it (2x/3x) for a crisper look on high-DPI screens - everything +gets scaled to the table's size regardless of the source file's actual pixel +dimensions, so it won't come in stretched or huge, but a very different +aspect ratio than the target box will get squashed/stretched to fit. + +## Testing + +Just refresh the browser tab after dropping files into `assets/` - no build +step, no server restart needed (unless the static server itself isn't +running yet, in which case see `README.md`). diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..aea6131 --- /dev/null +++ b/src/config.js @@ -0,0 +1,114 @@ +// Every spatial (pixel) constant in this file and in src/data/levels/*.js is +// multiplied by WORLD_SCALE, so the whole game - canvas, physics bodies, +// terrain, UI - resizes together. Change this one number to rescale it again. +export const WORLD_SCALE = 2; // 960x540 base design -> 1920x1080 + +export const GAME_WIDTH = 960 * WORLD_SCALE; +export const GAME_HEIGHT = 540 * WORLD_SCALE; + +// Set true to show live g-force / debug readouts during PlayScene. +export const DEBUG = false; + +export const STORAGE_KEY = 'monsterplex.progress.v1'; + +// Matter runs Phaser's default fixed 60Hz step. +export const PHYSICS_TIMESTEP_SECONDS = 1 / 60; + +export const BUS = { + chassisWidth: 170 * WORLD_SCALE, + chassisHeight: 64 * WORLD_SCALE, + + // Measured directly from assets/sprites/bus_chassis.png's baked-in wheel + // wells (it's a real photo bus - long rear overhang, short front hood, so + // the axles are NOT symmetric around the chassis center). Offsets are from + // the chassis center; re-measure these if bus_chassis.png is replaced. + wheelRadius: 17 * WORLD_SCALE, + rearWheelOffsetX: -35 * WORLD_SCALE, + frontWheelOffsetX: 64 * WORLD_SCALE, + // Where the wheel's CENTER rests at equilibrium - this is the measured + // wheel-well position itself, not an attachment point the wheel then + // hangs further below (that was the placeholder-art version's model, + // before there was real art dictating exactly where the wheel belongs). + wheelRestOffsetY: 22 * WORLD_SCALE, + // Horizontal spread between the two suspension links each wheel hangs + // from (a "wishbone") - a single point-to-point constraint can't resist + // sideways drift at all (it's radially symmetric), so each wheel is held + // by two constraints spread by this much, which resists side-to-side + // wander while still allowing the wheel to compress/extend vertically. + axleSpread: 6 * WORLD_SCALE, + + maxSeats: 5, + + // Density/friction/stiffness/damping are dimensionless ratios, not pixel + // distances - they don't scale with WORLD_SCALE. + chassisDensity: 0.0015, + chassisFriction: 0.4, + chassisFrictionAir: 0.01, + + wheelDensity: 0.004, + wheelFriction: 0.9, + wheelFrictionStatic: 1.4, + // Lowered a lot from the original 0.02 - that was quietly eating most of + // the wheel's spin-up each second (it's a per-tick multiplicative decay, + // so 0.02 was burning off roughly a third of angular velocity per second) + // and was the main reason the bus felt sluggish rather than Trials-fast. + wheelFrictionAir: 0.008, + // Some bounce on landing, not just suspension absorbing everything. + wheelRestitution: 0.3, + + // Softer and less damped than before - more travel, and lets it actually + // oscillate (bounce) instead of settling immediately - "more shocks." + suspensionStiffness: 0.45, + suspensionDamping: 0.08, + // How far the wheel can move up/down from wheelRestOffsetY. This will + // visibly pop the wheel outside its wheel well on a hard landing - that's + // the tradeoff for real suspension travel/bounce instead of a stiff ride. + suspensionTravel: 12 * WORLD_SCALE, + + // Angular velocities/torque steps are rotational (radians), not linear + // pixel distances, so they're left unscaled - wheel radius already scaled, + // so linear surface speed (angularVelocity * radius) scales automatically. + // Pushed way up from the original values for Trials/Snuggle-Truck-style + // speed - the old numbers made the bus crawl. + maxWheelAngularVelocity: 5, + driveTorque: 0.6, + brakeTorque: 0.4, + maxBrakeAngularVelocity: 3.5, + + // Bumped up to stay responsive at the new higher speed - sluggish lean + // control would feel wrong on a bus that's now moving quickly. + maxLeanAngularVelocity: 0.13, + leanTorqueStep: 0.018, +}; + +export const GFORCE = { + // Scaled with WORLD_SCALE so "meters" keeps the same real-world meaning + // relative to the bus, and ejectThresholdG doesn't need re-tuning. + pixelsPerMeter: 50 * WORLD_SCALE, + ejectThresholdG: 6, // primary tuning knob - not physically derived, tune by playtesting + gracePeriodMs: 500, + ejectImpulseMagnitude: 0.03 * WORLD_SCALE, + // A single hard landing can stay above threshold for several consecutive + // physics ticks; without a cooldown that would eject several kids from one + // impact instead of one. Debounces ejections to one per impact. + ejectCooldownMs: 400, +}; + +export const KID = { + radius: 14 * WORLD_SCALE, + density: 0.001, + friction: 0.6, + seatStiffness: 0.22, + seatDamping: 0.1, + seatLength: 4 * WORLD_SCALE, + settleTimeMs: 2000, +}; + +export const CAMERA = { + lerpX: 0.1, + lerpY: 0.1, + deadzoneWidth: 220 * WORLD_SCALE, + deadzoneHeight: 140 * WORLD_SCALE, +}; + +export const TERRAIN_DEPTH = 400 * WORLD_SCALE; diff --git a/src/data/levels/index.js b/src/data/levels/index.js new file mode 100644 index 0000000..0e7f300 --- /dev/null +++ b/src/data/levels/index.js @@ -0,0 +1,15 @@ +import level01 from './level01.js'; +import level02 from './level02.js'; +import level03 from './level03.js'; + +export const LEVELS = [level01, level02, level03]; + +export function getLevelById(id) { + return LEVELS.find((level) => level.id === id); +} + +export function getNextLevelId(id) { + const index = LEVELS.findIndex((level) => level.id === id); + if (index === -1 || index === LEVELS.length - 1) return null; + return LEVELS[index + 1].id; +} diff --git a/src/data/levels/level01.js b/src/data/levels/level01.js new file mode 100644 index 0000000..9c16f29 --- /dev/null +++ b/src/data/levels/level01.js @@ -0,0 +1,20 @@ +import { generateWave } from './terrainHelpers.js'; +import { WORLD_SCALE } from '../../config.js'; + +const END_X = 3600 * WORLD_SCALE; +const BASE_Y = 420 * WORLD_SCALE; + +const points = generateWave(-200 * WORLD_SCALE, END_X, 80 * WORLD_SCALE, BASE_Y, 30 * WORLD_SCALE, 260 * WORLD_SCALE); + +export default { + id: 'level01', + name: 'First Hills', + description: 'Gentle rolling hills - learn to drive and lean.', + kidsAboard: 5, + startPosition: { x: 100 * WORLD_SCALE, y: 350 * WORLD_SCALE }, + startAngle: 0, + terrain: [{ points }], + obstacles: [], + goal: { x: END_X - 120 * WORLD_SCALE, y: BASE_Y - 120 * WORLD_SCALE, width: 140 * WORLD_SCALE, height: 320 * WORLD_SCALE }, + cameraBounds: { x: -300 * WORLD_SCALE, y: 0, width: END_X + 700 * WORLD_SCALE, height: 1000 * WORLD_SCALE }, +}; diff --git a/src/data/levels/level02.js b/src/data/levels/level02.js new file mode 100644 index 0000000..d6ec729 --- /dev/null +++ b/src/data/levels/level02.js @@ -0,0 +1,24 @@ +import { generateWave, withRamp } from './terrainHelpers.js'; +import { WORLD_SCALE } from '../../config.js'; + +const RUNWAY_END_X = 1850 * WORLD_SCALE; +const LANDING_START_X = 2200 * WORLD_SCALE; +const END_X = 3900 * WORLD_SCALE; + +const runway = generateWave(-200 * WORLD_SCALE, RUNWAY_END_X, 60 * WORLD_SCALE, 420 * WORLD_SCALE, 10 * WORLD_SCALE, 500 * WORLD_SCALE); +withRamp(runway, 1500 * WORLD_SCALE, RUNWAY_END_X, -170 * WORLD_SCALE); // launch ramp climbing up to the jump-off edge + +const landing = generateWave(LANDING_START_X, END_X, 80 * WORLD_SCALE, 460 * WORLD_SCALE, 15 * WORLD_SCALE, 400 * WORLD_SCALE); + +export default { + id: 'level02', + name: 'Big Air', + description: 'Clear the gap and land level, or the kids pay for it.', + kidsAboard: 3, + startPosition: { x: 100 * WORLD_SCALE, y: 350 * WORLD_SCALE }, + startAngle: 0, + terrain: [{ points: runway }, { points: landing }], + obstacles: [], + goal: { x: END_X - 120 * WORLD_SCALE, y: 340 * WORLD_SCALE, width: 140 * WORLD_SCALE, height: 320 * WORLD_SCALE }, + cameraBounds: { x: -300 * WORLD_SCALE, y: 0, width: END_X + 700 * WORLD_SCALE, height: 1000 * WORLD_SCALE }, +}; diff --git a/src/data/levels/level03.js b/src/data/levels/level03.js new file mode 100644 index 0000000..e19bdd2 --- /dev/null +++ b/src/data/levels/level03.js @@ -0,0 +1,41 @@ +import { WORLD_SCALE } from '../../config.js'; + +// Hand-tuned profile: flat approach -> steep valley drop -> steep climb out -> +// a long stretch of tight, fast bumps that punish sloppy lean control. +function buildPoints() { + const step = 60 * WORLD_SCALE; + const points = []; + for (let x = -200 * WORLD_SCALE; x <= 3900 * WORLD_SCALE; x += step) { + let y; + if (x < 1200 * WORLD_SCALE) { + y = 420 * WORLD_SCALE + Math.sin(x / (500 * WORLD_SCALE)) * 10 * WORLD_SCALE; + } else if (x < 1500 * WORLD_SCALE) { + y = 420 * WORLD_SCALE + 220 * WORLD_SCALE * ((x - 1200 * WORLD_SCALE) / (300 * WORLD_SCALE)); + } else if (x < 1650 * WORLD_SCALE) { + y = 640 * WORLD_SCALE; + } else if (x < 1950 * WORLD_SCALE) { + y = 640 * WORLD_SCALE - 260 * WORLD_SCALE * ((x - 1650 * WORLD_SCALE) / (300 * WORLD_SCALE)); + } else if (x < 3650 * WORLD_SCALE) { + y = 380 * WORLD_SCALE + Math.sin(x / (150 * WORLD_SCALE)) * 45 * WORLD_SCALE; + } else { + y = 380 * WORLD_SCALE; + } + points.push({ x, y: Math.round(y) }); + } + return points; +} + +const END_X = 3900 * WORLD_SCALE; + +export default { + id: 'level03', + name: 'Tight Squeeze', + description: 'A steep valley and a long run of sharp bumps - lean early, lean often.', + kidsAboard: 4, + startPosition: { x: 100 * WORLD_SCALE, y: 350 * WORLD_SCALE }, + startAngle: 0, + terrain: [{ points: buildPoints() }], + obstacles: [], + goal: { x: END_X - 120 * WORLD_SCALE, y: 260 * WORLD_SCALE, width: 140 * WORLD_SCALE, height: 400 * WORLD_SCALE }, + cameraBounds: { x: -300 * WORLD_SCALE, y: 0, width: END_X + 700 * WORLD_SCALE, height: 1000 * WORLD_SCALE }, +}; diff --git a/src/data/levels/terrainHelpers.js b/src/data/levels/terrainHelpers.js new file mode 100644 index 0000000..314f58b --- /dev/null +++ b/src/data/levels/terrainHelpers.js @@ -0,0 +1,31 @@ +// Generates a hand-tunable wavy ground polyline: a human picks the +// amplitude/frequency knobs per level, this just avoids typing out every point. +export function generateWave(startX, endX, step, baseY, amplitude, frequency, phase = 0) { + const points = []; + for (let x = startX; x <= endX; x += step) { + const y = baseY + Math.sin(x / frequency + phase) * amplitude; + points.push({ x, y: Math.round(y) }); + } + return points; +} + +// Splices a straight ramp of the given rise (positive = downhill to the right) +// between two x positions into an existing point array, in place. +export function withRamp(points, fromX, toX, rise) { + const from = points.find((p) => p.x >= fromX) || points[points.length - 1]; + const to = points.find((p) => p.x >= toX) || points[points.length - 1]; + const fromIndex = points.indexOf(from); + const toIndex = points.indexOf(to); + if (toIndex <= fromIndex) return points; + const baseY = from.y; + for (let i = fromIndex; i <= toIndex; i++) { + const t = (points[i].x - from.x) / (to.x - from.x); + points[i].y = Math.round(baseY + rise * t); + } + // flatten everything after the ramp to the new height + const newY = points[toIndex].y; + for (let i = toIndex + 1; i < points.length; i++) { + points[i].y = newY; + } + return points; +} diff --git a/src/entities/Bus.js b/src/entities/Bus.js new file mode 100644 index 0000000..ebb27a5 --- /dev/null +++ b/src/entities/Bus.js @@ -0,0 +1,138 @@ +import Phaser from 'phaser'; +import { BUS } from '../config.js'; + +// Builds the bus as a chassis + two wheel Matter Image bodies, each wheel +// held by a "wishbone" - two suspension constraints instead of one - rather +// than Phaser's built-in Factory.car() - car()'s axle constraints are rigid +// pins (stiffness 1, length 0, verified against the shipped Phaser 4 build) +// with no vertical give, which is too harsh for a bus that needs real +// suspension travel to absorb bumps. +export default class Bus { + constructor(scene, x, y, angle = 0) { + this.scene = scene; + const matter = scene.matter; + + this.group = matter.world.nextGroup(true); + + // The anchor sits suspensionTravel above where the wheel actually rests, + // so the spring pulling the wheel out to its full constraint length is + // what lands it exactly on wheelRestOffsetY (anchorY + travel = restY), + // while still leaving suspensionTravel of compress/droop room. + const anchorY = BUS.wheelRestOffsetY - BUS.suspensionTravel; + // The wheel doesn't hang straight down from a single point (that point + // is split into two, spread by axleSpread), so the constraint's target + // length is the hypotenuse to the spread anchor, not just the vertical + // drop - otherwise the wheel would spawn pulled taut at an angle instead + // of hanging level, snapping into place on the first physics step. + const constraintLength = Math.hypot(BUS.axleSpread, BUS.suspensionTravel); + + this.chassis = matter.add.image(x, y, 'bus_chassis', null, { + shape: { type: 'rectangle', width: BUS.chassisWidth, height: BUS.chassisHeight }, + chamfer: { radius: BUS.chassisHeight * 0.35 }, + density: BUS.chassisDensity, + friction: BUS.chassisFriction, + frictionAir: BUS.chassisFrictionAir, + collisionFilter: { group: this.group }, + }); + this.chassis.setDisplaySize(BUS.chassisWidth, BUS.chassisHeight); + this.chassis.setAngle(Phaser.Math.RadToDeg(angle)); + + const wheelY = y + BUS.wheelRestOffsetY; + this.wheelRear = this._createWheel(x + BUS.rearWheelOffsetX, wheelY); + this.wheelFront = this._createWheel(x + BUS.frontWheelOffsetX, wheelY); + + this.wheelRearLinks = this._attachWishbone(this.wheelRear, BUS.rearWheelOffsetX, anchorY, constraintLength); + this.wheelFrontLinks = this._attachWishbone(this.wheelFront, BUS.frontWheelOffsetX, anchorY, constraintLength); + + this.seatOffsets = this._buildSeatOffsets(); + } + + // A single point-to-point constraint is radially symmetric - it can only + // resist the wheel drifting away in general, not sideways specifically. + // Two constraints anchored on either side of the true axle position (both + // to the same wheel center) form a narrow wishbone: moving the wheel + // sideways stretches one link and slackens the other, which the springs + // resist, while moving straight down lengthens both links symmetrically + // and is barely resisted - so the wheel is free to bob vertically but + // held from wandering left/right under its axle. + _attachWishbone(wheel, offsetX, anchorY, length) { + const matter = this.scene.matter; + const options = (anchorX) => ({ + pointA: { x: anchorX, y: anchorY }, + pointB: { x: 0, y: 0 }, + damping: BUS.suspensionDamping, + }); + + return [ + matter.add.constraint(this.chassis, wheel, length, BUS.suspensionStiffness, options(offsetX - BUS.axleSpread)), + matter.add.constraint(this.chassis, wheel, length, BUS.suspensionStiffness, options(offsetX + BUS.axleSpread)), + ]; + } + + _createWheel(x, y) { + const wheel = this.scene.matter.add.image(x, y, 'bus_wheel', null, { + shape: { type: 'circle', radius: BUS.wheelRadius }, + density: BUS.wheelDensity, + friction: BUS.wheelFriction, + frictionStatic: BUS.wheelFrictionStatic, + frictionAir: BUS.wheelFrictionAir, + restitution: BUS.wheelRestitution, + collisionFilter: { group: this.group }, + }); + wheel.setDisplaySize(BUS.wheelRadius * 2, BUS.wheelRadius * 2); + return wheel; + } + + _buildSeatOffsets() { + const offsets = []; + const margin = BUS.chassisWidth * 0.32; + for (let i = 0; i < BUS.maxSeats; i++) { + const t = BUS.maxSeats === 1 ? 0 : (i / (BUS.maxSeats - 1)) * 2 - 1; + offsets.push({ x: t * margin, y: -BUS.chassisHeight * 0.1 }); + } + return offsets; + } + + // intent: { throttle: -1|0|1, leanLeft: bool, leanRight: bool } + applyIntent(intent) { + const wheelBody = this.wheelRear.body; + + if (intent.throttle > 0) { + const next = Phaser.Math.Clamp( + wheelBody.angularVelocity + BUS.driveTorque, + -BUS.maxWheelAngularVelocity, + BUS.maxWheelAngularVelocity + ); + this.wheelRear.setAngularVelocity(next); + } else if (intent.throttle < 0) { + const next = Phaser.Math.Clamp( + wheelBody.angularVelocity - BUS.brakeTorque, + -BUS.maxBrakeAngularVelocity, + BUS.maxBrakeAngularVelocity + ); + this.wheelRear.setAngularVelocity(next); + } + + const chassisBody = this.chassis.body; + if (intent.leanLeft && !intent.leanRight) { + const next = Phaser.Math.Clamp( + chassisBody.angularVelocity - BUS.leanTorqueStep, + -BUS.maxLeanAngularVelocity, + BUS.maxLeanAngularVelocity + ); + this.chassis.setAngularVelocity(next); + } else if (intent.leanRight && !intent.leanLeft) { + const next = Phaser.Math.Clamp( + chassisBody.angularVelocity + BUS.leanTorqueStep, + -BUS.maxLeanAngularVelocity, + BUS.maxLeanAngularVelocity + ); + this.chassis.setAngularVelocity(next); + } + } + + getSeatWorldPosition(seatIndex) { + const seat = this.seatOffsets[seatIndex]; + return { x: this.chassis.x + seat.x, y: this.chassis.y + seat.y }; + } +} diff --git a/src/entities/Kid.js b/src/entities/Kid.js new file mode 100644 index 0000000..e932680 --- /dev/null +++ b/src/entities/Kid.js @@ -0,0 +1,69 @@ +import Phaser from 'phaser'; +import { GFORCE, KID } from '../config.js'; + +export default class Kid { + constructor(scene, bus, seatIndex) { + this.scene = scene; + this.bus = bus; + this.seatIndex = seatIndex; + this.state = 'aboard'; // aboard | ejected | settled + + const seat = bus.seatOffsets[seatIndex]; + const worldPos = bus.getSeatWorldPosition(seatIndex); + + this.image = scene.matter.add.image(worldPos.x, worldPos.y, 'kid_idle', null, { + shape: { type: 'circle', radius: KID.radius }, + density: KID.density, + friction: KID.friction, + collisionFilter: { group: bus.group }, + }); + this.image.setDisplaySize(KID.radius * 2, KID.radius * 2); + + this.seatConstraint = scene.matter.add.constraint(bus.chassis, this.image, KID.seatLength, KID.seatStiffness, { + pointA: seat, + pointB: { x: 0, y: 0 }, + damping: KID.seatDamping, + }); + + this._settleAt = 0; + } + + eject(chassisVelocity, gForce) { + if (this.state !== 'aboard') return; + this.state = 'ejected'; + + this.scene.matter.world.removeConstraint(this.seatConstraint, true); + this.seatConstraint = null; + + // Neutral group re-enables normal category/mask collision (was sharing + // the bus's non-colliding group while seated). + this.image.body.collisionFilter.group = 0; + this.image.setTexture('kid_ejected'); + + const speed = Math.hypot(chassisVelocity.x, chassisVelocity.y) || 1; + const dirX = chassisVelocity.x / speed; + const dirY = chassisVelocity.y / speed; + const severity = Phaser.Math.Clamp(gForce / GFORCE.ejectThresholdG, 1, 3); + + this.image.applyForce({ + x: dirX * GFORCE.ejectImpulseMagnitude * severity + (Math.random() - 0.5) * GFORCE.ejectImpulseMagnitude * 0.5, + y: dirY * GFORCE.ejectImpulseMagnitude * severity - GFORCE.ejectImpulseMagnitude * 0.4, + }); + + this._settleAt = this.scene.time.now + KID.settleTimeMs; + } + + update(time) { + if (this.state === 'ejected' && time >= this._settleAt) { + this.state = 'settled'; + } + } + + destroy() { + if (this.seatConstraint) { + this.scene.matter.world.removeConstraint(this.seatConstraint, true); + this.seatConstraint = null; + } + this.image.destroy(); + } +} diff --git a/src/entities/Terrain.js b/src/entities/Terrain.js new file mode 100644 index 0000000..75dca85 --- /dev/null +++ b/src/entities/Terrain.js @@ -0,0 +1,75 @@ +import { TERRAIN_DEPTH, WORLD_SCALE } from '../config.js'; + +// Ground is stored as left-to-right surface polylines (easy to hand-author), +// each converted into a chain of angled static rectangle bodies extruded +// downward - simpler and more robust than concave polygon decomposition. +export default class Terrain { + constructor(scene, levelData) { + this.scene = scene; + this.bodies = []; + this.graphics = scene.add.graphics(); + + for (const segment of levelData.terrain) { + this._buildSegment(segment.points); + this._drawSegment(segment.points); + } + + if (levelData.obstacles) { + for (const obstacle of levelData.obstacles) { + this._buildObstacle(obstacle); + } + } + } + + _buildSegment(points) { + for (let i = 0; i < points.length - 1; i++) { + const a = points[i]; + const b = points[i + 1]; + const dx = b.x - a.x; + const dy = b.y - a.y; + const length = Math.hypot(dx, dy); + if (length < 1) continue; + + const angle = Math.atan2(dy, dx); + const midX = (a.x + b.x) / 2; + const midY = (a.y + b.y) / 2 + (TERRAIN_DEPTH / 2) * Math.cos(angle); + + const body = this.scene.matter.add.rectangle(midX, midY, length, TERRAIN_DEPTH, { + isStatic: true, + angle, + friction: 0.95, + label: 'terrain', + }); + this.bodies.push(body); + } + } + + _buildObstacle(obstacle) { + if (obstacle.type !== 'ramp') return; + const body = this.scene.matter.add.rectangle(obstacle.x, obstacle.y, obstacle.width, obstacle.height, { + isStatic: true, + angle: obstacle.angle || 0, + friction: 0.95, + label: 'terrain', + }); + this.bodies.push(body); + } + + _drawSegment(points) { + const g = this.graphics; + g.fillStyle(0x3c8f3c, 1); + g.beginPath(); + g.moveTo(points[0].x, points[0].y + TERRAIN_DEPTH); + for (const p of points) g.lineTo(p.x, p.y); + const last = points[points.length - 1]; + g.lineTo(last.x, last.y + TERRAIN_DEPTH); + g.closePath(); + g.fillPath(); + + g.lineStyle(4 * WORLD_SCALE, 0x2c6e2c, 1); + g.beginPath(); + g.moveTo(points[0].x, points[0].y); + for (const p of points) g.lineTo(p.x, p.y); + g.strokePath(); + } +} diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..801a969 --- /dev/null +++ b/src/main.js @@ -0,0 +1,44 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, DEBUG, WORLD_SCALE } from './config.js'; +import BootScene from './scenes/BootScene.js'; +import PreloadScene from './scenes/PreloadScene.js'; +import IntroScene from './scenes/IntroScene.js'; +import MainMenuScene from './scenes/MainMenuScene.js'; +import LevelSelectScene from './scenes/LevelSelectScene.js'; +import PlayScene from './scenes/PlayScene.js'; +import LevelCompleteScene from './scenes/LevelCompleteScene.js'; +import LevelFailedScene from './scenes/LevelFailedScene.js'; + +window.__PHASER_GAME__ = new Phaser.Game({ + type: Phaser.AUTO, + parent: 'game-container', + width: GAME_WIDTH, + height: GAME_HEIGHT, + backgroundColor: '#8fc7e8', + physics: { + default: 'matter', + matter: { + // Gravity is a constant absolute px/s^2 regardless of body size (it's + // mass-proportional force, so acceleration = force/mass is scale- + // independent) - has to scale with WORLD_SCALE or a 2x-bigger world + // falls proportionally slower (everything free-falls for longer to + // cover the now-doubled pixel distances). + gravity: { x: 0, y: 1 * WORLD_SCALE }, + debug: DEBUG, + }, + }, + scale: { + mode: Phaser.Scale.FIT, + autoCenter: Phaser.Scale.CENTER_BOTH, + }, + scene: [ + BootScene, + PreloadScene, + IntroScene, + MainMenuScene, + LevelSelectScene, + PlayScene, + LevelCompleteScene, + LevelFailedScene, + ], +}); diff --git a/src/scenes/BootScene.js b/src/scenes/BootScene.js new file mode 100644 index 0000000..394cf2c --- /dev/null +++ b/src/scenes/BootScene.js @@ -0,0 +1,11 @@ +import Phaser from 'phaser'; + +export default class BootScene extends Phaser.Scene { + constructor() { + super('Boot'); + } + + create() { + this.scene.start('Preload'); + } +} diff --git a/src/scenes/IntroScene.js b/src/scenes/IntroScene.js new file mode 100644 index 0000000..b9fe512 --- /dev/null +++ b/src/scenes/IntroScene.js @@ -0,0 +1,44 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, WORLD_SCALE } from '../config.js'; + +export default class IntroScene extends Phaser.Scene { + constructor() { + super('Intro'); + } + + create() { + this.cameras.main.setBackgroundColor('#8fc7e8'); + + this.add.text(GAME_WIDTH / 2, GAME_HEIGHT / 2 - 60 * WORLD_SCALE, 'MONSTERPLEX', { + fontFamily: 'monospace', + fontSize: `${52 * WORLD_SCALE}px`, + color: '#1a1f29', + fontStyle: 'bold', + }).setOrigin(0.5); + + this.add.text(GAME_WIDTH / 2, GAME_HEIGHT / 2, 'a school bus survival ride', { + fontFamily: 'monospace', + fontSize: `${18 * WORLD_SCALE}px`, + color: '#2255aa', + }).setOrigin(0.5); + + const prompt = this.add.text(GAME_WIDTH / 2, GAME_HEIGHT - 90 * WORLD_SCALE, 'Press any key or tap to continue', { + fontFamily: 'monospace', + fontSize: `${16 * WORLD_SCALE}px`, + color: '#1a1f29', + }).setOrigin(0.5); + + this.tweens.add({ + targets: prompt, + alpha: { from: 1, to: 0.2 }, + duration: 700, + yoyo: true, + repeat: -1, + }); + + this._advance = () => this.scene.start('MainMenu'); + this.input.keyboard.once('keydown', this._advance); + this.input.once('pointerdown', this._advance); + this.time.delayedCall(6000, this._advance); + } +} diff --git a/src/scenes/LevelCompleteScene.js b/src/scenes/LevelCompleteScene.js new file mode 100644 index 0000000..c2d6456 --- /dev/null +++ b/src/scenes/LevelCompleteScene.js @@ -0,0 +1,61 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, WORLD_SCALE } from '../config.js'; +import { getLevelById, getNextLevelId } from '../data/levels/index.js'; +import { markLevelComplete } from '../util/progress.js'; +import { createButton } from '../util/ui.js'; + +export default class LevelCompleteScene extends Phaser.Scene { + constructor() { + super('LevelComplete'); + } + + init(data) { + this.levelId = data.levelId; + this.kidsSaved = data.kidsSaved; + this.total = data.total; + } + + create() { + markLevelComplete(this.levelId, this.kidsSaved, this.total); + + this.cameras.main.setBackgroundColor('#8fc7e8'); + + this.add.text(GAME_WIDTH / 2, 110 * WORLD_SCALE, 'LEVEL COMPLETE!', { + fontFamily: 'monospace', + fontSize: `${36 * WORLD_SCALE}px`, + color: '#1a1f29', + fontStyle: 'bold', + }).setOrigin(0.5); + + const perfect = this.kidsSaved === this.total; + this.add.text(GAME_WIDTH / 2, 170 * WORLD_SCALE, `${this.kidsSaved} / ${this.total} kids made it${perfect ? ' - perfect run!' : ''}`, { + fontFamily: 'monospace', + fontSize: `${18 * WORLD_SCALE}px`, + color: perfect ? '#2c8f3c' : '#1a1f29', + }).setOrigin(0.5); + + const nextId = getNextLevelId(this.levelId); + const y = GAME_HEIGHT / 2 + 20 * WORLD_SCALE; + + createButton(this, GAME_WIDTH / 2, y - 70 * WORLD_SCALE, 'RETRY', () => { + this.scene.start('Play', { levelId: this.levelId }); + }); + + if (nextId) { + const nextLevel = getLevelById(nextId); + createButton(this, GAME_WIDTH / 2, y, `NEXT: ${nextLevel.name.toUpperCase()}`, () => { + this.scene.start('Play', { levelId: nextId }); + }, { width: 280 * WORLD_SCALE }); + } else { + this.add.text(GAME_WIDTH / 2, y, 'That was the last level - nice driving!', { + fontFamily: 'monospace', + fontSize: `${14 * WORLD_SCALE}px`, + color: '#1a1f29', + }).setOrigin(0.5); + } + + createButton(this, GAME_WIDTH / 2, y + 70 * WORLD_SCALE, 'LEVEL SELECT', () => { + this.scene.start('LevelSelect'); + }); + } +} diff --git a/src/scenes/LevelFailedScene.js b/src/scenes/LevelFailedScene.js new file mode 100644 index 0000000..010235a --- /dev/null +++ b/src/scenes/LevelFailedScene.js @@ -0,0 +1,45 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, WORLD_SCALE } from '../config.js'; +import { createButton } from '../util/ui.js'; + +const REASON_TEXT = { + 'all-kids-lost': 'Every kid got thrown off the bus!', +}; + +export default class LevelFailedScene extends Phaser.Scene { + constructor() { + super('LevelFailed'); + } + + init(data) { + this.levelId = data.levelId; + this.reason = data.reason; + } + + create() { + this.cameras.main.setBackgroundColor('#c96a5a'); + + this.add.text(GAME_WIDTH / 2, 130 * WORLD_SCALE, 'LEVEL FAILED', { + fontFamily: 'monospace', + fontSize: `${36 * WORLD_SCALE}px`, + color: '#1a1f29', + fontStyle: 'bold', + }).setOrigin(0.5); + + this.add.text(GAME_WIDTH / 2, 190 * WORLD_SCALE, REASON_TEXT[this.reason] || 'The bus didn\'t make it.', { + fontFamily: 'monospace', + fontSize: `${16 * WORLD_SCALE}px`, + color: '#1a1f29', + }).setOrigin(0.5); + + const y = GAME_HEIGHT / 2 + 40 * WORLD_SCALE; + + createButton(this, GAME_WIDTH / 2, y - 40 * WORLD_SCALE, 'RETRY', () => { + this.scene.start('Play', { levelId: this.levelId }); + }); + + createButton(this, GAME_WIDTH / 2, y + 40 * WORLD_SCALE, 'LEVEL SELECT', () => { + this.scene.start('LevelSelect'); + }); + } +} diff --git a/src/scenes/LevelSelectScene.js b/src/scenes/LevelSelectScene.js new file mode 100644 index 0000000..7161405 --- /dev/null +++ b/src/scenes/LevelSelectScene.js @@ -0,0 +1,75 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, WORLD_SCALE } from '../config.js'; +import { LEVELS } from '../data/levels/index.js'; +import { getLevelResult } from '../util/progress.js'; + +export default class LevelSelectScene extends Phaser.Scene { + constructor() { + super('LevelSelect'); + } + + create() { + this.cameras.main.setBackgroundColor('#8fc7e8'); + + this.add.text(GAME_WIDTH / 2, 60 * WORLD_SCALE, 'SELECT LEVEL', { + fontFamily: 'monospace', + fontSize: `${32 * WORLD_SCALE}px`, + color: '#1a1f29', + fontStyle: 'bold', + }).setOrigin(0.5); + + const cardWidth = 260 * WORLD_SCALE; + const cardHeight = 300 * WORLD_SCALE; + const gap = 30 * WORLD_SCALE; + const totalWidth = LEVELS.length * cardWidth + (LEVELS.length - 1) * gap; + const startX = GAME_WIDTH / 2 - totalWidth / 2 + cardWidth / 2; + const y = GAME_HEIGHT / 2 + 30 * WORLD_SCALE; + + LEVELS.forEach((level, i) => { + const x = startX + i * (cardWidth + gap); + this._createCard(x, y, cardWidth, cardHeight, level); + }); + + const back = this.add.text(40 * WORLD_SCALE, GAME_HEIGHT - 40 * WORLD_SCALE, '< Menu', { + fontFamily: 'monospace', + fontSize: `${16 * WORLD_SCALE}px`, + color: '#1a1f29', + }).setInteractive({ useHandCursor: true }); + back.on('pointerdown', () => this.scene.start('MainMenu')); + } + + _createCard(x, y, width, height, level) { + const result = getLevelResult(level.id); + + const bg = this.add.rectangle(x, y, width, height, 0x2255aa).setStrokeStyle(2 * WORLD_SCALE, 0x1a1f29); + bg.setInteractive({ useHandCursor: true }); + bg.on('pointerover', () => bg.setFillStyle(0x2f6ac0)); + bg.on('pointerout', () => bg.setFillStyle(0x2255aa)); + bg.on('pointerdown', () => this.scene.start('Play', { levelId: level.id })); + + this.add.text(x, y - height / 2 + 34 * WORLD_SCALE, level.name, { + fontFamily: 'monospace', + fontSize: `${20 * WORLD_SCALE}px`, + color: '#ffffff', + fontStyle: 'bold', + }).setOrigin(0.5); + + this.add.text(x, y, level.description, { + fontFamily: 'monospace', + fontSize: `${13 * WORLD_SCALE}px`, + color: '#e8eef7', + align: 'center', + wordWrap: { width: width - 30 * WORLD_SCALE }, + }).setOrigin(0.5); + + const statusText = result + ? `Best: ${result.kidsSaved}/${result.kidsTotal} kids saved` + : 'Not completed'; + + this.add.text(x, y + height / 2 - 30 * WORLD_SCALE, statusText, { + fontFamily: 'monospace', + fontSize: `${13 * WORLD_SCALE}px`, + color: result ? '#f2c14e' : '#c8d3e0', + }).setOrigin(0.5); + } +} diff --git a/src/scenes/MainMenuScene.js b/src/scenes/MainMenuScene.js new file mode 100644 index 0000000..bc611b3 --- /dev/null +++ b/src/scenes/MainMenuScene.js @@ -0,0 +1,31 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, WORLD_SCALE } from '../config.js'; +import { createButton } from '../util/ui.js'; + +export default class MainMenuScene extends Phaser.Scene { + constructor() { + super('MainMenu'); + } + + create() { + this.cameras.main.setBackgroundColor('#8fc7e8'); + + this.add.text(GAME_WIDTH / 2, 90 * WORLD_SCALE, 'MONSTERPLEX', { + fontFamily: 'monospace', + fontSize: `${40 * WORLD_SCALE}px`, + color: '#1a1f29', + fontStyle: 'bold', + }).setOrigin(0.5); + + createButton(this, GAME_WIDTH / 2, GAME_HEIGHT / 2 - 20 * WORLD_SCALE, 'PLAY', () => { + this.scene.start('LevelSelect'); + }); + + this.add.text(GAME_WIDTH / 2, GAME_HEIGHT / 2 + 60 * WORLD_SCALE, 'Arrows/WASD to drive and lean.\nDon\'t let the g-force throw the kids out!', { + fontFamily: 'monospace', + fontSize: `${14 * WORLD_SCALE}px`, + color: '#1a1f29', + align: 'center', + }).setOrigin(0.5); + } +} diff --git a/src/scenes/PlayScene.js b/src/scenes/PlayScene.js new file mode 100644 index 0000000..e4c171c --- /dev/null +++ b/src/scenes/PlayScene.js @@ -0,0 +1,162 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, DEBUG, WORLD_SCALE } from '../config.js'; +import { getLevelById } from '../data/levels/index.js'; +import Bus from '../entities/Bus.js'; +import Terrain from '../entities/Terrain.js'; +import InputController from '../systems/InputController.js'; +import GForceMonitor from '../systems/GForceMonitor.js'; +import KidManager from '../systems/KidManager.js'; +import CameraRig from '../systems/CameraRig.js'; + +export default class PlayScene extends Phaser.Scene { + constructor() { + super('Play'); + } + + init(data) { + this.levelId = data.levelId; + this.level = getLevelById(this.levelId); + this._levelEnded = false; + } + + create() { + this.cameras.main.setBackgroundColor('#8fc7e8'); + + this._buildParallax(); + + this.terrain = new Terrain(this, this.level); + + this.bus = new Bus(this, this.level.startPosition.x, this.level.startPosition.y, this.level.startAngle || 0); + + this.kidManager = new KidManager(this, this.bus, this.level.kidsAboard); + + this.inputController = new InputController(this); + + this.gForceMonitor = new GForceMonitor(this, this.bus.chassis.body); + // Measured via headless testing: the spawn-to-ground drop settles by + // ~4.5s with the current spawn height/bus mass. Re-measure this if + // startPosition, WORLD_SCALE, or the bus's mass/suspension change again - + // too short and the landing itself trips the g-force ejection check. + this.gForceMonitor.startGracePeriod(5000); + + this.cameraRig = new CameraRig(this, this.bus.chassis, this.level.cameraBounds); + + this._buildGoal(); + this._buildHud(); + + this.events.on('kid-ejected', this._onKidEjected, this); + this.events.on('level-failed', this._onLevelFailed, this); + + this.matter.world.on('collisionstart', this._onCollisionStart, this); + + this.events.once('shutdown', this._cleanup, this); + } + + update(time, delta) { + if (this._levelEnded) return; + + const intent = this.inputController.getIntent(); + this.bus.applyIntent(intent); + this.kidManager.update(time); + + if (DEBUG && this.debugText) { + const g = this.gForceMonitor.lastGForce || 0; + this.debugText.setText(`g-force: ${g.toFixed(2)}`); + } + } + + _buildParallax() { + const bounds = this.level.cameraBounds; + const width = bounds.width + 1000 * WORLD_SCALE; + + const far = this.add.tileSprite(bounds.x, 0, width, GAME_HEIGHT, 'bg_far').setOrigin(0, 0); + far.setScrollFactor(0.15, 0); + + const mid = this.add.tileSprite(bounds.x, GAME_HEIGHT * 0.35, width, GAME_HEIGHT * 0.65, 'bg_mid').setOrigin(0, 0); + mid.setScrollFactor(0.45, 0); + + const near = this.add.tileSprite(bounds.x, GAME_HEIGHT * 0.55, width, GAME_HEIGHT * 0.45, 'bg_near').setOrigin(0, 0); + near.setScrollFactor(0.75, 0); + } + + _buildGoal() { + const goal = this.level.goal; + this.goalBody = this.matter.add.rectangle(goal.x, goal.y, goal.width, goal.height, { + isStatic: true, + isSensor: true, + label: 'goal', + }); + } + + _buildHud() { + this.hudIcons = []; + const startX = 24 * WORLD_SCALE; + const y = 24 * WORLD_SCALE; + const spacing = 30 * WORLD_SCALE; + const iconSize = 24 * WORLD_SCALE; + + for (let i = 0; i < this.level.kidsAboard; i++) { + const icon = this.add.image(startX + i * spacing, y, 'icon_kid').setDisplaySize(iconSize, iconSize).setScrollFactor(0).setDepth(10); + this.hudIcons.push(icon); + } + + this.hudText = this.add.text(startX, y + 24 * WORLD_SCALE, `Kids aboard: ${this.level.kidsAboard}/${this.level.kidsAboard}`, { + fontFamily: 'monospace', + fontSize: `${14 * WORLD_SCALE}px`, + color: '#1a1f29', + backgroundColor: '#ffffffaa', + }).setScrollFactor(0).setDepth(10); + + if (DEBUG) { + this.debugText = this.add.text(startX, y + 52 * WORLD_SCALE, 'g-force: 0.00', { + fontFamily: 'monospace', + fontSize: `${14 * WORLD_SCALE}px`, + color: '#1a1f29', + backgroundColor: '#ffffffaa', + }).setScrollFactor(0).setDepth(10); + } + } + + _onKidEjected({ kidsAboard, total }) { + const ejectedCount = total - kidsAboard; + for (let i = 0; i < this.hudIcons.length; i++) { + this.hudIcons[i].setAlpha(i < ejectedCount ? 0.2 : 1); + } + this.hudText.setText(`Kids aboard: ${kidsAboard}/${total}`); + } + + _onLevelFailed({ reason }) { + if (this._levelEnded) return; + this._levelEnded = true; + this.scene.start('LevelFailed', { levelId: this.levelId, reason }); + } + + _onCollisionStart(event, bodyA, bodyB) { + if (this._levelEnded) return; + if (this._isGoalHit(bodyA, bodyB)) { + this._onWin(); + } + } + + _isGoalHit(bodyA, bodyB) { + const busBodies = [this.bus.chassis.body, this.bus.wheelRear.body, this.bus.wheelFront.body]; + const isGoal = (b) => b.label === 'goal'; + const isBus = (b) => busBodies.includes(b); + return (isGoal(bodyA) && isBus(bodyB)) || (isGoal(bodyB) && isBus(bodyA)); + } + + _onWin() { + this._levelEnded = true; + const kidsSaved = this.kidManager.kidsAboardCount; + const total = this.kidManager.total; + this.scene.start('LevelComplete', { levelId: this.levelId, kidsSaved, total }); + } + + _cleanup() { + this.events.off('kid-ejected', this._onKidEjected, this); + this.events.off('level-failed', this._onLevelFailed, this); + this.matter.world.off('collisionstart', this._onCollisionStart, this); + if (this.gForceMonitor) this.gForceMonitor.destroy(); + if (this.kidManager) this.kidManager.destroy(); + } +} diff --git a/src/scenes/PreloadScene.js b/src/scenes/PreloadScene.js new file mode 100644 index 0000000..8e7501d --- /dev/null +++ b/src/scenes/PreloadScene.js @@ -0,0 +1,53 @@ +import Phaser from 'phaser'; +import { GAME_WIDTH, GAME_HEIGHT, WORLD_SCALE } from '../config.js'; +import { ASSET_MANIFEST } from '../util/assetManifest.js'; +import { generatePlaceholder } from '../util/placeholderTextures.js'; + +export default class PreloadScene extends Phaser.Scene { + constructor() { + super('Preload'); + } + + preload() { + this._drawLoadingBar(); + + this._failedKeys = new Set(); + this.load.on(Phaser.Loader.Events.FILE_LOAD_ERROR, (file) => { + this._failedKeys.add(file.key); + }); + + for (const entry of ASSET_MANIFEST) { + this.load.image(entry.key, entry.path); + } + } + + create() { + for (const entry of ASSET_MANIFEST) { + if (this._failedKeys.has(entry.key) || !this.textures.exists(entry.key)) { + generatePlaceholder(this, entry); + } + } + + this.scene.start('Intro'); + } + + _drawLoadingBar() { + const barWidth = 320 * WORLD_SCALE; + const barHeight = 18 * WORLD_SCALE; + const pad = 4 * WORLD_SCALE; + const x = GAME_WIDTH / 2 - barWidth / 2; + const y = GAME_HEIGHT / 2 - barHeight / 2; + + const box = this.add.graphics(); + box.fillStyle(0x1a1f29, 1); + box.fillRect(x - pad, y - pad, barWidth + pad * 2, barHeight + pad * 2); + + const bar = this.add.graphics(); + + this.load.on(Phaser.Loader.Events.PROGRESS, (value) => { + bar.clear(); + bar.fillStyle(0xf2c14e, 1); + bar.fillRect(x, y, barWidth * value, barHeight); + }); + } +} diff --git a/src/systems/CameraRig.js b/src/systems/CameraRig.js new file mode 100644 index 0000000..793aba3 --- /dev/null +++ b/src/systems/CameraRig.js @@ -0,0 +1,15 @@ +import { CAMERA } from '../config.js'; + +export default class CameraRig { + constructor(scene, target, bounds) { + this.scene = scene; + const cam = scene.cameras.main; + + if (bounds) { + cam.setBounds(bounds.x, bounds.y, bounds.width, bounds.height); + } + + cam.setDeadzone(CAMERA.deadzoneWidth, CAMERA.deadzoneHeight); + cam.startFollow(target, true, CAMERA.lerpX, CAMERA.lerpY); + } +} diff --git a/src/systems/GForceMonitor.js b/src/systems/GForceMonitor.js new file mode 100644 index 0000000..279014b --- /dev/null +++ b/src/systems/GForceMonitor.js @@ -0,0 +1,51 @@ +import { GFORCE, PHYSICS_TIMESTEP_SECONDS } from '../config.js'; + +// Pure detector: samples the chassis's linear velocity every fixed physics +// step, estimates acceleration via finite difference, and emits +// 'gforce-exceeded' on the scene when it crosses the tunable threshold. +// Ejection logic lives elsewhere (KidManager) so this stays a single-purpose +// sensor. +export default class GForceMonitor { + constructor(scene, chassisBody) { + this.scene = scene; + this.chassisBody = chassisBody; + this.previousVelocity = { x: 0, y: 0 }; + this.graceUntil = 0; + this.enabled = true; + + this._onAfterUpdate = this._onAfterUpdate.bind(this); + scene.matter.world.on('afterupdate', this._onAfterUpdate); + } + + startGracePeriod(durationMs = GFORCE.gracePeriodMs) { + this.graceUntil = this.scene.time.now + durationMs; + const v = this.chassisBody.velocity; + this.previousVelocity = { x: v.x, y: v.y }; + } + + _onAfterUpdate() { + if (!this.enabled) return; + + const v = this.chassisBody.velocity; + const dvx = v.x - this.previousVelocity.x; + const dvy = v.y - this.previousVelocity.y; + const deltaV = Math.hypot(dvx, dvy); + + const accelPxPerSec2 = deltaV / PHYSICS_TIMESTEP_SECONDS; + const accelMPerSec2 = accelPxPerSec2 / GFORCE.pixelsPerMeter; + const gForce = accelMPerSec2 / 9.8; + + this.previousVelocity = { x: v.x, y: v.y }; + this.lastGForce = gForce; + + if (this.scene.time.now < this.graceUntil) return; + + if (gForce > GFORCE.ejectThresholdG) { + this.scene.events.emit('gforce-exceeded', { gForce }); + } + } + + destroy() { + this.scene.matter.world.off('afterupdate', this._onAfterUpdate); + } +} diff --git a/src/systems/InputController.js b/src/systems/InputController.js new file mode 100644 index 0000000..e325bee --- /dev/null +++ b/src/systems/InputController.js @@ -0,0 +1,29 @@ +import Phaser from 'phaser'; + +// Polls keyboard input into a small, stable intent shape. Bus/PlayScene only +// ever depend on getIntent()'s return shape, so a TouchInputController with +// the same shape could be added later without touching either of them. +export default class InputController { + constructor(scene) { + const KC = Phaser.Input.Keyboard.KeyCodes; + const kb = scene.input.keyboard; + + this.up = [kb.addKey(KC.UP), kb.addKey(KC.W)]; + this.down = [kb.addKey(KC.DOWN), kb.addKey(KC.S)]; + this.left = [kb.addKey(KC.LEFT), kb.addKey(KC.A)]; + this.right = [kb.addKey(KC.RIGHT), kb.addKey(KC.D)]; + } + + _anyDown(keys) { + return keys.some((key) => key.isDown); + } + + getIntent() { + const throttle = this._anyDown(this.up) ? 1 : this._anyDown(this.down) ? -1 : 0; + return { + throttle, + leanLeft: this._anyDown(this.left), + leanRight: this._anyDown(this.right), + }; + } +} diff --git a/src/systems/KidManager.js b/src/systems/KidManager.js new file mode 100644 index 0000000..a76d379 --- /dev/null +++ b/src/systems/KidManager.js @@ -0,0 +1,54 @@ +import Phaser from 'phaser'; +import { GFORCE } from '../config.js'; +import Kid from '../entities/Kid.js'; + +export default class KidManager { + constructor(scene, bus, kidsAboard) { + this.scene = scene; + this.bus = bus; + this.total = kidsAboard; + this.kids = []; + this._lastEjectTime = -Infinity; + + for (let i = 0; i < kidsAboard; i++) { + this.kids.push(new Kid(scene, bus, i)); + } + + this._onGForceExceeded = this._onGForceExceeded.bind(this); + scene.events.on('gforce-exceeded', this._onGForceExceeded); + } + + get kidsAboardCount() { + return this.kids.filter((kid) => kid.state === 'aboard').length; + } + + _onGForceExceeded({ gForce }) { + const now = this.scene.time.now; + if (now - this._lastEjectTime < GFORCE.ejectCooldownMs) return; + + const aboard = this.kids.filter((kid) => kid.state === 'aboard'); + if (aboard.length === 0) return; + + this._lastEjectTime = now; + const kid = Phaser.Utils.Array.GetRandom(aboard); + kid.eject(this.bus.chassis.body.velocity, gForce); + + this.scene.events.emit('kid-ejected', { + kidsAboard: this.kidsAboardCount, + total: this.total, + }); + + if (this.kidsAboardCount === 0) { + this.scene.events.emit('level-failed', { reason: 'all-kids-lost' }); + } + } + + update(time) { + for (const kid of this.kids) kid.update(time); + } + + destroy() { + this.scene.events.off('gforce-exceeded', this._onGForceExceeded); + for (const kid of this.kids) kid.destroy(); + } +} diff --git a/src/util/assetManifest.js b/src/util/assetManifest.js new file mode 100644 index 0000000..2ff6cca --- /dev/null +++ b/src/util/assetManifest.js @@ -0,0 +1,16 @@ +import { WORLD_SCALE } from '../config.js'; + +// Single source of truth for every image the game expects. +// Drop a real file at `path` and it will be used automatically - +// nothing else in the codebase needs to change (see placeholderTextures.js). +export const ASSET_MANIFEST = [ + { key: 'bus_chassis', path: 'assets/sprites/bus_chassis.png', width: 170 * WORLD_SCALE, height: 64 * WORLD_SCALE, kind: 'rect', color: 0x2255aa }, + { key: 'bus_wheel', path: 'assets/sprites/bus_wheel.png', width: 34 * WORLD_SCALE, height: 34 * WORLD_SCALE, kind: 'circle', color: 0x222222 }, + { key: 'kid_idle', path: 'assets/sprites/kid_idle.png', width: 28 * WORLD_SCALE, height: 28 * WORLD_SCALE, kind: 'circle', color: 0xf2c14e }, + { key: 'kid_ejected', path: 'assets/sprites/kid_ejected.png', width: 28 * WORLD_SCALE, height: 28 * WORLD_SCALE, kind: 'circle', color: 0xe0553b }, + { key: 'bg_far', path: 'assets/backgrounds/bg_far.png', width: 256 * WORLD_SCALE, height: 540 * WORLD_SCALE, kind: 'rect', color: 0x8fc7e8, tileable: true }, + { key: 'bg_mid', path: 'assets/backgrounds/bg_mid.png', width: 256 * WORLD_SCALE, height: 540 * WORLD_SCALE, kind: 'rect', color: 0x6fae7d, tileable: true }, + { key: 'bg_near', path: 'assets/backgrounds/bg_near.png', width: 256 * WORLD_SCALE, height: 540 * WORLD_SCALE, kind: 'rect', color: 0x4c8a5c, tileable: true }, + { key: 'icon_kid', path: 'assets/ui/icon_kid.png', width: 24 * WORLD_SCALE, height: 24 * WORLD_SCALE, kind: 'circle', color: 0xf2c14e }, + { key: 'favicon', path: 'assets/favicon.png', width: 32, height: 32, kind: 'rect', color: 0x2255aa }, +]; diff --git a/src/util/placeholderTextures.js b/src/util/placeholderTextures.js new file mode 100644 index 0000000..ce47ea2 --- /dev/null +++ b/src/util/placeholderTextures.js @@ -0,0 +1,31 @@ +import { WORLD_SCALE } from '../config.js'; + +// Synthesizes a simple colored texture for any manifest entry whose real +// image file failed to load, registered under that entry's own texture key. +// Once a real PNG exists at the manifest path, the loader succeeds and this +// is never invoked for that key - no other code needs to change. +export function generatePlaceholder(scene, entry) { + const { key, width, height, kind, color, tileable } = entry; + const g = scene.make.graphics({ x: 0, y: 0 }, false); + const border = 2 * WORLD_SCALE; + + g.fillStyle(color, 1); + + if (kind === 'circle') { + const r = Math.min(width, height) / 2; + g.fillCircle(width / 2, height / 2, r - 1); + g.lineStyle(border, 0x000000, 0.35); + g.strokeCircle(width / 2, height / 2, r - 1); + } else { + g.fillRect(0, 0, width, height); + // Tiled textures (parallax backgrounds) skip the border - it would tile + // into a visible grid seam. + if (!tileable) { + g.lineStyle(border, 0x000000, 0.35); + g.strokeRect(border / 2, border / 2, width - border, height - border); + } + } + + g.generateTexture(key, width, height); + g.destroy(); +} diff --git a/src/util/progress.js b/src/util/progress.js new file mode 100644 index 0000000..ffc72e4 --- /dev/null +++ b/src/util/progress.js @@ -0,0 +1,31 @@ +import { STORAGE_KEY } from '../config.js'; + +function readAll() { + try { + const raw = localStorage.getItem(STORAGE_KEY); + return raw ? JSON.parse(raw) : {}; + } catch (e) { + return {}; + } +} + +export function isLevelComplete(levelId) { + return Boolean(readAll()[levelId]); +} + +export function markLevelComplete(levelId, kidsSaved, kidsTotal) { + const all = readAll(); + const existing = all[levelId]; + if (!existing || kidsSaved > existing.kidsSaved) { + all[levelId] = { kidsSaved, kidsTotal }; + } + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify(all)); + } catch (e) { + // localStorage unavailable (e.g. private browsing) - progress just won't persist + } +} + +export function getLevelResult(levelId) { + return readAll()[levelId] || null; +} diff --git a/src/util/ui.js b/src/util/ui.js new file mode 100644 index 0000000..c2d03cc --- /dev/null +++ b/src/util/ui.js @@ -0,0 +1,21 @@ +import { WORLD_SCALE } from '../config.js'; + +export function createButton(scene, x, y, label, onClick, options = {}) { + const width = options.width || 220 * WORLD_SCALE; + const height = options.height || 56 * WORLD_SCALE; + const fontSize = options.fontSize || `${20 * WORLD_SCALE}px`; + + const bg = scene.add.rectangle(x, y, width, height, 0x2255aa).setStrokeStyle(2 * WORLD_SCALE, 0x1a1f29); + const text = scene.add.text(x, y, label, { + fontFamily: 'monospace', + fontSize, + color: '#ffffff', + }).setOrigin(0.5); + + bg.setInteractive({ useHandCursor: true }); + bg.on('pointerover', () => bg.setFillStyle(0x2f6ac0)); + bg.on('pointerout', () => bg.setFillStyle(0x2255aa)); + bg.on('pointerdown', onClick); + + return { bg, text }; +} diff --git a/start_web.sh b/start_web.sh new file mode 100755 index 0000000..a92e9cc --- /dev/null +++ b/start_web.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Start a simple HTTP server on port 8000 +python3 -m http.server 3000 \ No newline at end of file diff --git a/vendor/phaser.esm.js b/vendor/phaser.esm.js new file mode 100644 index 0000000..8c6521a --- /dev/null +++ b/vendor/phaser.esm.js @@ -0,0 +1,268534 @@ +/******/ var __webpack_modules__ = ({ + +/***/ 50792 +(module) { + + + +var has = Object.prototype.hasOwnProperty + , prefix = '~'; + +/** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @private + */ +function Events() {} + +// +// We try to not inherit from `Object.prototype`. In some engines creating an +// instance in this way is faster than calling `Object.create(null)` directly. +// If `Object.create(null)` is not supported we prefix the event names with a +// character to make sure that the built-in object properties are not +// overridden or used as an attack vector. +// +if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; +} + +/** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @private + */ +function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; +} + +/** + * Add a listener for a given event. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} once Specify if the listener is a one-time listener. + * @returns {EventEmitter} + * @private + */ +function addListener(emitter, event, fn, context, once) { + if (typeof fn !== 'function') { + throw new TypeError('The listener must be a function'); + } + + var listener = new EE(fn, context || emitter, once) + , evt = prefix ? prefix + event : event; + + if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); + else emitter._events[evt] = [emitter._events[evt], listener]; + + return emitter; +} + +/** + * Clear event by name. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} evt The Event name. + * @private + */ +function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) emitter._events = new Events(); + else delete emitter._events[evt]; +} + +/** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @public + */ +function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; +} + +/** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @public + */ +EventEmitter.prototype.eventNames = function eventNames() { + var names = [] + , events + , name; + + if (this._eventsCount === 0) return names; + + for (name in (events = this._events)) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; +}; + +/** + * Return the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Array} The registered listeners. + * @public + */ +EventEmitter.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event + , handlers = this._events[evt]; + + if (!handlers) return []; + if (handlers.fn) return [handlers.fn]; + + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + + return ee; +}; + +/** + * Return the number of listeners listening to a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Number} The number of listeners. + * @public + */ +EventEmitter.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event + , listeners = this._events[evt]; + + if (!listeners) return 0; + if (listeners.fn) return 1; + return listeners.length; +}; + +/** + * Calls each of the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @public + */ +EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return false; + + var listeners = this._events[evt] + , len = arguments.length + , args + , i; + + if (listeners.fn) { + if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); + + switch (len) { + case 1: return listeners.fn.call(listeners.context), true; + case 2: return listeners.fn.call(listeners.context, a1), true; + case 3: return listeners.fn.call(listeners.context, a1, a2), true; + case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len -1); i < len; i++) { + args[i - 1] = arguments[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length + , j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); + + switch (len) { + case 1: listeners[i].fn.call(listeners[i].context); break; + case 2: listeners[i].fn.call(listeners[i].context, a1); break; + case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; + default: + if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { + args[j - 1] = arguments[j]; + } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; +}; + +/** + * Add a listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); +}; + +/** + * Add a one-time listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); +}; + +/** + * Remove the listeners of a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {*} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn && + (!once || listeners.once) && + (!context || listeners.context === context) + ) { + clearEvent(this, evt); + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn || + (once && !listeners[i].once) || + (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else clearEvent(this, evt); + } + + return this; +}; + +/** + * Remove all listeners, or those of the specified event. + * + * @param {(String|Symbol)} [event] The event name. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) clearEvent(this, evt); + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; +}; + +// +// Alias methods names because people roll like that. +// +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; +EventEmitter.prototype.addListener = EventEmitter.prototype.on; + +// +// Expose the prefix. +// +EventEmitter.prefixed = prefix; + +// +// Allow `EventEmitter` to be imported as module namespace. +// +EventEmitter.EventEmitter = EventEmitter; + +// +// Expose the module. +// +if (true) { + module.exports = EventEmitter; +} + + +/***/ }, + +/***/ 93300 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BlendModes = __webpack_require__(10312); + +/** + * Adds a Bloom effect to a Camera or GameObject or list thereof. + * + * Bloom is a phenomenon where bright light spreads across an image. + * It can be used to add to the realism of a scene, + * although too much is obvious and a subtle effect is best. + * + * This Action creates a Bloom effect by applying several Filters to the target. + * + * - `ParallelFilters` splits the filter stream, allowing us to combine + * the results of other filters with the original image. + * The other filters are added to the `top` stream. + * - `Threshold` removes darker colors. + * - `Blur` spreads the remaining bright colors out. + * + * This Action returns an object containing references to these filters. + * You can control their properties directly, + * e.g. if you want to animate the Bloom, + * or if you want to set properties this Action doesn't surface. + * + * The Bloom effect will be destroyed like any other filter on target shutdown. + * To disable or remove the Bloom effect manually, access the `parallelFilters` + * controller in the return object. It holds the other filters. + * + * - `parallelFilters.active = false`: deactivate Bloom + * - `parallelFilters.destroy()`: destroy Bloom + * + * Bloom is best as a full-screen effect. If you apply it to a GameObject with + * alpha regions, it cannot blend the light glow properly with the background. + * This is because the glow should use ADD blend, but the object itself should + * use NORMAL blend, and it can't do both. + * You can still apply bloom to a GameObject, + * but it works best on a solid texture. + * + * @example + * // Apply bloom to the scene camera. + * Phaser.Actions.AddEffectBloom(this.cameras.main); + * + * @example + * // Access the filters that make up a Bloom effect. + * const { parallelFilters, threshold, blur } = Phaser.Actions.AddEffectBloom(this.cameras.main)[0]; // The return is an array. + * + * // Destroy the bloom effect. + * parallelFilters.destroy(); + * + * @example + * // Emulate the Phaser 3 Bloom effect, + * // including the way bloom strength darkens instead of mixes. + * const { parallelFilters, threshold, blur } = Phaser.Actions.AddEffectBloom( + * image, + * { + * blendAmount: 0.5, + * blurQuality: 1, + * } + * ); + * + * threshold.active = false; + * parallelFilters.bottom.addBlend(undefined, Phaser.BlendModes.MULTIPLY, 1, [ 0. * 5, 0.5, 0.5, 0.5 ]); + * + * @function Phaser.Actions.AddEffectBloom + * @since 4.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera|Phaser.GameObjects.GameObject|Array.<(Phaser.Cameras.Scene2D.Camera|Phaser.GameObjects.GameObject)>} items - Recipients of the Bloom effect + * @param {Phaser.Types.Actions.AddEffectBloomConfig} [config] - Initial configuration of the Bloom effect. + * + * @return {Phaser.Types.Actions.AddEffectBloomReturn[]} A list of objects containing the filters which were created. + */ +var AddEffectBloom = function (items, config) +{ + if (!Array.isArray(items)) { items = [ items ]; } + if (!config) { config = {}; } + var threshold = config.threshold === undefined ? 0.5 : config.threshold; + var blurRadius = config.blurRadius === undefined ? 2 : config.blurRadius; + var blurSteps = config.blurSteps === undefined ? 4 : config.blurSteps; + var blurQuality = config.blurQuality === undefined ? 0 : config.blurQuality; + var blendAmount = config.blendAmount === undefined ? 1 : config.blendAmount; + var blendMode = config.blendMode === undefined ? BlendModes.ADD : config.blendMode; + + var output = []; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + if (item.enableFilters) { item.enableFilters(); } + var filterList = config.useInternal ? item.filters.internal : item.filters.external; + var parallelFilters = filterList.addParallelFilters(); + var thresholdFilter = parallelFilters.top.addThreshold(threshold, 1); + var blurFilter = parallelFilters.top.addBlur(blurQuality, blurRadius, blurRadius, 1, 0xffffff, blurSteps); + parallelFilters.blend.blendMode = blendMode; + parallelFilters.blend.amount = blendAmount; + + output.push({ + item: item, + parallelFilters: parallelFilters, + threshold: thresholdFilter, + blur: blurFilter + }); + } + + return output; +}; + +module.exports = AddEffectBloom; + + +/***/ }, + +/***/ 56704 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DESTROY_EVENT = __webpack_require__(16438); +var BlendModes = __webpack_require__(10312); +var DESTROY = __webpack_require__(41337); +var GameObject = __webpack_require__(95643); +var UUID = __webpack_require__(45650); + +/** + * Adds a Shine effect to a Camera or GameObject or list thereof. + * + * Shine simulates a highlight glancing from a surface. + * It's a brief specular reflection of a bright light, + * typically from a fairly flat surface which only reflects the highlight + * from certain angles. + * In a game, you might use this to highlight an important object, + * convey a sense of glossiness, + * or move an interference band across a transmission. + * + * This Action works by creating several resources. + * + * - A Gradient object generates the region of the shine. + * - A DynamicTexture holds the shine region. + * - A Tween animates the shine region. + * - A Blend filter combines the shine and the image. + * - (Optional) A ParallelFilters filter adds the rest of the image back in. + * + * You may configure the effect in several ways using the `config` parameter. + * + * Use `radius`, `direction` and `scale` to set the gradient orientation. + * Scale defaults to 2, twice the size of the target, + * to guarantee that the highlight leaves the image completely before repeating. + * The radius also adds an extra offset on either side of the image + * so the gradient has space to enter and exit the image. + * + * Use `colorFactor` to control the RGBA color of the highlight. + * You can overdrive this to values greater than 1 to create very bright shine. + * By default, it has a slight red tint to create warm highlights. + * + * Use `displacementMap` and `displacement` to add a Displacement filter + * to the Gradient. This creates the impression of a slightly scuffed surface. + * You may add other filters to the Gradient; they will be rendered into the + * DynamicTexture for use in the final blend. + * + * Use `reveal` to put the effect into reveal mode. + * In this mode, the image is only visible under the shine. + * + * Use `duration`, `yoyo` and `ease` to control the Tween animation. + * + * The resources created in this way will be automatically destroyed + * when the target is destroyed. You may remove them earlier yourself. + * Unless you use them in other systems, they are isolated and safe to destroy. + * (The Tween requires the other resources to exist while it exists.) + * + * When you target multiple objects with this method, + * each creates its own set of resources. Each set is independent, + * and may be destroyed or manipulated without affecting the others. + * + * You can create your own Shine effects using this as a base or as inspiration. + * + * @example + * // Slowly move a cyan highlight up and down an image. + * // Use a displacement map to dirty up the highlight. + * const { dynamicTexture, gradient, tween } = Phaser.Actions.AddEffectShine(this.image, { + * duration: 5000, + * direction: Math.PI / 2, + * scale: 1, + * displacementMap: 'displace', + * colorFactor: [ 0.5,2,2,1 ], + * yoyo: true, + * ease: 'Quad.inout' + * })[0]; // The return is an array. + * + * @function Phaser.Actions.AddEffectShine + * @since 4.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera|Phaser.GameObjects.GameObject|Array.<(Phaser.Cameras.Scene2D.Camera|Phaser.GameObjects.GameObject)>} items - Recipients of the Shine effect + * @param {Phaser.Types.Actions.AddEffectShineConfig} [config] - Initial configuration of the Shine effect. + * + * @return {Phaser.Types.Actions.AddEffectShineReturn[]} A list of objects containing the resources which were created. + */ +var AddEffectShine = function (items, config) +{ + if (!config) { config = {}; } + + if (!Array.isArray(items)) { items = [ items ]; } + var firstItem = items[0]; + var scene = firstItem.scene; + + var gradientDirection = config.direction === undefined ? 0.5 : config.direction % (Math.PI * 2); + var gradientScale = config.scale === undefined ? 2 : config.scale; + var gradientRadius = (config.radius || 0.5) / gradientScale; + var gradientWidth = config.width || firstItem.width || 128; + var gradientHeight = config.height || firstItem.height || 128; + var start = { x: 0, y: 0 }; + if (gradientDirection < 0) { gradientDirection += Math.PI * 2; } + if (gradientDirection > Math.PI * 3 / 2) + { + // Bottom-left start + start.y = 1; + } + else if (gradientDirection > Math.PI) + { + // Bottom-right start + start.x = 1; + start.y = 1; + } + else if (gradientDirection > Math.PI / 2) + { + // Top-right start + start.x = 1; + } + + var output = []; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + // Create Gradient object. + var gradientConfig = { + origin: 0, + width: gradientWidth, + height: gradientHeight, + config: { + offset: -gradientRadius, + repeatMode: 3, // Triangular + shapeMode: 0, // Linear + direction: gradientDirection, + length: gradientScale, + start: start, + bands: config.bands || [ + { + interpolation: 2, // Sinusoidal for smooth transitions + colorStart: 0xffffff, + colorEnd: [ 1, 1, 1, 0 ], + size: gradientRadius + }, + { + colorStart: [ 1, 1, 1, 0 ], + size: 1 - gradientRadius + } + ] + } + }; + var gradient = scene.make.gradient(gradientConfig, false); + + // Create displacement effect. + if (config.displacementMap) + { + var displacement = config.displacement || 0.1; + gradient.enableFilters().filters.internal.addDisplacement(config.displacementMap, displacement, displacement); + } + + // Create DynamicTexture. + var key = UUID(); + var textures = scene.textures; + while (textures.exists(key)) + { + key = UUID(); + } + var dynamicTexture = textures.addDynamicTexture(key, gradient.width, gradient.height); + + // Create Tween. + var tween = scene.tweens.add({ + targets: gradient, + offset: 1 + gradientRadius, + repeat: -1, + yoyo: !!config.yoyo, + ease: config.ease, + duration: config.duration || 2000, + repeatDelay: config.repeatDelay || 0, + onUpdate: function () + { + dynamicTexture.clear().draw(gradient).render(); + } + }); + + // Enable filters on target. + if (item instanceof GameObject) + { + item.enableFilters(); + } + + // Combine gradient texture with target. + var filterList = config.useExternal ? item.filters.external : item.filters.internal; + var blendFilter; + var parallelFilters; + var colorFactor = config.colorFactor || [ 1.15, 0.85, 0.85, 1 ]; + if (!config.reveal) + { + parallelFilters = filterList.addParallelFilters(); + blendFilter = parallelFilters.top.addBlend(key, BlendModes.MULTIPLY, 1, colorFactor); + parallelFilters.blend.blendMode = BlendModes.ADD; + } + else + { + blendFilter = filterList.addBlend(key, BlendModes.MULTIPLY, 1, colorFactor); + } + + // Set up tidy-up. + // Gradient is only referenced from the tween, and will self-dispose. + // Filters will self-dispose. + // Tween and dynamic texture must be removed if the target is destroyed. + var tidyup = function () + { + tween.destroy(); + dynamicTexture.destroy(); + }; + if (item instanceof GameObject) + { + item.on(DESTROY, tidyup); + } + else + { + item.on(DESTROY_EVENT, tidyup); + } + + output.push({ + item: item, + dynamicTexture: dynamicTexture, + gradient: gradient, + tween: tween, + parallelFilters: parallelFilters, + blendFilter: blendFilter + }); + } + + // Return relevant objects. + return output; +}; + +module.exports = AddEffectShine; + + +/***/ }, + +/***/ 245 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObject = __webpack_require__(95643); +var Rectangle = __webpack_require__(93232); +var FitToRegion = __webpack_require__(94591); + +/** + * Apply a Mask to a GameObject or Camera or list thereof using a Shape. + * + * This is a quick way to add a mask to an object/camera. + * It creates a Shape and uses FitToRegion to size it correctly. + * + * By default, the Mask is a circle, scaled to fit both X and Y axes + * of the game canvas (so it's not really a circle any more). + * + * You can change the shape to 'square', 'rectangle', or 'ellipse'. + * Control the shape of rectangles or ellipses via `config.aspectRatio`. + * + * You can change the coverage much like FitToRegion. + * You can scale to fit inside, outside, or both axes. + * You can set the target region; if you do not, the action will choose + * an appropriate region for you. + * + * The action supports an optional Blur effect, applied to the shape. + * This is good for soft edges on masks. + * You can use `config.padding` to shrink the shape region inward, leaving room for the blur to spread outward to the intended boundary. + * + * The Shape is removed from the scene upon creation. + * You don't need to manage its life cycle; it should be garbage collected + * once the Mask filter is destroyed, usually when the scene or target + * is shut down. + * If you want to access the Shape, it is available on the mask filter. + * + * If you apply this to multiple objects at once, + * they all have their own shape and mask filter. + * Note that, if you use external filters, the masks will seem to line up. + * In this case, it might be more efficient to put all the targets into + * a Layer or Container and mask that instead. + * + * @example + * const mask = Phaser.Actions.AddMaskShape(target, { + * blurRadius: 2, + * padding: 2 + * })[0]; // The return is an array. + * const shape = mask.maskGameObject; // This reference prevents garbage collection until `shape` is dropped. + * const blur = shape.filters.external.list[0]; // Nothing else should be in this list. + * + * @function Phaser.Actions.AddMaskShape + * @since 4.0.0 + * + * @param {Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera | Array.<(Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera)>} items - The GameObject or Camera or list thereof to which to apply a mask. + * @param {Phaser.Types.Actions.AddMaskShapeConfig} config - The configuration of the mask shape. + * + * @return {Phaser.Filters.Mask[]} The new Mask filters, in order of target. + */ +var AddMaskShape = function (items, config) +{ + if (!Array.isArray(items)) { items = [ items ]; } + if (!config) { config = {}; } + var aspectRatio = (config.aspectRatio === undefined) ? 1 : config.aspectRatio; + var padding = config.padding || 0; + + var scene = items[0].scene; + var output = []; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + var region = config.region; + if (!region) + { + if (config.useInternal && item._sizeComponent) + { + region = new Rectangle(0, 0, item.width, item.height); + } + else + { + region = new Rectangle(0, 0, scene.scale.width, scene.scale.height); + } + } + + // Create a shape to use as a mask. + var shape; + switch (config.shape) + { + case 'ellipse': + { + shape = scene.add.ellipse(0, 0, aspectRatio, 1, 0xffffff); + break; + } + case 'square': + { + shape = scene.add.rectangle(0, 0, 1, 1, 0xffffff); + break; + } + case 'rectangle': + { + shape = scene.add.rectangle(0, 0, aspectRatio, 1, 0xffffff); + break; + } + case 'circle': + default: + { + shape = scene.add.circle(0, 0, 1, 0xffffff); + break; + } + } + + // Remove shape from scene, as we don't need to display it, + // and it will be garbage collected once the Mask is destroyed. + scene.children.remove(shape); + + // Apply padding. + if (padding) + { + region = new Rectangle( + region.x + padding, + region.y + padding, + region.width - padding * 2, + region.height - padding * 2 + ); + } + + // Transform shape to fit to target. + FitToRegion(shape, config.scaleMode, region); + + // Optionally, blur shape. + if (config.blurRadius > 0) + { + shape.enableFilters().filters.external.addBlur( + config.blurQuality, + config.blurRadius, + config.blurRadius, + 1, + undefined, + config.blurSteps + ); + } + + // Apply mask. + if (item instanceof GameObject) + { + item.enableFilters(); + } + var filterList = config.useInternal ? item.filters.internal : item.filters.external; + var mask = filterList.addMask(shape, config.invert); + + output.push(mask); + } + + return output; +}; + +module.exports = AddMaskShape; + + +/***/ }, + +/***/ 11517 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author samme + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var QuickSet = __webpack_require__(38829); + +/** + * Takes an array of Game Objects and aligns them next to each other. + * + * The alignment position is controlled by the `position` parameter, which should be one + * of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`, + * `Phaser.Display.Align.TOP_CENTER`, etc. + * + * The first item isn't moved. The second item is aligned next to the first, + * then the third next to the second, and so on. + * + * @function Phaser.Actions.AlignTo + * @since 3.22.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} position - The position to align the items with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position, in pixels. + * @param {number} [offsetY=0] - Optional vertical offset from the position, in pixels. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var AlignTo = function (items, position, offsetX, offsetY) +{ + var target = items[0]; + + for (var i = 1; i < items.length; i++) + { + var item = items[i]; + + QuickSet(item, target, position, offsetX, offsetY); + + target = item; + } + + return items; +}; + +module.exports = AlignTo; + + +/***/ }, + +/***/ 80318 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have a public `angle` property, + * and then adds the given value to each of their `angle` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Angle(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Angle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount, in degrees, to be added to the `angle` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. For example, a `step` of 10 will add 0 to the first item, 10 to the second, 20 to the third, and so on. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var Angle = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'angle', value, step, index, direction); +}; + +module.exports = Angle; + + +/***/ }, + +/***/ 60757 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of objects and passes each of them to the given callback. + * + * @function Phaser.Actions.Call + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {Phaser.Types.Actions.CallCallback} callback - The callback to be invoked. It will be passed just one argument: the item from the array. + * @param {*} context - The scope in which the callback will be invoked. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that was passed to this Action. + */ +var Call = function (items, callback, context) +{ + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + callback.call(context, item); + } + + return items; +}; + +module.exports = Call; + + +/***/ }, + +/***/ 94591 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); +var GetFastValue = __webpack_require__(95540); + +/** + * Fit GameObjects to a region. + * + * This is a quick way to fit a background to a scene, + * move an object without worrying about origins, + * or cover a hole of known size. + * + * This will transform each object to fit into a rectangular region. + * Rotation is ignored, but translation and scale are changed. + * Note that negative scale will become positive; use flip to resolve this. + * The object must support transformation. + * + * The fit can scale proportionally, to touch the inside or outside of the region; + * but by default it scales both axes independently to touch all sides. + * + * The region is an axis-aligned bounding box (AABB). + * By default, it is derived from the object, via the scene scale properties, + * i.e. `{ x: 0, y: 0, width: scene.scale.width, height: scene.scale.height }`. + * + * If the game object has no size or origin, e.g. a Container, + * then it is tricky to figure out how to resize it to fit. + * The `itemCoverage` parameter allows you to set `width`, `height`, `originX` + * and/or `originY` properties to supplement available data. + * These settings take precedence over original item properties, even if they exist. + * + * @function Phaser.Actions.FitToRegion + * @since 4.0.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} items - The GameObject or GameObjects to fit to the region. Each must have the Phaser.GameObjects.Components.Transform component. + * @param {number} [scaleMode=0] - The scale mode. 0 sets each axis to fill the region independently. -1 scales both axes uniformly so the item touches the _inside_ of the region. 1 scales both axes uniformly so the item touches the _outside_ of the region. + * @param {Phaser.Types.Math.RectangleLike} [region] - The region to fit. If not defined, it will be inferred from the first item's scene scale. + * @param {Phaser.Types.Actions.FitToRegionItemCoverage} [itemCoverage] - Override or define the region covered by the item. This is intended to provide dimensions for objects which don't have them, such as Containers, allowing them to resize. + * + * @return {Phaser.GameObjects.GameObject[]} - The items that were fitted. + */ +var FitToRegion = function (items, scaleMode, region, itemCoverage) +{ + if (!Array.isArray(items)) { items = [ items ]; } + if (scaleMode === undefined) { scaleMode = 0; } + if (!region) + { + var scene = items[0].scene; + region = new Rectangle(0, 0, scene.scale.width, scene.scale.height); + } + if (!itemCoverage) { itemCoverage = {}; } + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var itemWidth = GetFastValue(itemCoverage, 'width', GetFastValue(item, 'width', 1)); + var itemHeight = GetFastValue(itemCoverage, 'height', GetFastValue(item, 'height', 1)); + var itemOriginX = GetFastValue(itemCoverage, 'originX', GetFastValue(item, 'originX', 0.5)); + var itemOriginY = GetFastValue(itemCoverage, 'originY', GetFastValue(item, 'originY', 0.5)); + + // Reposition item. + item.x = region.x + region.width * itemOriginX; + item.y = region.y + region.height * itemOriginY; + + // Compute relative scales. + var itemScaleXToRegion = region.width / itemWidth; + var itemScaleYToRegion = region.height / itemHeight; + switch (scaleMode) + { + case -1: + { + // Scale to fit the inside of the region. + item.setScale(Math.min(itemScaleXToRegion, itemScaleYToRegion)); + break; + } + case 0: + { + // Scale both axes independently to match the region. + item.setScale(itemScaleXToRegion, itemScaleYToRegion); + break; + } + case 1: + { + // Scale to envelop the outside of the region. + item.setScale(Math.max(itemScaleXToRegion, itemScaleYToRegion)); + break; + } + } + } + + return item; +}; + +module.exports = FitToRegion; + + +/***/ }, + +/***/ 69927 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of objects and returns the first element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetFirst(group.getChildren(), compare, index)` + * + * @function Phaser.Actions.GetFirst + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The first object in the array that matches the comparison object, or `null` if no match was found. + */ +var GetFirst = function (items, compare, index) +{ + if (index === undefined) { index = 0; } + + for (var i = index; i < items.length; i++) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; +}; + +module.exports = GetFirst; + + +/***/ }, + +/***/ 32265 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of objects and returns the last element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetLast(group.getChildren(), compare, index)` + * + * @function Phaser.Actions.GetLast + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The last object in the array that matches the comparison object, or `null` if no match was found. + */ +var GetLast = function (items, compare, index) +{ + if (index === undefined) { index = 0; } + + for (var i = items.length - 1; i >= index; i--) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; +}; + +module.exports = GetLast; + + +/***/ }, + +/***/ 94420 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AlignIn = __webpack_require__(11879); +var CONST = __webpack_require__(60461); +var GetFastValue = __webpack_require__(95540); +var NOOP = __webpack_require__(29747); +var Zone = __webpack_require__(41481); + +var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1).setOrigin(0, 0); + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and positions them in a grid layout based on the configuration provided. + * + * The grid is defined by a `width` (number of columns) and/or `height` (number of rows). + * Each cell in the grid has a size defined by `cellWidth` and `cellHeight`, in pixels. + * Items are placed into cells starting from the top-left origin (`x`, `y`) and filling + * left-to-right, top-to-bottom by default. If only `width` is set to -1, items are laid + * out in a single horizontal row. If only `height` is set to -1, items are laid out in a + * single vertical column. When both `width` and `height` are set, the grid fills + * row-by-row, stopping early if the grid is full before all items have been placed. + * + * The `position` option controls how each item is aligned within its cell, using one of + * the `Phaser.Display.Align` constants such as `CENTER` or `TOP_LEFT`. + * + * @function Phaser.Actions.GridAlign + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {Phaser.Types.Actions.GridAlignConfig} options - The GridAlign Configuration object. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var GridAlign = function (items, options) +{ + if (options === undefined) { options = {}; } + + var widthSet = options.hasOwnProperty('width'); + var heightSet = options.hasOwnProperty('height'); + + var width = GetFastValue(options, 'width', -1); + var height = GetFastValue(options, 'height', -1); + + var cellWidth = GetFastValue(options, 'cellWidth', 1); + var cellHeight = GetFastValue(options, 'cellHeight', cellWidth); + + var position = GetFastValue(options, 'position', CONST.TOP_LEFT); + var x = GetFastValue(options, 'x', 0); + var y = GetFastValue(options, 'y', 0); + + var cx = 0; + var cy = 0; + var w = (width * cellWidth); + var h = (height * cellHeight); + + tempZone.setPosition(x, y); + tempZone.setSize(cellWidth, cellHeight); + + for (var i = 0; i < items.length; i++) + { + AlignIn(items[i], tempZone, position); + + if (widthSet && width === -1) + { + // We keep laying them out horizontally until we've done them all + tempZone.x += cellWidth; + } + else if (heightSet && height === -1) + { + // We keep laying them out vertically until we've done them all + tempZone.y += cellHeight; + } + else if (heightSet && !widthSet) + { + // We keep laying them out until we hit the column limit + cy += cellHeight; + tempZone.y += cellHeight; + + if (cy === h) + { + cy = 0; + cx += cellWidth; + tempZone.y = y; + tempZone.x += cellWidth; + + if (cx === w) + { + // We've hit the column limit, so return, even if there are items left + break; + } + } + } + else + { + // We keep laying them out until we hit the column limit + cx += cellWidth; + tempZone.x += cellWidth; + + if (cx === w) + { + cx = 0; + cy += cellHeight; + tempZone.x = x; + tempZone.y += cellHeight; + + if (cy === h) + { + // We've hit the column limit, so return, even if there are items left + break; + } + } + } + } + + return items; +}; + +module.exports = GridAlign; + + +/***/ }, + +/***/ 41721 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have a public `alpha` property, + * and then adds the given value to each of their `alpha` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncAlpha + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `alpha` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncAlpha = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'alpha', value, step, index, direction); +}; + +module.exports = IncAlpha; + + +/***/ }, + +/***/ 67285 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have a public `x` property, + * and then adds the given value to each of their `x` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `x` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'x', value, step, index, direction); +}; + +module.exports = IncX; + + +/***/ }, + +/***/ 9074 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.IncXY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to be added to the `x` property. + * @param {number} [y=x] - The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueInc(items, 'x', x, stepX, index, direction); + + return PropertyValueInc(items, 'y', y, stepY, index, direction); +}; + +module.exports = IncXY; + + +/***/ }, + +/***/ 75222 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have a public `y` property, + * and then adds the given value to each of their `y` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `y` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'y', value, step, index, direction); +}; + +module.exports = IncY; + + +/***/ }, + +/***/ 22983 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.PlaceOnCircle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnCircle = function (items, circle, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + var cx = circle.x; + var cy = circle.y; + var radius = circle.radius; + + for (var i = 0; i < items.length; i++) + { + items[i].x = cx + (radius * Math.cos(angle)); + items[i].y = cy + (radius * Math.sin(angle)); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnCircle; + + +/***/ }, + +/***/ 95253 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. + * + * Each Game Object's `x` and `y` properties are updated in place. The spacing between objects is determined + * by dividing the angular range (from `startAngle` to `endAngle`) evenly across the number of items. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.PlaceOnEllipse + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + var a = ellipse.width / 2; + var b = ellipse.height / 2; + + for (var i = 0; i < items.length; i++) + { + items[i].x = ellipse.x + a * Math.cos(angle); + items[i].y = ellipse.y + b * Math.sin(angle); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnEllipse; + + +/***/ }, + +/***/ 88505 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetPoints = __webpack_require__(15258); +var GetEasedPoints = __webpack_require__(26708); + +/** + * Positions an array of Game Objects along a Line, setting each object's `x` and `y` coordinates. + * By default the Game Objects are placed at evenly spaced intervals along the line. If the `ease` + * parameter is supplied, the spacing between points is controlled by that easing function instead, + * allowing for clustered or accelerating distributions along the line. + * + * @function Phaser.Actions.PlaceOnLine + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects on. + * @param {(string|function)} [ease] - An optional ease to apply to the point distribution. This can be either a string key from the EaseMap (e.g. `'Sine.easeInOut'`) or a custom easing function. If omitted, points are evenly spaced. + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnLine = function (items, line, ease) +{ + var points; + + if (ease) + { + points = GetEasedPoints(line, ease, items.length); + } + else + { + points = GetPoints(line, items.length); + } + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = points[i]; + + item.x = point.x; + item.y = point.y; + } + + return items; +}; + +module.exports = PlaceOnLine; + + +/***/ }, + +/***/ 41346 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MarchingAnts = __webpack_require__(14649); +var RotateLeft = __webpack_require__(86003); +var RotateRight = __webpack_require__(49498); + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. + * + * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. + * If the `shift` parameter is given you can offset where placement begins. + * + * @function Phaser.Actions.PlaceOnRectangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on. + * @param {number} [shift=0] - An optional starting offset, in number of steps. A positive value shifts the starting position clockwise around the perimeter, a negative value shifts it counter-clockwise. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnRectangle = function (items, rect, shift) +{ + if (shift === undefined) { shift = 0; } + + var points = MarchingAnts(rect, false, items.length); + + if (shift > 0) + { + RotateLeft(points, shift); + } + else if (shift < 0) + { + RotateRight(points, Math.abs(shift)); + } + + for (var i = 0; i < items.length; i++) + { + items[i].x = points[i].x; + items[i].y = points[i].y; + } + + return items; +}; + +module.exports = PlaceOnRectangle; + + +/***/ }, + +/***/ 11575 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BresenhamPoints = __webpack_require__(84993); + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.PlaceOnTriangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects on. + * @param {number} [stepRate=1] - An optional step rate that controls the density of points sampled along each edge of the Triangle using Bresenham's line algorithm. A higher value produces fewer, more widely spaced points; a lower value produces more points and denser placement. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnTriangle = function (items, triangle, stepRate) +{ + var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate); + var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate); + var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate); + + // Remove overlaps + p1.pop(); + p2.pop(); + p3.pop(); + + p1 = p1.concat(p2, p3); + + var step = p1.length / items.length; + var p = 0; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = p1[Math.floor(p)]; + + item.x = point.x; + item.y = point.y; + + p += step; + } + + return items; +}; + +module.exports = PlaceOnTriangle; + + +/***/ }, + +/***/ 29953 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Play an animation on all Game Objects in the array that have an Animation component. + * + * You can pass either an animation key, or an animation configuration object for more control over the playback. + * + * @function Phaser.Actions.PlayAnimation + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {boolean} [ignoreIfPlaying=false] - If this animation is already playing then ignore this call. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlayAnimation = function (items, key, ignoreIfPlaying) +{ + for (var i = 0; i < items.length; i++) + { + var gameObject = items[i]; + + if (gameObject.anims) + { + gameObject.anims.play(key, ignoreIfPlaying); + } + } + + return items; +}; + +module.exports = PlayAnimation; + + +/***/ }, + +/***/ 66979 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then adds the given value to it. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueInc + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to be added to the property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var PropertyValueInc = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] += value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] += value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueInc; + + +/***/ }, + +/***/ 43967 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueSet + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var PropertyValueSet = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] = value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] = value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueSet; + + +/***/ }, + +/***/ 88926 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Random = __webpack_require__(28176); + +/** + * Takes an array of Game Objects and positions them at random locations within the Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomCircle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomCircle = function (items, circle) +{ + for (var i = 0; i < items.length; i++) + { + Random(circle, items[i]); + } + + return items; +}; + +module.exports = RandomCircle; + + +/***/ }, + +/***/ 33286 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Random = __webpack_require__(24820); + +/** + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomEllipse + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomEllipse = function (items, ellipse) +{ + for (var i = 0; i < items.length; i++) + { + Random(ellipse, items[i]); + } + + return items; +}; + +module.exports = RandomEllipse; + + +/***/ }, + +/***/ 96000 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Random = __webpack_require__(65822); + +/** + * Takes an array of Game Objects and positions them at random locations on the Line. + * + * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomLine + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects randomly on. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomLine = function (items, line) +{ + for (var i = 0; i < items.length; i++) + { + Random(line, items[i]); + } + + return items; +}; + +module.exports = RandomLine; + + +/***/ }, + +/***/ 28789 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Random = __webpack_require__(26597); + +/** + * Takes an array of Game Objects and positions them at random locations within the Rectangle. + * + * @function Phaser.Actions.RandomRectangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomRectangle = function (items, rect) +{ + for (var i = 0; i < items.length; i++) + { + Random(rect, items[i]); + } + + return items; +}; + +module.exports = RandomRectangle; + + +/***/ }, + +/***/ 97154 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Random = __webpack_require__(90260); + +/** + * Takes an array of Game Objects and positions them at random locations within the Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomTriangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomTriangle = function (items, triangle) +{ + for (var i = 0; i < items.length; i++) + { + Random(triangle, items[i]); + } + + return items; +}; + +module.exports = RandomTriangle; + + +/***/ }, + +/***/ 20510 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have a public `rotation` property, + * and then adds the given value to each of their `rotation` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Rotate(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Rotate + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `rotation` property (in radians). + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var Rotate = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'rotation', value, step, index, direction); +}; + +module.exports = Rotate; + + +/***/ }, + +/***/ 91051 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RotateAroundDistance = __webpack_require__(1163); +var DistanceBetween = __webpack_require__(20339); + +/** + * Rotates each item around the given point by the given angle. + * + * @function Phaser.Actions.RotateAround + * @since 3.0.0 + * @see Phaser.Math.RotateAroundDistance + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RotateAround = function (items, point, angle) +{ + var x = point.x; + var y = point.y; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y))); + } + + return items; +}; + +module.exports = RotateAround; + + +/***/ }, + +/***/ 76332 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MathRotateAroundDistance = __webpack_require__(1163); + +/** + * Rotates each Game Object in the given array around a point by the specified angle, positioning each item at the given distance from that point. If the distance is zero, the items are not moved. + * + * @function Phaser.Actions.RotateAroundDistance + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * @param {number} distance - The distance from the point of rotation in pixels. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RotateAroundDistance = function (items, point, angle, distance) +{ + var x = point.x; + var y = point.y; + + // There's nothing to do + if (distance === 0) + { + return items; + } + + for (var i = 0; i < items.length; i++) + { + MathRotateAroundDistance(items[i], x, y, angle, distance); + } + + return items; +}; + +module.exports = RotateAroundDistance; + + +/***/ }, + +/***/ 61619 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleX` property, + * and then adds the given value to each of their `scaleX` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleX` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var ScaleX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleX', value, step, index, direction); +}; + +module.exports = ScaleX; + + +/***/ }, + +/***/ 94868 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.ScaleXY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to be added to the `scaleX` property. + * @param {number} [scaleY] - The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = ScaleXY; + + +/***/ }, + +/***/ 95532 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueInc = __webpack_require__(66979); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleY` property, + * and then adds the given value to each of their `scaleY` properties. + * + * The optional `step` parameter is applied incrementally, multiplied by the iteration index of each item in the array. + * + * To use this with a Group: `ScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleY` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var ScaleY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleY', value, step, index, direction); +}; + +module.exports = ScaleY; + + +/***/ }, + +/***/ 8689 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `alpha` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by the iteration index and added to `value`. + * + * To use this with a Group: `SetAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetAlpha + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The alpha value to set on each item. Should be in the range 0 (fully transparent) to 1 (fully opaque). + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetAlpha = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'alpha', value, step, index, direction); +}; + +module.exports = SetAlpha; + + +/***/ }, + +/***/ 2645 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `blendMode` + * and then sets it to the given value. + * + * To use this with a Group: `SetBlendMode(group.getChildren(), value)` + * + * @function Phaser.Actions.SetBlendMode + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {(Phaser.BlendModes|string|number)} value - The Blend Mode to be set. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetBlendMode = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'blendMode', value, 0, index, direction); +}; + +module.exports = SetBlendMode; + + +/***/ }, + +/***/ 32372 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `depth`, + * and then sets it to the given value. The `depth` property controls the rendering order + * of Game Objects within a Scene: objects with higher depth values are rendered on top + * of those with lower values. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetDepth(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetDepth + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The depth value to assign to each item. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetDepth = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'depth', value, step, index, direction); +}; + +module.exports = SetDepth; + + +/***/ }, + +/***/ 85373 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Iterates over all items in the given array and calls `setInteractive` on each one, applying the same hit area shape and callback to every Game Object in the array. + * + * @see {@link Phaser.GameObjects.GameObject#setInteractive} + * + * @function Phaser.Actions.SetHitArea + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. + * @param {Phaser.Types.Input.HitAreaCallback} [hitAreaCallback] - The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SetHitArea = function (items, hitArea, hitAreaCallback) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setInteractive(hitArea, hitAreaCallback); + } + + return items; +}; + +module.exports = SetHitArea; + + +/***/ }, + +/***/ 81583 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)` + * + * @function Phaser.Actions.SetOrigin + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} originX - The amount to set the `originX` property to. + * @param {number} [originY] - The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. + * @param {number} [stepX=0] - This is added to the `originX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `originY` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction) +{ + if (originY === undefined || originY === null) { originY = originX; } + + PropertyValueSet(items, 'originX', originX, stepX, index, direction); + PropertyValueSet(items, 'originY', originY, stepY, index, direction); + + items.forEach(function (item) + { + item.updateDisplayOrigin(); + }); + + return items; +}; + +module.exports = SetOrigin; + + +/***/ }, + +/***/ 79939 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `rotation` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetRotation(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetRotation + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to (in radians). + * @param {number} [step=0] - This value, multiplied by the iteration index, is added to `value` for each successive item, resulting in each object receiving a progressively stepped rotation (in radians). + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetRotation = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'rotation', value, step, index, direction); +}; + +module.exports = SetRotation; + + +/***/ }, + +/***/ 2699 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.SetScale + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to set the `scaleX` property to. + * @param {number} [scaleY] - The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = SetScale; + + +/***/ }, + +/***/ 98739 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleX` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by the iteration counter. + * + * To use this with a Group: `SetScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The value to set the `scaleX` property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScaleX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleX', value, step, index, direction); +}; + +module.exports = SetScaleX; + + +/***/ }, + +/***/ 98476 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleY` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by the iteration counter. + * + * To use this with a Group: `SetScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScaleY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleY', value, step, index, direction); +}; + +module.exports = SetScaleY; + + +/***/ }, + +/***/ 6207 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `scrollFactorX` and `scrollFactorY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScrollFactor(group.getChildren(), scrollFactorX, scrollFactorY, stepX, stepY)` + * + * @function Phaser.Actions.SetScrollFactor + * @since 3.21.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scrollFactorX - The amount to set the `scrollFactorX` property to. + * @param {number} [scrollFactorY] - The amount to set the `scrollFactorY` property to. If `undefined` or `null` it uses the `scrollFactorX` value. + * @param {number} [stepX=0] - This is added to the `scrollFactorX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `scrollFactorY` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScrollFactor = function (items, scrollFactorX, scrollFactorY, stepX, stepY, index, direction) +{ + if (scrollFactorY === undefined || scrollFactorY === null) { scrollFactorY = scrollFactorX; } + + PropertyValueSet(items, 'scrollFactorX', scrollFactorX, stepX, index, direction); + + return PropertyValueSet(items, 'scrollFactorY', scrollFactorY, stepY, index, direction); +}; + +module.exports = SetScrollFactor; + + +/***/ }, + +/***/ 6607 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scrollFactorX` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScrollFactorX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScrollFactorX + * @since 3.21.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScrollFactorX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scrollFactorX', value, step, index, direction); +}; + +module.exports = SetScrollFactorX; + + +/***/ }, + +/***/ 72248 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scrollFactorY` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScrollFactorY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScrollFactorY + * @since 3.21.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScrollFactorY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scrollFactorY', value, step, index, direction); +}; + +module.exports = SetScrollFactorY; + + +/***/ }, + +/***/ 14036 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have the public method setTint(), and then updates the tint of each to the given value(s). You can specify a tint color per corner or provide only one color value for the `topLeft` parameter, in which case the whole item will be tinted with that color. + * + * @function Phaser.Actions.SetTint + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {number} topLeft - The tint to be applied to the top-left corner of each item. If the other parameters are omitted, this tint will be applied to the whole item. + * @param {number} [topRight] - The tint to be applied to top-right corner of item. + * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. + * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setTint(topLeft, topRight, bottomLeft, bottomRight); + } + + return items; +}; + +module.exports = SetTint; + + +/***/ }, + +/***/ 50159 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `visible` + * and then sets it to the given value. + * + * To use this with a Group: `SetVisible(group.getChildren(), value)` + * + * @function Phaser.Actions.SetVisible + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {boolean} value - The visible state to set on each item. Set to `true` to make items visible, or `false` to hide them. + * @param {number} [index=0] - An optional offset to start iterating from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetVisible = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'visible', value, 0, index, direction); +}; + +module.exports = SetVisible; + + +/***/ }, + +/***/ 77597 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `x` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The x coordinate, in pixels, to set on each item. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration index, so that each item receives a progressively increasing x offset. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'x', value, step, index, direction); +}; + +module.exports = SetX; + + +/***/ }, + +/***/ 83194 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `x` and `y` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.SetXY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to set the `x` property to. + * @param {number} [y=x] - The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueSet(items, 'x', x, stepX, index, direction); + + return PropertyValueSet(items, 'y', y, stepY, index, direction); +}; + +module.exports = SetXY; + + +/***/ }, + +/***/ 67678 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PropertyValueSet = __webpack_require__(43967); + +/** + * Takes an array of Game Objects, or any objects that have the public property `y` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'y', value, step, index, direction); +}; + +module.exports = SetY; + + +/***/ }, + +/***/ 35850 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Takes an array of items, such as Game Objects, or any objects with public `x` and + * `y` properties and then iterates through them. As this function iterates, it moves + * the position of the current element to be that of the previous entry in the array. + * This repeats until all items have been moved. + * + * The direction controls the order of iteration. A value of 0 (the default) assumes + * that the final item in the array is the 'head' item. + * + * A direction value of 1 assumes that the first item in the array is the 'head' item. + * + * The position of the 'head' item is set to the x/y values given to this function. + * Every other item in the array is then updated, in sequence, to be that of the + * previous (or next) entry in the array. + * + * The final x/y coords are returned, or set in the 'output' Vector2. + * + * Think of it as being like the game Snake, where the 'head' is moved and then + * each body piece is moved into the space of the previous piece. + * + * @function Phaser.Actions.ShiftPosition + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items] + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {(Phaser.Types.Math.Vector2Like[]|Phaser.GameObjects.GameObject[])} items - An array of Game Objects, or objects with public x and y positions. The contents of this array are updated by this Action. + * @param {number} x - The x coordinate to place the head item at. + * @param {number} y - The y coordinate to place the head item at. + * @param {number} [direction=0] - The iteration direction. 0 = last to first and 1 = first to last. + * @param {Phaser.Types.Math.Vector2Like} [output] - An optional Vec2Like object to store the final position in. + * + * @return {Phaser.Types.Math.Vector2Like} The output vector. + */ +var ShiftPosition = function (items, x, y, direction, output) +{ + if (direction === undefined) { direction = 0; } + if (output === undefined) { output = new Vector2(); } + + var px; + var py; + var len = items.length; + + if (len === 1) + { + px = items[0].x; + py = items[0].y; + + items[0].x = x; + items[0].y = y; + } + else + { + var i = 1; + var pos = 0; + + if (direction === 0) + { + pos = len - 1; + i = len - 2; + } + + px = items[pos].x; + py = items[pos].y; + + // Update the head item to the new x/y coordinates + items[pos].x = x; + items[pos].y = y; + + for (var c = 0; c < len; c++) + { + if (i >= len || i === -1) + { + continue; + } + + // Current item + var cur = items[i]; + + // Get current item x/y, to be passed to the next item in the list + var cx = cur.x; + var cy = cur.y; + + // Set current item to the previous items x/y + cur.x = px; + cur.y = py; + + // Set current as previous + px = cx; + py = cy; + + if (direction === 0) + { + i--; + } + else + { + i++; + } + } + } + + // Return the final set of coordinates as they're effectively lost from the shift and may be needed + + output.x = px; + output.y = py; + + return output; +}; + +module.exports = ShiftPosition; + + +/***/ }, + +/***/ 8628 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ArrayShuffle = __webpack_require__(33680); + +/** + * Shuffles the array in place. The shuffled array is both modified and returned. + * + * @function Phaser.Actions.Shuffle + * @since 3.0.0 + * @see Phaser.Utils.Array.Shuffle + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var Shuffle = function (items) +{ + return ArrayShuffle(items); +}; + +module.exports = Shuffle; + + +/***/ }, + +/***/ 21837 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MathSmoothStep = __webpack_require__(7602); + +/** + * Takes an array of Game Objects and distributes values across the specified property using + * smoothstep interpolation. Each item in the array is assigned a smoothstep-interpolated value + * based on its position, creating a smooth ease-in/ease-out transition across the items. + * + * Smoothstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" + * and the "right edge", with the left edge being assumed smaller than the right edge. + * + * The function receives a real number x as an argument and returns 0 if x is less than + * or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly + * interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the + * smoothstep function is zero at both edges. + * + * This is convenient for creating a sequence of transitions using smoothstep to interpolate + * each segment as an alternative to using more sophisticated or expensive interpolation techniques. + * + * @function Phaser.Actions.SmoothStep + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The left edge of the smoothstep. This value should be smaller than `max`. + * @param {number} max - The right edge of the smoothstep. This value should be larger than `min`. + * @param {boolean} [inc=false] - Should the property value be incremented (`true`) or set (`false`)? + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SmoothStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmoothStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmoothStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmoothStep; + + +/***/ }, + +/***/ 21910 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MathSmootherStep = __webpack_require__(54261); + +/** + * Takes an array of Game Objects and distributes values across the specified property using + * smootherstep interpolation. Each item in the array is assigned a smootherstep-interpolated + * value based on its position, creating an even smoother transition than SmoothStep. + * + * Smootherstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smootherstep function is zero at both edges. This is convenient for creating a sequence of transitions using smootherstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. + * + * @function Phaser.Actions.SmootherStep + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - If `true`, the values are incremented. If `false` (default), the values are set. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SmootherStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmootherStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmootherStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmootherStep; + + +/***/ }, + +/***/ 62054 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, by the + * calculated spread value. + * + * The spread value is derived from the given `min` and `max` values and the total number of items in the array. + * + * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: + * + * ```javascript + * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); + * ``` + * + * @function Phaser.Actions.Spread + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - The property of the Game Object to spread. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * @param {boolean} [inc=false] - Should the values be incremented (`true`) or set directly (`false`)? + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that were passed to this Action. + */ +var Spread = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + if (items.length === 0) { return items; } + if (items.length === 1) // if only one item put it at the center + { + if (inc) + { + items[0][property] += (max + min) / 2; + } + else + { + items[0][property] = (max + min) / 2; + } + + return items; + } + + var step = Math.abs(max - min) / (items.length - 1); + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += i * step + min; + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = i * step + min; + } + } + + return items; +}; + +module.exports = Spread; + + +/***/ }, + +/***/ 79815 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes an array of Game Objects and toggles the visibility of each one. + * Those previously `visible = false` will become `visible = true`, and vice versa. + * + * @function Phaser.Actions.ToggleVisible + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var ToggleVisible = function (items) +{ + for (var i = 0; i < items.length; i++) + { + items[i].visible = !items[i].visible; + } + + return items; +}; + +module.exports = ToggleVisible; + + +/***/ }, + +/***/ 39665 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author samme + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Wrap = __webpack_require__(15994); + +/** + * Iterates through the given array and makes sure that each object's x and y + * properties are wrapped to keep them contained within the given Rectangle's + * area. + * + * @function Phaser.Actions.WrapInRectangle + * @since 3.0.0 + * @see Phaser.Math.Wrap + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The rectangle which the objects will be wrapped to remain within. + * @param {number} [padding=0] - An amount added to each side of the rectangle during the operation. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var WrapInRectangle = function (items, rect, padding) +{ + if (padding === undefined) + { + padding = 0; + } + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + item.x = Wrap(item.x, rect.left - padding, rect.right + padding); + item.y = Wrap(item.y, rect.top - padding, rect.bottom + padding); + } + + return items; +}; + +module.exports = WrapInRectangle; + + +/***/ }, + +/***/ 61061 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Actions + */ + +module.exports = { + + AddEffectBloom: __webpack_require__(93300), + AddEffectShine: __webpack_require__(56704), + AddMaskShape: __webpack_require__(245), + AlignTo: __webpack_require__(11517), + Angle: __webpack_require__(80318), + Call: __webpack_require__(60757), + FitToRegion: __webpack_require__(94591), + GetFirst: __webpack_require__(69927), + GetLast: __webpack_require__(32265), + GridAlign: __webpack_require__(94420), + IncAlpha: __webpack_require__(41721), + IncX: __webpack_require__(67285), + IncXY: __webpack_require__(9074), + IncY: __webpack_require__(75222), + PlaceOnCircle: __webpack_require__(22983), + PlaceOnEllipse: __webpack_require__(95253), + PlaceOnLine: __webpack_require__(88505), + PlaceOnRectangle: __webpack_require__(41346), + PlaceOnTriangle: __webpack_require__(11575), + PlayAnimation: __webpack_require__(29953), + PropertyValueInc: __webpack_require__(66979), + PropertyValueSet: __webpack_require__(43967), + RandomCircle: __webpack_require__(88926), + RandomEllipse: __webpack_require__(33286), + RandomLine: __webpack_require__(96000), + RandomRectangle: __webpack_require__(28789), + RandomTriangle: __webpack_require__(97154), + Rotate: __webpack_require__(20510), + RotateAround: __webpack_require__(91051), + RotateAroundDistance: __webpack_require__(76332), + ScaleX: __webpack_require__(61619), + ScaleXY: __webpack_require__(94868), + ScaleY: __webpack_require__(95532), + SetAlpha: __webpack_require__(8689), + SetBlendMode: __webpack_require__(2645), + SetDepth: __webpack_require__(32372), + SetHitArea: __webpack_require__(85373), + SetOrigin: __webpack_require__(81583), + SetRotation: __webpack_require__(79939), + SetScale: __webpack_require__(2699), + SetScaleX: __webpack_require__(98739), + SetScaleY: __webpack_require__(98476), + SetScrollFactor: __webpack_require__(6207), + SetScrollFactorX: __webpack_require__(6607), + SetScrollFactorY: __webpack_require__(72248), + SetTint: __webpack_require__(14036), + SetVisible: __webpack_require__(50159), + SetX: __webpack_require__(77597), + SetXY: __webpack_require__(83194), + SetY: __webpack_require__(67678), + ShiftPosition: __webpack_require__(35850), + Shuffle: __webpack_require__(8628), + SmootherStep: __webpack_require__(21910), + SmoothStep: __webpack_require__(21837), + Spread: __webpack_require__(62054), + ToggleVisible: __webpack_require__(79815), + WrapInRectangle: __webpack_require__(39665) + +}; + + +/***/ }, + +/***/ 42099 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(74943); +var FindClosestInSorted = __webpack_require__(81957); +var Frame = __webpack_require__(41138); +var GetValue = __webpack_require__(35154); +var SortByDigits = __webpack_require__(90126); + +/** + * @classdesc + * A Frame based Animation. + * + * Animations in Phaser consist of a sequence of `AnimationFrame` objects, which are managed by + * this class, along with properties that impact playback, such as the animation's frame rate + * or delay. + * + * This class contains all of the properties and methods needed to handle playback of the animation + * directly to an `AnimationState` instance, which is owned by a Sprite, or similar Game Object. + * + * You don't typically create an instance of this class directly, but instead go via + * either the `AnimationManager` or the `AnimationState` and use their `create` methods, + * depending on if you need a global animation, or local to a specific Sprite. + * + * @class Animation + * @memberof Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationManager} manager - A reference to the global Animation Manager + * @param {string} key - The unique identifying string for this animation. + * @param {Phaser.Types.Animations.Animation} config - The Animation configuration. + */ +var Animation = new Class({ + + initialize: + + function Animation (manager, key, config) + { + /** + * A reference to the global Animation Manager. + * + * @name Phaser.Animations.Animation#manager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The unique identifying string for this animation. + * + * @name Phaser.Animations.Animation#key + * @type {string} + * @since 3.0.0 + */ + this.key = key; + + /** + * A frame-based animation (as opposed to a bone-based animation). + * + * @name Phaser.Animations.Animation#type + * @type {string} + * @default frame + * @since 3.0.0 + */ + this.type = 'frame'; + + /** + * An array of AnimationFrame objects that make up this animation. + * + * @name Phaser.Animations.Animation#frames + * @type {Phaser.Animations.AnimationFrame[]} + * @since 3.0.0 + */ + this.frames = this.getFrames( + manager.textureManager, + GetValue(config, 'frames', []), + GetValue(config, 'defaultTextureKey', null), + GetValue(config, 'sortFrames', true) + ); + + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + * + * @name Phaser.Animations.Animation#frameRate + * @type {number} + * @default 24 + * @since 3.0.0 + */ + this.frameRate = GetValue(config, 'frameRate', null); + + /** + * How long the animation should play for, in milliseconds. + * If the `frameRate` property has been set then it overrides this value, + * otherwise the `frameRate` is derived from `duration`. + * + * @name Phaser.Animations.Animation#duration + * @type {number} + * @since 3.0.0 + */ + this.duration = GetValue(config, 'duration', null); + + /** + * How many ms per frame, not including frame-specific modifiers. + * + * @name Phaser.Animations.Animation#msPerFrame + * @type {number} + * @since 3.0.0 + */ + this.msPerFrame; + + /** + * Skip frames if the time lags, or always advance anyway? + * + * @name Phaser.Animations.Animation#skipMissedFrames + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); + + /** + * The delay in ms before the playback will begin. + * + * @name Phaser.Animations.Animation#delay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.delay = GetValue(config, 'delay', 0); + + /** + * Number of times to repeat the animation. Set to -1 to repeat forever. + * + * @name Phaser.Animations.Animation#repeat + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeat = GetValue(config, 'repeat', 0); + + /** + * The delay in ms before a repeat play starts. + * + * @name Phaser.Animations.Animation#repeatDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatDelay = GetValue(config, 'repeatDelay', 0); + + /** + * Should the animation yoyo (reverse back down to the start) before repeating? + * + * @name Phaser.Animations.Animation#yoyo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.yoyo = GetValue(config, 'yoyo', false); + + /** + * If the animation has a delay set, before playback will begin, this + * controls when the first frame is set on the Sprite. If this property + * is 'false' then the frame is set only after the delay has expired. + * This is the default behavior. + * + * @name Phaser.Animations.Animation#showBeforeDelay + * @type {boolean} + * @default false + * @since 3.60.0 + */ + this.showBeforeDelay = GetValue(config, 'showBeforeDelay', false); + + /** + * Should the GameObject's `visible` property be set to `true` when the animation starts to play? + * + * @name Phaser.Animations.Animation#showOnStart + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.showOnStart = GetValue(config, 'showOnStart', false); + + /** + * Should the GameObject's `visible` property be set to `false` when the animation finishes? + * + * @name Phaser.Animations.Animation#hideOnComplete + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.hideOnComplete = GetValue(config, 'hideOnComplete', false); + + /** + * Start playback of this animation from a random frame? + * + * @name Phaser.Animations.Animation#randomFrame + * @type {boolean} + * @default false + * @since 3.60.0 + */ + this.randomFrame = GetValue(config, 'randomFrame', false); + + /** + * Global pause. All Game Objects using this Animation instance are impacted by this property. + * + * @name Phaser.Animations.Animation#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + this.calculateDuration(this, this.getTotalFrames(), this.duration, this.frameRate); + + if (this.manager.on) + { + this.manager.on(Events.PAUSE_ALL, this.pause, this); + this.manager.on(Events.RESUME_ALL, this.resume, this); + } + }, + + /** + * Gets the total number of frames in this animation. + * + * @method Phaser.Animations.Animation#getTotalFrames + * @since 3.50.0 + * + * @return {number} The total number of frames in this animation. + */ + getTotalFrames: function () + { + return this.frames.length; + }, + + /** + * Calculates the duration, frame rate and msPerFrame values. + * + * @method Phaser.Animations.Animation#calculateDuration + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} target - The target to set the values on. + * @param {number} totalFrames - The total number of frames in the animation. + * @param {?number} [duration] - The duration to calculate the frame rate from. Pass `null` if you wish to set the `frameRate` instead. + * @param {?number} [frameRate] - The frame rate to calculate the duration from. + */ + calculateDuration: function (target, totalFrames, duration, frameRate) + { + if (duration === null && frameRate === null) + { + // No duration or frameRate given, use default frameRate of 24fps + target.frameRate = 24; + target.duration = (24 / totalFrames) * 1000; + } + else if (duration && frameRate === null) + { + // Duration given but no frameRate, so set the frameRate based on duration + // I.e. 12 frames in the animation, duration = 4000 ms + // So frameRate is 12 / (4000 / 1000) = 3 fps + target.duration = duration; + target.frameRate = totalFrames / (duration / 1000); + } + else + { + // frameRate given, derive duration from it (even if duration also specified) + // I.e. 15 frames in the animation, frameRate = 30 fps + // So duration is 15 / 30 = 0.5 * 1000 (half a second, or 500ms) + target.frameRate = frameRate; + target.duration = (totalFrames / frameRate) * 1000; + } + + target.msPerFrame = 1000 / target.frameRate; + }, + + /** + * Add frames to the end of the animation. + * + * @method Phaser.Animations.Animation#addFrame + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects. + * + * @return {this} This Animation object. + */ + addFrame: function (config) + { + return this.addFrameAt(this.frames.length, config); + }, + + /** + * Inserts one or more frames into the animation at the specified index. + * + * @method Phaser.Animations.Animation#addFrameAt + * @since 3.0.0 + * + * @param {number} index - The index to insert the frame at within the animation. + * @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects. + * + * @return {this} This Animation object. + */ + addFrameAt: function (index, config) + { + var newFrames = this.getFrames(this.manager.textureManager, config); + + if (newFrames.length > 0) + { + if (index === 0) + { + this.frames = newFrames.concat(this.frames); + } + else if (index === this.frames.length) + { + this.frames = this.frames.concat(newFrames); + } + else + { + var pre = this.frames.slice(0, index); + var post = this.frames.slice(index); + + this.frames = pre.concat(newFrames, post); + } + + this.updateFrameSequence(); + } + + return this; + }, + + /** + * Check if the given frame index is valid. + * + * @method Phaser.Animations.Animation#checkFrame + * @since 3.0.0 + * + * @param {number} index - The index to be checked. + * + * @return {boolean} `true` if the index is valid, otherwise `false`. + */ + checkFrame: function (index) + { + return (index >= 0 && index < this.frames.length); + }, + + /** + * Called internally when this Animation first starts to play. + * Sets the accumulator and nextTick properties. + * + * @method Phaser.Animations.Animation#getFirstTick + * @protected + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. + */ + getFirstTick: function (state) + { + // When is the first update due? + state.accumulator = 0; + + state.nextTick = state.frameRate === state.currentAnim.frameRate ? state.currentFrame.duration || state.msPerFrame : state.msPerFrame; + }, + + /** + * Returns the AnimationFrame at the provided index + * + * @method Phaser.Animations.Animation#getFrameAt + * @since 3.0.0 + * + * @param {number} index - The index in the AnimationFrame array + * + * @return {Phaser.Animations.AnimationFrame} The frame at the index provided from the animation sequence + */ + getFrameAt: function (index) + { + return this.frames[index]; + }, + + /** + * Creates AnimationFrame instances based on the given frame data. + * + * @method Phaser.Animations.Animation#getFrames + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureManager} textureManager - A reference to the global Texture Manager. + * @param {(string|Phaser.Types.Animations.AnimationFrame[])} frames - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects. + * @param {string} [defaultTextureKey] - The key to use if no key is set in the frame configuration object. + * + * @return {Phaser.Animations.AnimationFrame[]} An array of newly created AnimationFrame instances. + */ + getFrames: function (textureManager, frames, defaultTextureKey, sortFrames) + { + if (sortFrames === undefined) { sortFrames = true; } + + var out = []; + var prev; + var animationFrame; + var index = 1; + var i; + var textureKey; + + // if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet + if (typeof frames === 'string') + { + textureKey = frames; + + if (!textureManager.exists(textureKey)) + { + console.warn('Texture "%s" not found', textureKey); + + return out; + } + + var texture = textureManager.get(textureKey); + var frameKeys = texture.getFrameNames(); + + if (sortFrames) + { + SortByDigits(frameKeys); + } + + frames = []; + + frameKeys.forEach(function (value) + { + frames.push({ key: textureKey, frame: value }); + }); + } + + if (!Array.isArray(frames) || frames.length === 0) + { + return out; + } + + for (i = 0; i < frames.length; i++) + { + var item = frames[i]; + + var key = GetValue(item, 'key', defaultTextureKey); + + if (!key) + { + continue; + } + + // Could be an integer or a string + var frame = GetValue(item, 'frame', 0); + + // The actual texture frame + var textureFrame = textureManager.getFrame(key, frame); + + if (!textureFrame) + { + console.warn('Texture "%s" not found', key); + + continue; + } + + animationFrame = new Frame(key, frame, index, textureFrame); + + animationFrame.duration = GetValue(item, 'duration', 0); + + animationFrame.isFirst = (!prev); + + // The previously created animationFrame + if (prev) + { + prev.nextFrame = animationFrame; + + animationFrame.prevFrame = prev; + } + + out.push(animationFrame); + + prev = animationFrame; + + index++; + } + + if (out.length > 0) + { + animationFrame.isLast = true; + + // Link them end-to-end, so they loop + animationFrame.nextFrame = out[0]; + + out[0].prevFrame = animationFrame; + + // Generate the progress data + + var slice = 1 / (out.length - 1); + + for (i = 0; i < out.length; i++) + { + out[i].progress = i * slice; + } + } + + return out; + }, + + /** + * Called internally. Sets the accumulator and nextTick values of the current Animation. + * + * @method Phaser.Animations.Animation#getNextTick + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. + */ + getNextTick: function (state) + { + state.accumulator -= state.nextTick; + + state.nextTick = state.frameRate === state.currentAnim.frameRate ? state.currentFrame.duration || state.msPerFrame : state.msPerFrame; + }, + + /** + * Returns the frame closest to the given progress value between 0 and 1. + * + * @method Phaser.Animations.Animation#getFrameByProgress + * @since 3.4.0 + * + * @param {number} value - A value between 0 and 1. + * + * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. + */ + getFrameByProgress: function (value) + { + value = Clamp(value, 0, 1); + + return FindClosestInSorted(value, this.frames, 'progress'); + }, + + /** + * Advance the animation frame. + * + * @method Phaser.Animations.Animation#nextFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationState} state - The Animation State to advance. + */ + nextFrame: function (state) + { + var frame = state.currentFrame; + + if (frame.isLast) + { + // We're at the end of the animation + + // Yoyo? (happens before repeat) + if (state.yoyo) + { + this.handleYoyoFrame(state, false); + } + else if (state.repeatCounter > 0) + { + // Repeat (happens before complete) + + if (state.inReverse && state.forward) + { + state.forward = false; + } + else + { + this.repeatAnimation(state); + } + } + else + { + state.complete(); + } + } + else + { + this.updateAndGetNextTick(state, frame.nextFrame); + } + }, + + /** + * Handle the yoyo functionality in nextFrame and previousFrame methods. + * + * @method Phaser.Animations.Animation#handleYoyoFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.Animations.AnimationState} state - The Animation State to advance. + * @param {boolean} isReverse - Is animation in reverse mode? (Default: false) + */ + handleYoyoFrame: function (state, isReverse) + { + if (!isReverse) { isReverse = false; } + + if (state.inReverse === !isReverse && state.repeatCounter > 0) + { + if (state.repeatDelay === 0 || state.pendingRepeat) + { + state.forward = isReverse; + } + + this.repeatAnimation(state); + + return; + } + + if (state.inReverse !== isReverse && state.repeatCounter === 0) + { + state.complete(); + + return; + } + + state.forward = isReverse; + + var frame = (isReverse) ? state.currentFrame.nextFrame : state.currentFrame.prevFrame; + + this.updateAndGetNextTick(state, frame); + }, + + /** + * Returns the last frame in this animation. + * + * @method Phaser.Animations.Animation#getLastFrame + * @since 3.12.0 + * + * @return {Phaser.Animations.AnimationFrame} The last Animation Frame. + */ + getLastFrame: function () + { + return this.frames[this.frames.length - 1]; + }, + + /** + * Called internally when the Animation is playing backwards. + * Sets the previous frame, causing a yoyo, repeat, complete or update, accordingly. + * + * @method Phaser.Animations.Animation#previousFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. + */ + previousFrame: function (state) + { + var frame = state.currentFrame; + + if (frame.isFirst) + { + // We're at the start of the animation + if (state.yoyo) + { + this.handleYoyoFrame(state, true); + } + else if (state.repeatCounter > 0) + { + if (state.inReverse && !state.forward) + { + this.repeatAnimation(state); + } + else + { + // Repeat (happens before complete) + state.forward = true; + + this.repeatAnimation(state); + } + } + else + { + state.complete(); + } + } + else + { + this.updateAndGetNextTick(state, frame.prevFrame); + } + }, + + /** + * Update Frame and Wait next tick. + * + * @method Phaser.Animations.Animation#updateAndGetNextTick + * @private + * @since 3.12.0 + * + * @param {Phaser.Animations.AnimationState} state - The Animation State. + * @param {Phaser.Animations.AnimationFrame} frame - An Animation frame. + */ + updateAndGetNextTick: function (state, frame) + { + state.setCurrentFrame(frame); + + this.getNextTick(state); + }, + + /** + * Removes the given AnimationFrame from this Animation instance. + * This is a global action. Any Game Object using this Animation will be impacted by this change. + * + * @method Phaser.Animations.Animation#removeFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - The AnimationFrame to be removed. + * + * @return {this} This Animation object. + */ + removeFrame: function (frame) + { + var index = this.frames.indexOf(frame); + + if (index !== -1) + { + this.removeFrameAt(index); + } + + return this; + }, + + /** + * Removes a frame from the AnimationFrame array at the provided index + * and updates the animation accordingly. + * + * @method Phaser.Animations.Animation#removeFrameAt + * @since 3.0.0 + * + * @param {number} index - The index in the AnimationFrame array + * + * @return {this} This Animation object. + */ + removeFrameAt: function (index) + { + this.frames.splice(index, 1); + + this.updateFrameSequence(); + + return this; + }, + + /** + * Called internally during playback. Forces the animation to repeat, provided there are enough counts left + * in the repeat counter. + * + * @method Phaser.Animations.Animation#repeatAnimation + * @fires Phaser.Animations.Events#ANIMATION_REPEAT + * @fires Phaser.Animations.Events#SPRITE_ANIMATION_REPEAT + * @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_REPEAT + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. + */ + repeatAnimation: function (state) + { + if (state._pendingStop === 2) + { + if (state._pendingStopValue === 0) + { + return state.stop(); + } + else + { + state._pendingStopValue--; + } + } + + if (state.repeatDelay > 0 && !state.pendingRepeat) + { + state.pendingRepeat = true; + state.accumulator -= state.nextTick; + state.nextTick += state.repeatDelay; + } + else + { + state.repeatCounter--; + + if (state.forward) + { + state.setCurrentFrame(state.currentFrame.nextFrame); + } + else + { + state.setCurrentFrame(state.currentFrame.prevFrame); + } + + if (state.isPlaying) + { + this.getNextTick(state); + + state.handleRepeat(); + } + } + }, + + /** + * Converts the animation data to JSON. + * + * @method Phaser.Animations.Animation#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Animations.JSONAnimation} The resulting JSONAnimation formatted object. + */ + toJSON: function () + { + var output = { + key: this.key, + type: this.type, + frames: [], + frameRate: this.frameRate, + duration: this.duration, + skipMissedFrames: this.skipMissedFrames, + delay: this.delay, + repeat: this.repeat, + repeatDelay: this.repeatDelay, + yoyo: this.yoyo, + showBeforeDelay: this.showBeforeDelay, + showOnStart: this.showOnStart, + randomFrame: this.randomFrame, + hideOnComplete: this.hideOnComplete + }; + + this.frames.forEach(function (frame) + { + output.frames.push(frame.toJSON()); + }); + + return output; + }, + + /** + * Called internally whenever frames are added to, or removed from, this Animation. + * + * @method Phaser.Animations.Animation#updateFrameSequence + * @since 3.0.0 + * + * @return {this} This Animation object. + */ + updateFrameSequence: function () + { + var len = this.frames.length; + var slice = 1 / (len - 1); + + var frame; + + for (var i = 0; i < len; i++) + { + frame = this.frames[i]; + + frame.index = i + 1; + frame.isFirst = false; + frame.isLast = false; + frame.progress = i * slice; + + if (i === 0) + { + frame.isFirst = true; + + if (len === 1) + { + frame.isLast = true; + frame.nextFrame = frame; + frame.prevFrame = frame; + } + else + { + frame.isLast = false; + frame.prevFrame = this.frames[len - 1]; + frame.nextFrame = this.frames[i + 1]; + } + } + else if (i === len - 1 && len > 1) + { + frame.isLast = true; + frame.prevFrame = this.frames[len - 2]; + frame.nextFrame = this.frames[0]; + } + else if (len > 1) + { + frame.prevFrame = this.frames[i - 1]; + frame.nextFrame = this.frames[i + 1]; + } + } + + return this; + }, + + /** + * Pauses playback of this Animation. The paused state is set immediately. + * + * @method Phaser.Animations.Animation#pause + * @since 3.0.0 + * + * @return {this} This Animation object. + */ + pause: function () + { + this.paused = true; + + return this; + }, + + /** + * Resumes playback of this Animation. The paused state is reset immediately. + * + * @method Phaser.Animations.Animation#resume + * @since 3.0.0 + * + * @return {this} This Animation object. + */ + resume: function () + { + this.paused = false; + + return this; + }, + + /** + * Destroys this Animation instance. It will remove all event listeners, + * remove this animation and its key from the global Animation Manager, + * and then destroy all Animation Frames in turn. + * + * @method Phaser.Animations.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.manager.off) + { + this.manager.off(Events.PAUSE_ALL, this.pause, this); + this.manager.off(Events.RESUME_ALL, this.resume, this); + } + + this.manager.remove(this.key); + + for (var i = 0; i < this.frames.length; i++) + { + this.frames[i].destroy(); + } + + this.frames = []; + + this.manager = null; + } + +}); + +module.exports = Animation; + + +/***/ }, + +/***/ 41138 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * A single frame within an Animation sequence. + * + * An AnimationFrame holds a reference to the Texture Frame it uses for rendering, links to the + * previous and next frames in the sequence, its position index, and playback progress data. + * It can also carry an optional per-frame duration that overrides the parent Animation's default + * frame rate, and can be flagged as a keyframe to mark significant moments in the sequence. + * + * AnimationFrames are created and managed automatically by the Animation class when an animation + * is built via the Animation Manager. You would not typically instantiate AnimationFrame directly. + * + * @class AnimationFrame + * @memberof Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {string} textureKey - The key of the Texture this AnimationFrame uses. + * @param {(string|number)} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. + * @param {number} index - The index of this AnimationFrame within the Animation sequence. + * @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering. + * @param {boolean} [isKeyFrame=false] - Is this Frame a Keyframe within the Animation? + */ +var AnimationFrame = new Class({ + + initialize: + + function AnimationFrame (textureKey, textureFrame, index, frame, isKeyFrame) + { + if (isKeyFrame === undefined) { isKeyFrame = false; } + + /** + * The key of the Texture this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureKey + * @type {string} + * @since 3.0.0 + */ + this.textureKey = textureKey; + + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureFrame + * @type {(string|number)} + * @since 3.0.0 + */ + this.textureFrame = textureFrame; + + /** + * The index of this AnimationFrame within the Animation sequence. + * + * @name Phaser.Animations.AnimationFrame#index + * @type {number} + * @since 3.0.0 + */ + this.index = index; + + /** + * A reference to the Texture Frame this AnimationFrame uses for rendering. + * + * @name Phaser.Animations.AnimationFrame#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = frame; + + /** + * Is this the first frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isFirst + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isFirst = false; + + /** + * Is this the last frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isLast + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isLast = false; + + /** + * A reference to the AnimationFrame that comes before this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#prevFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readonly + * @since 3.0.0 + */ + this.prevFrame = null; + + /** + * A reference to the AnimationFrame that comes after this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#nextFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readonly + * @since 3.0.0 + */ + this.nextFrame = null; + + /** + * The duration, in ms, of this frame of the animation. + * + * @name Phaser.Animations.AnimationFrame#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * The normalized progress of this frame within the animation, in the range 0 to 1. + * A value of 0 means the very start of the animation and 1 means the very end. + * This value is calculated when the animation is created and cached here. + * + * @name Phaser.Animations.AnimationFrame#progress + * @type {number} + * @default 0 + * @readonly + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Is this Frame a KeyFrame within the Animation? + * + * @name Phaser.Animations.AnimationFrame#isKeyFrame + * @type {boolean} + * @since 3.50.0 + */ + this.isKeyFrame = isKeyFrame; + }, + + /** + * Generates a JavaScript object suitable for converting to JSON. + * + * @method Phaser.Animations.AnimationFrame#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Animations.JSONAnimationFrame} The AnimationFrame data. + */ + toJSON: function () + { + return { + key: this.textureKey, + frame: this.textureFrame, + duration: this.duration, + keyframe: this.isKeyFrame + }; + }, + + /** + * Destroys this object by removing references to external resources. + * + * @method Phaser.Animations.AnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.frame = undefined; + } + +}); + +module.exports = AnimationFrame; + + +/***/ }, + +/***/ 60848 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Animation = __webpack_require__(42099); +var Class = __webpack_require__(83419); +var CustomMap = __webpack_require__(90330); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(74943); +var GameEvents = __webpack_require__(8443); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var MATH_CONST = __webpack_require__(36383); +var NumberArray = __webpack_require__(20283); +var Pad = __webpack_require__(41836); + +/** + * @classdesc + * The Animation Manager is a global system responsible for defining, storing, and managing all + * animations in your Phaser game. It is a singleton owned by the Game instance, meaning it persists + * across all Scenes and is not tied to any single Scene's lifecycle. + * + * You create animations once via `this.anims.create()` (or `this.anims.createFromAseprite()` for + * Aseprite exports), and those animations are then available to every Sprite or Game Object that has + * an Animation Component, across every Scene. + * + * The Animation Manager handles frame sequencing, timing, and playback configuration. Individual + * Game Objects each maintain their own playback state (current frame, repeat count, etc.) via their + * AnimationState component, but the frame data and timing definitions live here. + * + * You can access the Animation Manager from any Scene via `this.anims`. + * + * @class AnimationManager + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. + */ +var AnimationManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function AnimationManager (game) + { + EventEmitter.call(this); + + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.Animations.AnimationManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * A reference to the Texture Manager. + * + * @name Phaser.Animations.AnimationManager#textureManager + * @type {Phaser.Textures.TextureManager} + * @protected + * @since 3.0.0 + */ + this.textureManager = null; + + /** + * The global time scale of the Animation Manager. + * + * This scales the time delta between two frames, thus influencing the speed of time for the Animation Manager. + * + * @name Phaser.Animations.AnimationManager#globalTimeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.globalTimeScale = 1; + + /** + * The Animations registered in the Animation Manager. + * + * This map should be modified with the {@link #add} and {@link #create} methods of the Animation Manager. + * + * @name Phaser.Animations.AnimationManager#anims + * @type {Phaser.Structs.Map.} + * @protected + * @since 3.0.0 + */ + this.anims = new CustomMap(); + + /** + * A list of animation mix times. + * + * See the {@link #setMix} method for more details. + * + * @name Phaser.Animations.AnimationManager#mixes + * @type {Phaser.Structs.Map.} + * @since 3.50.0 + */ + this.mixes = new CustomMap(); + + /** + * Whether the Animation Manager is paused along with all of its Animations. + * + * @name Phaser.Animations.AnimationManager#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * The name of this Animation Manager. + * + * @name Phaser.Animations.AnimationManager#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'AnimationManager'; + + game.events.once(GameEvents.BOOT, this.boot, this); + }, + + /** + * Registers event listeners after the Game boots. + * + * @method Phaser.Animations.AnimationManager#boot + * @listens Phaser.Core.Events#DESTROY + * @since 3.0.0 + */ + boot: function () + { + this.textureManager = this.game.textures; + + this.game.events.once(GameEvents.DESTROY, this.destroy, this); + }, + + /** + * Adds a mix between two animations. + * + * Mixing allows you to specify a unique delay between a pairing of animations. + * + * When playing Animation A on a Game Object, if you then play Animation B, and a + * mix exists, it will wait for the specified delay to be over before playing Animation B. + * + * This allows you to customise smoothing between different types of animation, such + * as blending between an idle and a walk state, or a running and a firing state. + * + * Note that mixing is only applied if you use the `Sprite.play` method. If you opt to use + * `playAfterRepeat` or `playAfterDelay` instead, those will take priority and the mix + * delay will not be used. + * + * To update an existing mix, just call this method with the new delay. + * + * To remove a mix pairing, see the `removeMix` method. + * + * @method Phaser.Animations.AnimationManager#addMix + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation)} animA - The string-based key, or instance of, Animation A. + * @param {(string|Phaser.Animations.Animation)} animB - The string-based key, or instance of, Animation B. + * @param {number} delay - The delay, in milliseconds, to wait when transitioning from Animation A to B. + * + * @return {this} This Animation Manager. + */ + addMix: function (animA, animB, delay) + { + var anims = this.anims; + var mixes = this.mixes; + + var keyA = (typeof(animA) === 'string') ? animA : animA.key; + var keyB = (typeof(animB) === 'string') ? animB : animB.key; + + if (anims.has(keyA) && anims.has(keyB)) + { + var mixObj = mixes.get(keyA); + + if (!mixObj) + { + mixObj = {}; + } + + mixObj[keyB] = delay; + + mixes.set(keyA, mixObj); + } + + return this; + }, + + /** + * Removes a mix between two animations. + * + * Mixing allows you to specify a unique delay between a pairing of animations. + * + * Calling this method lets you remove those pairings. You can either remove + * it between `animA` and `animB`, or if you do not provide the `animB` parameter, + * it will remove all `animA` mixes. + * + * If you wish to update an existing mix instead, call the `addMix` method with the + * new delay. + * + * @method Phaser.Animations.AnimationManager#removeMix + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation)} animA - The string-based key, or instance of, Animation A. + * @param {(string|Phaser.Animations.Animation)} [animB] - The string-based key, or instance of, Animation B. If not given, all mixes for Animation A will be removed. + * + * @return {this} This Animation Manager. + */ + removeMix: function (animA, animB) + { + var mixes = this.mixes; + + var keyA = (typeof(animA) === 'string') ? animA : animA.key; + + var mixObj = mixes.get(keyA); + + if (mixObj) + { + if (animB) + { + var keyB = (typeof(animB) === 'string') ? animB : animB.key; + + if (mixObj.hasOwnProperty(keyB)) + { + // Remove just this pairing + delete mixObj[keyB]; + } + } + else if (!animB) + { + // Remove everything for animA + mixes.delete(keyA); + } + } + + return this; + }, + + /** + * Returns the mix delay between two animations. + * + * If no mix has been set up, this method will return zero. + * + * If you wish to create, or update, a new mix, call the `addMix` method. + * If you wish to remove a mix, call the `removeMix` method. + * + * @method Phaser.Animations.AnimationManager#getMix + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation)} animA - The string-based key, or instance of, Animation A. + * @param {(string|Phaser.Animations.Animation)} animB - The string-based key, or instance of, Animation B. + * + * @return {number} The mix duration, or zero if no mix exists. + */ + getMix: function (animA, animB) + { + var mixes = this.mixes; + + var keyA = (typeof(animA) === 'string') ? animA : animA.key; + var keyB = (typeof(animB) === 'string') ? animB : animB.key; + + var mixObj = mixes.get(keyA); + + if (mixObj && mixObj.hasOwnProperty(keyB)) + { + return mixObj[keyB]; + } + else + { + return 0; + } + }, + + /** + * Adds an existing Animation to the Animation Manager. + * + * @method Phaser.Animations.AnimationManager#add + * @fires Phaser.Animations.Events#ADD_ANIMATION + * @since 3.0.0 + * + * @param {string} key - The key under which the Animation should be added. The Animation will be updated with it. Must be unique. + * @param {Phaser.Animations.Animation} animation - The Animation which should be added to the Animation Manager. + * + * @return {this} This Animation Manager. + */ + add: function (key, animation) + { + if (this.anims.has(key)) + { + console.warn('Animation key exists: ' + key); + + return this; + } + + animation.key = key; + + this.anims.set(key, animation); + + this.emit(Events.ADD_ANIMATION, key, animation); + + return this; + }, + + /** + * Checks to see if the given key is already in use within the Animation Manager or not. + * + * Animations are global. Keys created in one scene can be used from any other Scene in your game. They are not Scene specific. + * + * @method Phaser.Animations.AnimationManager#exists + * @since 3.16.0 + * + * @param {string} key - The key of the Animation to check. + * + * @return {boolean} `true` if the Animation already exists in the Animation Manager, or `false` if the key is available. + */ + exists: function (key) + { + return this.anims.has(key); + }, + + /** + * Create one, or more animations from a loaded Aseprite JSON file. + * + * Aseprite is a powerful animated sprite editor and pixel art tool. + * + * You can find more details at https://www.aseprite.org/ + * + * To export a compatible JSON file in Aseprite, please do the following: + * + * 1. Go to "File - Export Sprite Sheet" + * + * 2. On the **Layout** tab: + * 2a. Set the "Sheet type" to "Packed" + * 2b. Set the "Constraints" to "None" + * 2c. Check the "Merge Duplicates" checkbox + * + * 3. On the **Sprite** tab: + * 3a. Set "Layers" to "Visible layers" + * 3b. Set "Frames" to "All frames", unless you only wish to export a sub-set of tags + * + * 4. On the **Borders** tab: + * 4a. Check the "Trim Sprite" and "Trim Cells" options + * 4b. Ensure "Border Padding", "Spacing" and "Inner Padding" are all > 0 (1 is usually enough) + * + * 5. On the **Output** tab: + * 5a. Check "Output File", give your image a name and make sure you choose "png files" as the file type + * 5b. Check "JSON Data" and give your json file a name + * 5c. The JSON Data type can be either a Hash or Array, Phaser doesn't mind. + * 5d. Make sure "Tags" is checked in the Meta options + * 5e. In the "Item Filename" input box, make sure it says just "{frame}" and nothing more. + * + * 6. Click export + * + * This was tested with Aseprite 1.2.25. + * + * This will export a png and json file which you can load using the Aseprite Loader, i.e.: + * + * ```javascript + * function preload () + * { + * this.load.path = 'assets/animations/aseprite/'; + * this.load.aseprite('paladin', 'paladin.png', 'paladin.json'); + * } + * ``` + * + * Once loaded, you can call this method from within a Scene with the 'atlas' key: + * + * ```javascript + * this.anims.createFromAseprite('paladin'); + * ``` + * + * Any animations defined in the JSON will now be available to use in Phaser and you play them + * via their Tag name. For example, if you have an animation called 'War Cry' on your Aseprite timeline, + * you can play it in Phaser using that Tag name: + * + * ```javascript + * this.add.sprite(400, 300).play('War Cry'); + * ``` + * + * When calling this method you can optionally provide an array of tag names, and only those animations + * will be created. For example: + * + * ```javascript + * this.anims.createFromAseprite('paladin', [ 'step', 'War Cry', 'Magnum Break' ]); + * ``` + * + * This will only create the 3 animations defined. Note that the tag names are case-sensitive. + * + * @method Phaser.Animations.AnimationManager#createFromAseprite + * @since 3.50.0 + * + * @param {string} key - The key of the loaded Aseprite atlas. It must have been loaded prior to calling this method. + * @param {string[]} [tags] - An array of Tag names. If provided, only animations found in this array will be created. + * @param {(Phaser.Animations.AnimationManager|Phaser.GameObjects.GameObject)} [target] - Create the animations on this target Sprite. If not given, they will be created globally in this Animation Manager. + * + * @return {Phaser.Animations.Animation[]} An array of Animation instances that were successfully created. + */ + createFromAseprite: function (key, tags, target) + { + var output = []; + + var data = this.game.cache.json.get(key); + + if (!data) + { + console.warn('No Aseprite data found for: ' + key); + + return output; + } + + var _this = this; + + var meta = GetValue(data, 'meta', null); + var frames = GetValue(data, 'frames', null); + + if (meta && frames) + { + var frameTags = GetValue(meta, 'frameTags', []); + + frameTags.forEach(function (tag) + { + var animFrames = []; + + var name = GetFastValue(tag, 'name', null); + var from = GetFastValue(tag, 'from', 0); + var to = GetFastValue(tag, 'to', 0); + var direction = GetFastValue(tag, 'direction', 'forward'); + + if (!name) + { + // Skip if no name + return; + } + + if (!tags || (tags && tags.indexOf(name) > -1)) + { + // Get all the frames for this tag and calculate the total duration in milliseconds. + var totalDuration = 0; + for (var i = from; i <= to; i++) + { + var frameKey = i.toString(); + var frame = frames[frameKey]; + + if (frame) + { + var frameDuration = GetFastValue(frame, 'duration', MATH_CONST.MAX_SAFE_INTEGER); + animFrames.push({ key: key, frame: frameKey, duration: frameDuration }); + totalDuration += frameDuration; + } + } + + if (direction === 'reverse') + { + animFrames = animFrames.reverse(); + } + + // Create the animation + var createConfig = { + key: name, + frames: animFrames, + duration: totalDuration, + yoyo: (direction === 'pingpong') + }; + + var result; + + if (target) + { + if (target.anims) + { + result = target.anims.create(createConfig); + } + } + else + { + result = _this.create(createConfig); + } + + if (result) + { + output.push(result); + } + } + }); + } + + return output; + }, + + /** + * Creates a new Animation and adds it to the Animation Manager. + * + * Animations are global. Once created, you can use them in any Scene in your game. They are not Scene specific. + * + * If an invalid key is given this method will return `false`. + * + * If you pass the key of an animation that already exists in the Animation Manager, that animation will be returned. + * + * A brand new animation is only created if the key is valid and not already in use. + * + * If you wish to re-use an existing key, call `AnimationManager.remove` first, then this method. + * + * @method Phaser.Animations.AnimationManager#create + * @fires Phaser.Animations.Events#ADD_ANIMATION + * @since 3.0.0 + * + * @param {Phaser.Types.Animations.Animation} config - The configuration settings for the Animation. + * + * @return {(Phaser.Animations.Animation|false)} The Animation that was created, or `false` if the key is already in use. + */ + create: function (config) + { + var key = config.key; + + var anim = false; + + if (key) + { + anim = this.get(key); + + if (!anim) + { + anim = new Animation(this, key, config); + + this.anims.set(key, anim); + + this.emit(Events.ADD_ANIMATION, key, anim); + } + else + { + console.warn('AnimationManager key already exists: ' + key); + } + } + + return anim; + }, + + /** + * Loads this Animation Manager's Animations and settings from a JSON object. + * + * @method Phaser.Animations.AnimationManager#fromJSON + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Animations.JSONAnimations|Phaser.Types.Animations.JSONAnimation)} data - The JSON object to parse. + * @param {boolean} [clearCurrentAnimations=false] - If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. + * + * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. + */ + fromJSON: function (data, clearCurrentAnimations) + { + if (clearCurrentAnimations === undefined) { clearCurrentAnimations = false; } + + if (clearCurrentAnimations) + { + this.anims.clear(); + } + + // Do we have a String (i.e. from JSON, or an Object?) + if (typeof data === 'string') + { + data = JSON.parse(data); + } + + var output = []; + + // Array of animations, or a single animation? + if (data.hasOwnProperty('anims') && Array.isArray(data.anims)) + { + for (var i = 0; i < data.anims.length; i++) + { + output.push(this.create(data.anims[i])); + } + + if (data.hasOwnProperty('globalTimeScale')) + { + this.globalTimeScale = data.globalTimeScale; + } + } + else if (data.hasOwnProperty('key') && data.type === 'frame') + { + output.push(this.create(data)); + } + + return output; + }, + + /** + * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. + * + * Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}. + * + * It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases. + * + * If you're working with a sprite sheet, see the `generateFrameNumbers` method instead. + * + * Example: + * + * If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on, + * then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', start: 1, end: 6, zeroPad: 4 })`. + * + * The `end` value tells it to select frames 1 through 6, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad` + * value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do: + * + * ```javascript + * this.anims.create({ + * key: 'ruby', + * repeat: -1, + * frames: this.anims.generateFrameNames('gems', { + * prefix: 'ruby_', + * end: 6, + * zeroPad: 4 + * }) + * }); + * ``` + * + * Please see the animation examples for further details. + * + * @method Phaser.Animations.AnimationManager#generateFrameNames + * @since 3.0.0 + * + * @param {string} key - The key for the texture containing the animation frames. + * @param {Phaser.Types.Animations.GenerateFrameNames} [config] - The configuration object for the animation frame names. + * + * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. + */ + generateFrameNames: function (key, config) + { + var prefix = GetValue(config, 'prefix', ''); + var start = GetValue(config, 'start', 0); + var end = GetValue(config, 'end', 0); + var suffix = GetValue(config, 'suffix', ''); + var zeroPad = GetValue(config, 'zeroPad', 0); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + if (!this.textureManager.exists(key)) + { + console.warn('Texture "%s" not found', key); + + return out; + } + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + var i; + + if (!config) + { + // Use every frame in the atlas + frames = texture.getFrameNames(); + + for (i = 0; i < frames.length; i++) + { + out.push({ key: key, frame: frames[i] }); + } + } + else + { + if (!frames) + { + frames = NumberArray(start, end); + } + + for (i = 0; i < frames.length; i++) + { + var frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + else + { + console.warn('Frame "%s" not found in texture "%s"', frame, key); + } + } + } + + return out; + }, + + /** + * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}. + * + * If you're working with a texture atlas, see the `generateFrameNames` method instead. + * + * It's a helper method, designed to make it easier for you to extract frames from sprite sheets. + * + * Example: + * + * If you have a sprite sheet loaded called `explosion` and it contains 12 frames, then you can call this method using: + * + * `this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 })`. + * + * The `end` value of 11 tells it to stop after the 12th frame has been added, because it started at zero. + * + * To create an animation using this method, you can do: + * + * ```javascript + * this.anims.create({ + * key: 'boom', + * frames: this.anims.generateFrameNumbers('explosion', { + * start: 0, + * end: 11 + * }) + * }); + * ``` + * + * Note that `start` is optional and you don't need to include it if the animation starts from frame 0. + * + * To specify an animation in reverse, swap the `start` and `end` values. + * + * If the frames are not sequential, you may pass an array of frame numbers instead, for example: + * + * `this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })` + * + * Please see the animation examples and `GenerateFrameNumbers` config docs for further details. + * + * @method Phaser.Animations.AnimationManager#generateFrameNumbers + * @since 3.0.0 + * + * @param {string} key - The key for the texture containing the animation frames. + * @param {Phaser.Types.Animations.GenerateFrameNumbers} [config] - The configuration object for the animation frames. + * + * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. + */ + generateFrameNumbers: function (key, config) + { + var start = GetValue(config, 'start', 0); + var end = GetValue(config, 'end', -1); + var first = GetValue(config, 'first', false); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + if (!this.textureManager.exists(key)) + { + console.warn('Texture "%s" not found', key); + + return out; + } + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + if (first && texture.has(first)) + { + out.push({ key: key, frame: first }); + } + + // No 'frames' array? Then generate one automatically + if (!frames) + { + if (end === -1) + { + // -1 because of __BASE, which we don't want in our results + // and -1 because frames are zero based + end = texture.frameTotal - 2; + } + + frames = NumberArray(start, end); + } + + for (var i = 0; i < frames.length; i++) + { + var frameName = frames[i]; + + if (texture.has(frameName)) + { + out.push({ key: key, frame: frameName }); + } + else + { + console.warn('Frame "%s" not found in texture "%s"', frameName, key); + } + } + + return out; + }, + + /** + * Retrieves an Animation from the Animation Manager by its key. + * + * Returns `undefined` if no Animation with the given key exists. + * + * @method Phaser.Animations.AnimationManager#get + * @since 3.0.0 + * + * @param {string} key - The key of the Animation to retrieve. + * + * @return {(Phaser.Animations.Animation|undefined)} The Animation or `undefined`. + */ + get: function (key) + { + return this.anims.get(key); + }, + + /** + * Returns an array of all Animation keys that are using the given + * Texture. Only Animations that have at least one AnimationFrame + * entry using this texture will be included in the result. + * + * @method Phaser.Animations.AnimationManager#getAnimsFromTexture + * @since 3.60.0 + * + * @param {(string|Phaser.Textures.Texture|Phaser.Textures.Frame)} key - The unique string-based key of the Texture, or a Texture, or Frame instance. + * + * @return {string[]} An array of Animation keys that feature the given Texture. + */ + getAnimsFromTexture: function (key) + { + var texture = this.textureManager.get(key); + + var match = texture.key; + var anims = this.anims.getArray(); + + var out = []; + + for (var i = 0; i < anims.length; i++) + { + var anim = anims[i]; + var frames = anim.frames; + + for (var c = 0; c < frames.length; c++) + { + if (frames[c].textureKey === match) + { + out.push(anim.key); + + break; + } + } + } + + return out; + }, + + /** + * Pauses all animations in the Animation Manager by setting the `paused` flag to `true`. + * This affects all Game Objects that are playing animations globally. Has no effect if + * the Animation Manager is already paused. + * + * @method Phaser.Animations.AnimationManager#pauseAll + * @fires Phaser.Animations.Events#PAUSE_ALL + * @since 3.0.0 + * + * @return {this} This Animation Manager. + */ + pauseAll: function () + { + if (!this.paused) + { + this.paused = true; + + this.emit(Events.PAUSE_ALL); + } + + return this; + }, + + /** + * Play an animation on the given Game Objects that have an Animation Component. + * + * @method Phaser.Animations.AnimationManager#play + * @since 3.0.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. + * + * @return {this} This Animation Manager. + */ + play: function (key, children) + { + if (!Array.isArray(children)) + { + children = [ children ]; + } + + for (var i = 0; i < children.length; i++) + { + children[i].anims.play(key); + } + + return this; + }, + + /** + * Takes an array of Game Objects that have an Animation Component and then + * starts the given animation playing on them. The start time of each Game Object + * is offset, incrementally, by the `stagger` amount. + * + * For example, if you pass an array with 4 children and a stagger time of 1000, + * the delays will be: + * + * child 1: 1000ms delay + * child 2: 2000ms delay + * child 3: 3000ms delay + * child 4: 4000ms delay + * + * If you set the `staggerFirst` parameter to `false` they would be: + * + * child 1: 0ms delay + * child 2: 1000ms delay + * child 3: 2000ms delay + * child 4: 3000ms delay + * + * You can also set `stagger` to be a negative value. If it was -1000, the above would be: + * + * child 1: 3000ms delay + * child 2: 2000ms delay + * child 3: 1000ms delay + * child 4: 0ms delay + * + * @method Phaser.Animations.AnimationManager#staggerPlay + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. + * @param {number} stagger - The amount of time, in milliseconds, to offset each play time by. If a negative value is given, it's applied to the children in reverse order. + * @param {boolean} [staggerFirst=true] - Should the first child be staggered as well? + * + * @return {this} This Animation Manager. + */ + staggerPlay: function (key, children, stagger, staggerFirst) + { + if (stagger === undefined) { stagger = 0; } + if (staggerFirst === undefined) { staggerFirst = true; } + + if (!Array.isArray(children)) + { + children = [ children ]; + } + + var len = children.length; + + if (!staggerFirst) + { + len--; + } + + for (var i = 0; i < children.length; i++) + { + var time = (stagger < 0) ? Math.abs(stagger) * (len - i) : stagger * i; + + children[i].anims.playAfterDelay(key, time); + } + + return this; + }, + + /** + * Removes an Animation from this Animation Manager, based on the given key. + * + * This is a global action. Once an Animation has been removed, no Game Objects + * can carry on using it. + * + * @method Phaser.Animations.AnimationManager#remove + * @fires Phaser.Animations.Events#REMOVE_ANIMATION + * @since 3.0.0 + * + * @param {string} key - The key of the animation to remove. + * + * @return {Phaser.Animations.Animation} The Animation instance that was removed from the Animation Manager. + */ + remove: function (key) + { + var anim = this.get(key); + + if (anim) + { + this.emit(Events.REMOVE_ANIMATION, key, anim); + + this.anims.delete(key); + + this.removeMix(key); + } + + return anim; + }, + + /** + * Resumes all paused animations in the Animation Manager by setting the `paused` flag to `false`. + * Has no effect if the Animation Manager is not currently paused. + * + * @method Phaser.Animations.AnimationManager#resumeAll + * @fires Phaser.Animations.Events#RESUME_ALL + * @since 3.0.0 + * + * @return {this} This Animation Manager. + */ + resumeAll: function () + { + if (this.paused) + { + this.paused = false; + + this.emit(Events.RESUME_ALL); + } + + return this; + }, + + /** + * Returns the Animation data as JavaScript object based on the given key. + * Or, if no key is defined, it will return the data of all animations as array of objects. + * + * @method Phaser.Animations.AnimationManager#toJSON + * @since 3.0.0 + * + * @param {string} [key] - The animation to get the JSONAnimation data from. If not provided, all animations are returned as an array. + * + * @return {Phaser.Types.Animations.JSONAnimations} The resulting JSONAnimations formatted object. + */ + toJSON: function (key) + { + var output = { + anims: [], + globalTimeScale: this.globalTimeScale + }; + + if (key !== undefined && key !== '') + { + output.anims.push(this.anims.get(key).toJSON()); + } + else + { + this.anims.each(function (animationKey, animation) + { + output.anims.push(animation.toJSON()); + }); + } + + return output; + }, + + /** + * Destroy this Animation Manager and clean up animation definitions and references to other objects. + * This method should not be called directly. It will be called automatically as a response to a `destroy` event from the Phaser.Game instance. + * + * @method Phaser.Animations.AnimationManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.anims.clear(); + this.mixes.clear(); + + this.textureManager = null; + + this.game = null; + } + +}); + +module.exports = AnimationManager; + + +/***/ }, + +/***/ 9674 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Animation = __webpack_require__(42099); +var Between = __webpack_require__(30976); +var Class = __webpack_require__(83419); +var CustomMap = __webpack_require__(90330); +var Events = __webpack_require__(74943); +var GetFastValue = __webpack_require__(95540); + +/** + * @classdesc + * The Animation State Component. + * + * This component provides features to apply animations to Game Objects. It is responsible for + * loading, queuing animations for later playback, mixing between animations and setting + * the current animation frame to the Game Object that owns this component. + * + * This component lives as an instance within any Game Object that has it defined, such as Sprites. + * + * You can access its properties and methods via the `anims` property, i.e. `Sprite.anims`. + * + * As well as playing animations stored in the global Animation Manager, this component + * can also create animations that are stored locally within it. See the `create` method + * for more details. + * + * Prior to Phaser 3.50 this component was called just `Animation` and lived in the + * `Phaser.GameObjects.Components` namespace. It was renamed to `AnimationState` + * in 3.50 to help better identify its true purpose when browsing the documentation. + * + * @class AnimationState + * @memberof Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation component belongs. + */ +var AnimationState = new Class({ + + initialize: + + function AnimationState (parent) + { + /** + * The Game Object to which this animation component belongs. + * + * You can typically access this component from the Game Object + * via the `this.anims` property. + * + * @name Phaser.Animations.AnimationState#parent + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * A reference to the global Animation Manager. + * + * @name Phaser.Animations.AnimationState#animationManager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.animationManager = parent.scene.sys.anims; + + this.animationManager.on(Events.REMOVE_ANIMATION, this.globalRemove, this); + + /** + * A reference to the Texture Manager. + * + * @name Phaser.Animations.AnimationState#textureManager + * @type {Phaser.Textures.TextureManager} + * @protected + * @since 3.50.0 + */ + this.textureManager = this.animationManager.textureManager; + + /** + * The Animations stored locally in this Animation component. + * + * Do not modify the contents of this Map directly, instead use the + * `add`, `create` and `remove` methods of this class instead. + * + * @name Phaser.Animations.AnimationState#anims + * @type {Phaser.Structs.Map.} + * @protected + * @since 3.50.0 + */ + this.anims = null; + + /** + * Is an animation currently playing or not? + * + * @name Phaser.Animations.AnimationState#isPlaying + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * Has the current animation started playing, or is it waiting for a delay to expire? + * + * @name Phaser.Animations.AnimationState#hasStarted + * @type {boolean} + * @default false + * @since 3.50.0 + */ + this.hasStarted = false; + + /** + * The current Animation loaded into this Animation component. + * + * Will be `null` if no animation is yet loaded. + * + * @name Phaser.Animations.AnimationState#currentAnim + * @type {?Phaser.Animations.Animation} + * @default null + * @since 3.0.0 + */ + this.currentAnim = null; + + /** + * The current AnimationFrame being displayed by this Animation component. + * + * Will be `null` if no animation is yet loaded. + * + * @name Phaser.Animations.AnimationState#currentFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @since 3.0.0 + */ + this.currentFrame = null; + + /** + * The key, instance, or config of the next Animation to be loaded into this Animation component + * when the current animation completes. + * + * Will be `null` if no animation has been queued. + * + * @name Phaser.Animations.AnimationState#nextAnim + * @type {?(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} + * @default null + * @since 3.16.0 + */ + this.nextAnim = null; + + /** + * A queue of Animations to be loaded into this Animation component when the current animation completes. + * + * Populate this queue via the `chain` method. + * + * @name Phaser.Animations.AnimationState#nextAnimsQueue + * @type {array} + * @since 3.24.0 + */ + this.nextAnimsQueue = []; + + /** + * The Time Scale factor. + * + * You can adjust this value to modify the passage of time for the animation that is currently + * playing. For example, setting it to 2 will make the animation play twice as fast. Or setting + * it to 0.5 will slow the animation down. + * + * You can change this value at run-time, or set it via the `PlayAnimationConfig`. + * + * Prior to Phaser 3.50 this property was private and called `_timeScale`. + * + * @name Phaser.Animations.AnimationState#timeScale + * @type {number} + * @default 1 + * @since 3.50.0 + */ + this.timeScale = 1; + + /** + * The frame rate of playback, of the current animation, in frames per second. + * + * This value is set when a new animation is loaded into this component and should + * be treated as read-only, as changing it once playback has started will not alter + * the animation. To change the frame rate, provide a new value in the `PlayAnimationConfig` object. + * + * @name Phaser.Animations.AnimationState#frameRate + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.frameRate = 0; + + /** + * The duration of the current animation, in milliseconds. + * + * This value is set when a new animation is loaded into this component and should + * be treated as read-only, as changing it once playback has started will not alter + * the animation. To change the duration, provide a new value in the `PlayAnimationConfig` object. + * + * @name Phaser.Animations.AnimationState#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * The number of milliseconds per frame, not including frame specific modifiers that may be present in the + * Animation data. + * + * This value is calculated when a new animation is loaded into this component and should + * be treated as read-only. Changing it will not alter playback speed. + * + * @name Phaser.Animations.AnimationState#msPerFrame + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.msPerFrame = 0; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.Animations.AnimationState#skipMissedFrames + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.skipMissedFrames = true; + + /** + * Start playback of this animation from a random frame? + * + * @name Phaser.Animations.AnimationState#randomFrame + * @type {boolean} + * @default false + * @since 3.60.0 + */ + this.randomFrame = false; + + /** + * The delay before starting playback of the current animation, in milliseconds. + * + * This value is set when a new animation is loaded into this component and should + * be treated as read-only, as changing it once playback has started will not alter + * the animation. To change the delay, provide a new value in the `PlayAnimationConfig` object. + * + * Prior to Phaser 3.50 this property was private and called `_delay`. + * + * @name Phaser.Animations.AnimationState#delay + * @type {number} + * @default 0 + * @since 3.50.0 + */ + this.delay = 0; + + /** + * The number of times to repeat playback of the current animation. + * + * If -1, it means the animation will repeat forever. + * + * This value is set when a new animation is loaded into this component and should + * be treated as read-only, as changing it once playback has started will not alter + * the animation. To change the number of repeats, provide a new value in the `PlayAnimationConfig` object. + * + * Prior to Phaser 3.50 this property was private and called `_repeat`. + * + * @name Phaser.Animations.AnimationState#repeat + * @type {number} + * @default 0 + * @since 3.50.0 + */ + this.repeat = 0; + + /** + * The number of milliseconds to wait before starting the repeat playback of the current animation. + * + * This value is set when a new animation is loaded into this component, but can also be modified + * at run-time. + * + * You can change the repeat delay by providing a new value in the `PlayAnimationConfig` object. + * + * Prior to Phaser 3.50 this property was private and called `_repeatDelay`. + * + * @name Phaser.Animations.AnimationState#repeatDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatDelay = 0; + + /** + * Should the current animation yoyo? An animation that yoyos will play in reverse, from the end + * to the start, before then repeating or completing. An animation that does not yoyo will just + * play from the start to the end. + * + * This value is set when a new animation is loaded into this component, but can also be modified + * at run-time. + * + * You can change the yoyo by providing a new value in the `PlayAnimationConfig` object. + * + * Prior to Phaser 3.50 this property was private and called `_yoyo`. + * + * @name Phaser.Animations.AnimationState#yoyo + * @type {boolean} + * @default false + * @since 3.50.0 + */ + this.yoyo = false; + + /** + * If the animation has a delay set, before playback will begin, this + * controls when the first frame is set on the Sprite. If this property + * is 'false' then the frame is set only after the delay has expired. + * This is the default behavior. + * + * If this property is 'true' then the first frame of this animation + * is set immediately, and then when the delay expires, playback starts. + * + * @name Phaser.Animations.AnimationState#showBeforeDelay + * @type {boolean} + * @since 3.60.0 + */ + this.showBeforeDelay = false; + + /** + * Should the GameObject's `visible` property be set to `true` when the animation starts to play? + * + * This will happen _after_ any delay that may have been set. + * + * This value is set when a new animation is loaded into this component, but can also be modified + * at run-time, assuming the animation is currently delayed. + * + * @name Phaser.Animations.AnimationState#showOnStart + * @type {boolean} + * @since 3.50.0 + */ + this.showOnStart = false; + + /** + * Should the GameObject's `visible` property be set to `false` when the animation completes? + * + * This value is set when a new animation is loaded into this component, but can also be modified + * at run-time, assuming the animation is still actively playing. + * + * @name Phaser.Animations.AnimationState#hideOnComplete + * @type {boolean} + * @since 3.50.0 + */ + this.hideOnComplete = false; + + /** + * Is the playhead moving forwards (`true`) or in reverse (`false`) ? + * + * @name Phaser.Animations.AnimationState#forward + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.forward = true; + + /** + * An internal trigger that tells the component if it should plays the animation + * in reverse mode ('true') or not ('false'). This is used because `forward` can + * be changed by the `yoyo` feature. + * + * Prior to Phaser 3.50 this property was private and called `_reverse`. + * + * @name Phaser.Animations.AnimationState#inReverse + * @type {boolean} + * @default false + * @since 3.50.0 + */ + this.inReverse = false; + + /** + * Internal time overflow accumulator. + * + * This has the `delta` time added to it as part of the `update` step. + * + * @name Phaser.Animations.AnimationState#accumulator + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accumulator = 0; + + /** + * The time point at which the next animation frame will change. + * + * This value is compared against the `accumulator` as part of the `update` step. + * + * @name Phaser.Animations.AnimationState#nextTick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.nextTick = 0; + + /** + * A counter keeping track of how much delay time, in milliseconds, is left before playback begins. + * + * This is set via the `playAfterDelay` method, although it can be modified at run-time + * if required, as long as the animation has not already started playing. + * + * @name Phaser.Animations.AnimationState#delayCounter + * @type {number} + * @default 0 + * @since 3.50.0 + */ + this.delayCounter = 0; + + /** + * A counter that keeps track of how many repeats are left to run. + * + * This value is set when a new animation is loaded into this component, but can also be modified + * at run-time. + * + * @name Phaser.Animations.AnimationState#repeatCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCounter = 0; + + /** + * An internal flag keeping track of pending repeats. + * + * @name Phaser.Animations.AnimationState#pendingRepeat + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pendingRepeat = false; + + /** + * Is the Animation paused? + * + * @name Phaser.Animations.AnimationState#_paused + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._paused = false; + + /** + * Was the animation previously playing before being paused? + * + * @name Phaser.Animations.AnimationState#_wasPlaying + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._wasPlaying = false; + + /** + * Internal property tracking if this Animation is waiting to stop. + * + * 0 = No + * 1 = Waiting for ms to pass + * 2 = Waiting for repeat + * 3 = Waiting for specific frame + * + * @name Phaser.Animations.AnimationState#_pendingStop + * @type {number} + * @private + * @since 3.4.0 + */ + this._pendingStop = 0; + + /** + * Internal property used by _pendingStop. + * + * @name Phaser.Animations.AnimationState#_pendingStopValue + * @type {any} + * @private + * @since 3.4.0 + */ + this._pendingStopValue; + }, + + /** + * Sets an animation, or an array of animations, to be played in the future, after the current one completes or stops. + * + * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, + * or have one of the `stop` methods called. + * + * An animation set to repeat forever will never enter a completed state unless stopped. + * + * You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` event). + * + * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing. + * + * Call this method with no arguments to reset all currently chained animations. + * + * @method Phaser.Animations.AnimationState#chain + * @since 3.16.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig|string[]|Phaser.Animations.Animation[]|Phaser.Types.Animations.PlayAnimationConfig[])} [key] - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object, or an array of them. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + chain: function (key) + { + var parent = this.parent; + + if (key === undefined) + { + this.nextAnimsQueue.length = 0; + this.nextAnim = null; + + return parent; + } + + if (!Array.isArray(key)) + { + key = [ key ]; + } + + for (var i = 0; i < key.length; i++) + { + var anim = key[i]; + + if (!this.nextAnim) + { + this.nextAnim = anim; + } + else + { + this.nextAnimsQueue.push(anim); + } + } + + return this.parent; + }, + + /** + * Returns the key of the animation currently loaded into this component. + * + * Prior to Phaser 3.50 this method was called `getCurrentKey`. + * + * @method Phaser.Animations.AnimationState#getName + * @since 3.50.0 + * + * @return {string} The key of the Animation currently loaded into this component, or an empty string if none loaded. + */ + getName: function () + { + return (this.currentAnim) ? this.currentAnim.key : ''; + }, + + /** + * Returns the key of the animation frame currently displayed by this component. + * + * @method Phaser.Animations.AnimationState#getFrameName + * @since 3.50.0 + * + * @return {string} The key of the Animation Frame currently displayed by this component, or an empty string if no animation has been loaded. + */ + getFrameName: function () + { + return (this.currentFrame) ? this.currentFrame.textureFrame : ''; + }, + + /** + * Internal method used to load an animation into this component. + * + * @method Phaser.Animations.AnimationState#load + * @protected + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or a `PlayAnimationConfig` object. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + load: function (key) + { + if (this.isPlaying) + { + this.stop(); + } + + var manager = this.animationManager; + var animKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', null); + + // Get the animation, first from the local map and, if not found, from the Animation Manager + var anim = (this.exists(animKey)) ? this.get(animKey) : manager.get(animKey); + + if (!anim) + { + console.warn('Missing animation: ' + animKey); + } + else + { + this.currentAnim = anim; + + // And now override the animation values, if set in the config. + + var totalFrames = anim.getTotalFrames(); + var frameRate = GetFastValue(key, 'frameRate', anim.frameRate); + var duration = GetFastValue(key, 'duration', anim.duration); + + anim.calculateDuration(this, totalFrames, duration, frameRate); + + this.delay = GetFastValue(key, 'delay', anim.delay); + this.repeat = GetFastValue(key, 'repeat', anim.repeat); + this.repeatDelay = GetFastValue(key, 'repeatDelay', anim.repeatDelay); + this.yoyo = GetFastValue(key, 'yoyo', anim.yoyo); + this.showBeforeDelay = GetFastValue(key, 'showBeforeDelay', anim.showBeforeDelay); + this.showOnStart = GetFastValue(key, 'showOnStart', anim.showOnStart); + this.hideOnComplete = GetFastValue(key, 'hideOnComplete', anim.hideOnComplete); + this.skipMissedFrames = GetFastValue(key, 'skipMissedFrames', anim.skipMissedFrames); + this.randomFrame = GetFastValue(key, 'randomFrame', anim.randomFrame); + + this.timeScale = GetFastValue(key, 'timeScale', this.timeScale); + + var startFrame = GetFastValue(key, 'startFrame', 0); + + if (startFrame > totalFrames) + { + startFrame = 0; + } + + if (this.randomFrame) + { + startFrame = Between(0, totalFrames - 1); + } + + var frame = anim.frames[startFrame]; + + if (startFrame === 0 && !this.forward) + { + frame = anim.getLastFrame(); + } + + this.currentFrame = frame; + } + + return this.parent; + }, + + /** + * Pause the current animation and set the `isPlaying` property to `false`. + * You can optionally pause it at a specific frame. + * + * @method Phaser.Animations.AnimationState#pause + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} [atFrame] - An optional frame to set after pausing the animation. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + pause: function (atFrame) + { + if (!this._paused) + { + this._paused = true; + this._wasPlaying = this.isPlaying; + this.isPlaying = false; + } + + if (atFrame !== undefined) + { + this.setCurrentFrame(atFrame); + } + + return this.parent; + }, + + /** + * Resumes playback of a paused animation and sets the `isPlaying` property to `true`. + * You can optionally tell it to start playback from a specific frame. + * + * @method Phaser.Animations.AnimationState#resume + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} [fromFrame] - An optional frame to set before restarting playback. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + resume: function (fromFrame) + { + if (this._paused) + { + this._paused = false; + this.isPlaying = this._wasPlaying; + } + + if (fromFrame !== undefined) + { + this.setCurrentFrame(fromFrame); + } + + return this.parent; + }, + + /** + * Waits for the specified delay, in milliseconds, then starts playback of the given animation. + * + * If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here. + * + * If an animation is already running and a new animation is given to this method, it will wait for + * the given delay before starting the new animation. + * + * If no animation is currently running, the given one begins after the delay. + * + * Prior to Phaser 3.50 this method was called 'delayedPlay' and the parameters were in the reverse order. + * + * @method Phaser.Animations.AnimationState#playAfterDelay + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {number} delay - The delay, in milliseconds, to wait before starting the animation playing. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playAfterDelay: function (key, delay) + { + if (!this.isPlaying) + { + this.delayCounter = delay; + + this.play(key, true); + } + else + { + // If we've got a nextAnim, move it to the queue + var nextAnim = this.nextAnim; + var queue = this.nextAnimsQueue; + + if (nextAnim) + { + queue.unshift(nextAnim); + } + + this.nextAnim = key; + + this._pendingStop = 1; + this._pendingStopValue = delay; + } + + return this.parent; + }, + + /** + * Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback + * of the given animation. + * + * You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an + * idle animation to a walking animation, by making them blend smoothly into each other. + * + * If no animation is currently running, the given one will start immediately. + * + * @method Phaser.Animations.AnimationState#playAfterRepeat + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {number} [repeatCount=1] - How many times should the animation repeat before the next one starts? + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playAfterRepeat: function (key, repeatCount) + { + if (repeatCount === undefined) { repeatCount = 1; } + + if (!this.isPlaying) + { + this.play(key); + } + else + { + // If we've got a nextAnim, move it to the queue + var nextAnim = this.nextAnim; + var queue = this.nextAnimsQueue; + + if (nextAnim) + { + queue.unshift(nextAnim); + } + + if (this.repeatCounter !== -1 && repeatCount > this.repeatCounter) + { + repeatCount = this.repeatCounter; + } + + this.nextAnim = key; + + this._pendingStop = 2; + this._pendingStopValue = repeatCount; + } + + return this.parent; + }, + + /** + * Start playing the given animation on this Sprite. + * + * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. + * + * The benefit of a global animation is that multiple Sprites can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any Sprite. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Sprite. + * + * With the animation created, either globally or locally, you can now play it on this Sprite: + * + * ```javascript + * this.add.sprite(x, y).play('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config + * object instead: + * + * ```javascript + * this.add.sprite(x, y).play({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Sprite to be able to play both local and global animations, make sure they don't + * have conflicting keys. + * + * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * + * Also, see the documentation in the Animation Manager for further details on creating animations. + * + * @method Phaser.Animations.AnimationState#play + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.0.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {boolean} [ignoreIfPlaying=false] - If this animation is already playing then ignore this call. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + play: function (key, ignoreIfPlaying) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + + var currentAnim = this.currentAnim; + var parent = this.parent; + + // Must be either an Animation instance, or a PlayAnimationConfig object + var animKey = (typeof key === 'string') ? key : key.key; + + if (ignoreIfPlaying && this.isPlaying && currentAnim.key === animKey) + { + return parent; + } + + // Are we mixing? + if (currentAnim && this.isPlaying) + { + var mix = this.animationManager.getMix(currentAnim.key, key); + + if (mix > 0) + { + return this.playAfterDelay(key, mix); + } + } + + this.forward = true; + this.inReverse = false; + + this._paused = false; + this._wasPlaying = true; + + return this.startAnimation(key); + }, + + /** + * Start playing the given animation on this Sprite, in reverse. + * + * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. + * + * The benefit of a global animation is that multiple Sprites can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any Sprite. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Sprite. + * + * With the animation created, either globally or locally, you can now play it on this Sprite: + * + * ```javascript + * this.add.sprite(x, y).playReverse('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config + * object instead: + * + * ```javascript + * this.add.sprite(x, y).playReverse({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Sprite to be able to play both local and global animations, make sure they don't + * have conflicting keys. + * + * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * + * Also, see the documentation in the Animation Manager for further details on creating animations. + * + * @method Phaser.Animations.AnimationState#playReverse + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.12.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playReverse: function (key, ignoreIfPlaying) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + + // Must be either an Animation instance, or a PlayAnimationConfig object + var animKey = (typeof key === 'string') ? key : key.key; + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === animKey) + { + return this.parent; + } + + this.forward = false; + this.inReverse = true; + + this._paused = false; + this._wasPlaying = true; + + return this.startAnimation(key); + }, + + /** + * Load the animation based on the key and set-up all of the internal values + * needed for playback to start. If there is no delay, it will also fire the start events. + * + * @method Phaser.Animations.AnimationState#startAnimation + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.50.0 + * + * @param {(string|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or a `PlayAnimationConfig` object. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + startAnimation: function (key) + { + this.load(key); + + var anim = this.currentAnim; + var gameObject = this.parent; + + if (!anim) + { + return gameObject; + } + + // Should give us 9,007,199,254,740,991 safe repeats + this.repeatCounter = (this.repeat === -1) ? Number.MAX_VALUE : this.repeat; + + anim.getFirstTick(this); + + this.isPlaying = true; + this.pendingRepeat = false; + this.hasStarted = false; + + this._pendingStop = 0; + this._pendingStopValue = 0; + this._paused = false; + + // Add any delay the animation itself may have had as well + this.delayCounter += this.delay; + + if (this.delayCounter === 0) + { + this.handleStart(); + } + else if (this.showBeforeDelay) + { + // We have a delay, but still need to set the frame + this.setCurrentFrame(this.currentFrame); + } + + return gameObject; + }, + + /** + * Handles the start of an animation playback. + * + * @method Phaser.Animations.AnimationState#handleStart + * @private + * @since 3.50.0 + */ + handleStart: function () + { + if (this.showOnStart) + { + this.parent.setVisible(true); + } + + this.setCurrentFrame(this.currentFrame); + + this.hasStarted = true; + + this.emitEvents(Events.ANIMATION_START); + }, + + /** + * Handles the repeat of an animation. + * + * @method Phaser.Animations.AnimationState#handleRepeat + * @private + * @since 3.50.0 + */ + handleRepeat: function () + { + this.pendingRepeat = false; + + this.emitEvents(Events.ANIMATION_REPEAT); + }, + + /** + * Handles the stop of an animation playback. + * + * @method Phaser.Animations.AnimationState#handleStop + * @private + * @since 3.50.0 + */ + handleStop: function () + { + this._pendingStop = 0; + + this.isPlaying = false; + + this.emitEvents(Events.ANIMATION_STOP); + }, + + /** + * Handles the completion of an animation playback. + * + * @method Phaser.Animations.AnimationState#handleComplete + * @private + * @since 3.50.0 + */ + handleComplete: function () + { + this._pendingStop = 0; + + this.isPlaying = false; + + if (this.hideOnComplete) + { + this.parent.setVisible(false); + } + + this.emitEvents(Events.ANIMATION_COMPLETE, Events.ANIMATION_COMPLETE_KEY); + }, + + /** + * Fires the given animation event. + * + * @method Phaser.Animations.AnimationState#emitEvents + * @private + * @since 3.50.0 + * + * @param {string} event - The Animation Event to dispatch. + */ + emitEvents: function (event, keyEvent) + { + var anim = this.currentAnim; + + if (anim) + { + var frame = this.currentFrame; + + var gameObject = this.parent; + + var frameKey = frame.textureFrame; + + gameObject.emit(event, anim, frame, gameObject, frameKey); + + if (keyEvent) + { + gameObject.emit(keyEvent + anim.key, anim, frame, gameObject, frameKey); + } + } + }, + + /** + * Reverse the Animation that is already playing on the Game Object. + * + * @method Phaser.Animations.AnimationState#reverse + * @since 3.12.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + reverse: function () + { + if (this.isPlaying) + { + this.inReverse = !this.inReverse; + + this.forward = !this.forward; + } + + return this.parent; + }, + + /** + * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. + * + * The value is based on the current frame and how far that is in the animation, it is not based on + * the duration of the animation. + * + * @method Phaser.Animations.AnimationState#getProgress + * @since 3.4.0 + * + * @return {number} The progress of the current animation in frames, between 0 and 1. + */ + getProgress: function () + { + var frame = this.currentFrame; + + if (!frame) + { + return 0; + } + + var p = frame.progress; + + if (this.inReverse) + { + p *= -1; + } + + return p; + }, + + /** + * Takes a value between 0 and 1 and uses it to set how far this animation is through playback. + * + * Does not factor in repeats or yoyos, but does handle playing forwards or backwards. + * + * The value is based on the current frame and how far that is in the animation, it is not based on + * the duration of the animation. + * + * @method Phaser.Animations.AnimationState#setProgress + * @since 3.4.0 + * + * @param {number} [value=0] - The progress value, between 0 and 1. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setProgress: function (value) + { + if (!this.forward) + { + value = 1 - value; + } + + this.setCurrentFrame(this.currentAnim.getFrameByProgress(value)); + + return this.parent; + }, + + /** + * Sets the number of times that the animation should repeat after its first play through. + * For example, if repeat is 1, the animation will play a total of twice: the initial play plus 1 repeat. + * + * To repeat indefinitely, use -1. + * The value should always be an integer. + * + * Calling this method only works if the animation is already running. Otherwise, any + * value specified here will be overwritten when the next animation loads in. To avoid this, + * use the `repeat` property of the `PlayAnimationConfig` object instead. + * + * @method Phaser.Animations.AnimationState#setRepeat + * @since 3.4.0 + * + * @param {number} value - The number of times that the animation should repeat. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setRepeat: function (value) + { + this.repeatCounter = (value === -1) ? Number.MAX_VALUE : value; + + return this.parent; + }, + + /** + * Handle the removal of an animation from the Animation Manager. + * + * @method Phaser.Animations.AnimationState#globalRemove + * @since 3.50.0 + * + * @param {string} [key] - The key of the removed Animation. + * @param {Phaser.Animations.Animation} [animation] - The removed Animation. + */ + globalRemove: function (key, animation) + { + if (animation === undefined) { animation = this.currentAnim; } + + if (this.isPlaying && animation.key === this.currentAnim.key) + { + this.stop(); + + this.setCurrentFrame(this.currentAnim.frames[0]); + } + }, + + /** + * Restarts the current animation from its beginning. + * + * You can optionally reset the delay and repeat counters as well. + * + * Calling this will fire the `ANIMATION_RESTART` event immediately. + * + * If you `includeDelay` then it will also fire the `ANIMATION_START` event once + * the delay has expired, otherwise, playback will just begin immediately. + * + * @method Phaser.Animations.AnimationState#restart + * @fires Phaser.Animations.Events#ANIMATION_RESTART + * @since 3.0.0 + * + * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. + * @param {boolean} [resetRepeats=false] - Whether to reset the repeat counter or not? + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + restart: function (includeDelay, resetRepeats) + { + if (includeDelay === undefined) { includeDelay = false; } + if (resetRepeats === undefined) { resetRepeats = false; } + + var anim = this.currentAnim; + var gameObject = this.parent; + + if (!anim) + { + return gameObject; + } + + if (resetRepeats) + { + this.repeatCounter = (this.repeat === -1) ? Number.MAX_VALUE : this.repeat; + } + + anim.getFirstTick(this); + + this.emitEvents(Events.ANIMATION_RESTART); + + this.isPlaying = true; + this.pendingRepeat = false; + + // Set this to `true` if there is no delay to include, so it skips the `hasStarted` check in `update`. + this.hasStarted = !includeDelay; + + this._pendingStop = 0; + this._pendingStopValue = 0; + this._paused = false; + + this.setCurrentFrame(anim.frames[0]); + + return this.parent; + }, + + /** + * The current animation has completed. This dispatches the `ANIMATION_COMPLETE` event. + * + * This method is called by the Animation instance and should not usually be invoked directly. + * + * If no animation is loaded, no events will be dispatched. + * + * If another animation has been queued for playback, it will be started after the events fire. + * + * @method Phaser.Animations.AnimationState#complete + * @fires Phaser.Animations.Events#ANIMATION_COMPLETE + * @since 3.50.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + complete: function () + { + this._pendingStop = 0; + + this.isPlaying = false; + + if (this.currentAnim) + { + this.handleComplete(); + } + + if (this.nextAnim) + { + var key = this.nextAnim; + + this.nextAnim = (this.nextAnimsQueue.length > 0) ? this.nextAnimsQueue.shift() : null; + + this.play(key); + } + + return this.parent; + }, + + /** + * Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing. + * + * @method Phaser.Animations.AnimationState#stop + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stop: function () + { + this._pendingStop = 0; + + this.isPlaying = false; + + this.delayCounter = 0; + + if (this.currentAnim) + { + this.handleStop(); + } + + if (this.nextAnim) + { + var key = this.nextAnim; + + this.nextAnim = this.nextAnimsQueue.shift(); + + this.play(key); + } + + return this.parent; + }, + + /** + * Stops the current animation from playing after the specified time delay, given in milliseconds. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * + * @method Phaser.Animations.AnimationState#stopAfterDelay + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.4.0 + * + * @param {number} delay - The number of milliseconds to wait before stopping this animation. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stopAfterDelay: function (delay) + { + this._pendingStop = 1; + this._pendingStopValue = delay; + + return this.parent; + }, + + /** + * Stops the current animation from playing when it next repeats. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * + * Prior to Phaser 3.50 this method was called `stopOnRepeat` and had no parameters. + * + * @method Phaser.Animations.AnimationState#stopAfterRepeat + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.50.0 + * + * @param {number} [repeatCount=1] - How many times should the animation repeat before stopping? + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stopAfterRepeat: function (repeatCount) + { + if (repeatCount === undefined) { repeatCount = 1; } + + if (this.repeatCounter !== -1 && repeatCount > this.repeatCounter) + { + repeatCount = this.repeatCounter; + } + + this._pendingStop = 2; + this._pendingStopValue = repeatCount; + + return this.parent; + }, + + /** + * Stops the current animation from playing when it next sets the given frame. + * If this frame doesn't exist within the animation it will not stop it from playing. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * + * @method Phaser.Animations.AnimationState#stopOnFrame + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.4.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - The frame to check before stopping this animation. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stopOnFrame: function (frame) + { + this._pendingStop = 3; + this._pendingStopValue = frame; + + return this.parent; + }, + + /** + * Returns the total number of frames in this animation, or returns zero if no + * animation has been loaded. + * + * @method Phaser.Animations.AnimationState#getTotalFrames + * @since 3.4.0 + * + * @return {number} The total number of frames in the current animation, or zero if no animation has been loaded. + */ + getTotalFrames: function () + { + return (this.currentAnim) ? this.currentAnim.getTotalFrames() : 0; + }, + + /** + * The internal update loop for the AnimationState Component. + * + * This is called automatically by the `Sprite.preUpdate` method. + * + * @method Phaser.Animations.AnimationState#update + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + var anim = this.currentAnim; + + if (!this.isPlaying || !anim || anim.paused) + { + return; + } + + this.accumulator += delta * this.timeScale * this.animationManager.globalTimeScale; + + if (this._pendingStop === 1) + { + this._pendingStopValue -= delta; + + if (this._pendingStopValue <= 0) + { + return this.stop(); + } + } + + if (!this.hasStarted) + { + if (this.accumulator >= this.delayCounter) + { + this.accumulator -= this.delayCounter; + + this.handleStart(); + } + } + else if (this.accumulator >= this.nextTick) + { + // Process one frame advance as standard + + if (this.forward) + { + anim.nextFrame(this); + } + else + { + anim.previousFrame(this); + } + + // And only do more if we're skipping frames and have time left + if (this.isPlaying && this._pendingStop === 0 && this.skipMissedFrames && this.accumulator > this.nextTick) + { + var safetyNet = 0; + + do + { + if (this.forward) + { + anim.nextFrame(this); + } + else + { + anim.previousFrame(this); + } + + safetyNet++; + + } while (this.isPlaying && this.accumulator > this.nextTick && safetyNet < 60); + } + } + }, + + /** + * Sets the given Animation Frame as being the current frame + * and applies it to the parent Game Object, adjusting size and origin as needed. + * + * @method Phaser.Animations.AnimationState#setCurrentFrame + * @fires Phaser.Animations.Events#ANIMATION_UPDATE + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.4.0 + * + * @param {Phaser.Animations.AnimationFrame} animationFrame - The animation frame to change to. + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + setCurrentFrame: function (animationFrame) + { + var gameObject = this.parent; + + this.currentFrame = animationFrame; + + gameObject.texture = animationFrame.frame.texture; + gameObject.frame = animationFrame.frame; + + if (gameObject.isCropped) + { + gameObject.frame.updateCropUVs(gameObject._crop, gameObject.flipX, gameObject.flipY); + } + + if (animationFrame.setAlpha) + { + gameObject.alpha = animationFrame.alpha; + } + + gameObject.setSizeToFrame(); + + if (gameObject._originComponent) + { + if (animationFrame.frame.customPivot) + { + gameObject.setOrigin(animationFrame.frame.pivotX, animationFrame.frame.pivotY); + } + else + { + gameObject.updateDisplayOrigin(); + } + } + + if (this.isPlaying && this.hasStarted) + { + this.emitEvents(Events.ANIMATION_UPDATE); + + if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) + { + this.stop(); + } + } + + return gameObject; + }, + + /** + * Advances the animation to the next frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in reverse, calling this method doesn't then change the direction to forwards. + * + * @method Phaser.Animations.AnimationState#nextFrame + * @since 3.16.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + nextFrame: function () + { + if (this.currentAnim) + { + this.currentAnim.nextFrame(this); + } + + return this.parent; + }, + + /** + * Advances the animation to the previous frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in forwards, calling this method doesn't then change the direction to backwards. + * + * @method Phaser.Animations.AnimationState#previousFrame + * @since 3.16.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + previousFrame: function () + { + if (this.currentAnim) + { + this.currentAnim.previousFrame(this); + } + + return this.parent; + }, + + /** + * Get an Animation instance that has been created locally on this Sprite. + * + * See the `create` method for more details. + * + * @method Phaser.Animations.AnimationState#get + * @since 3.50.0 + * + * @param {string} key - The key of the Animation to retrieve. + * + * @return {Phaser.Animations.Animation} The Animation, or `null` if the key is invalid. + */ + get: function (key) + { + return (this.anims) ? this.anims.get(key) : null; + }, + + /** + * Checks to see if the given key is already used locally within the animations stored on this Sprite. + * + * @method Phaser.Animations.AnimationState#exists + * @since 3.50.0 + * + * @param {string} key - The key of the Animation to check. + * + * @return {boolean} `true` if the Animation exists locally, or `false` if the key is available, or there are no local animations. + */ + exists: function (key) + { + return (this.anims) ? this.anims.has(key) : false; + }, + + /** + * Creates a new Animation that is local specifically to this Sprite. + * + * When a Sprite owns an animation, it is kept out of the global Animation Manager, which means + * you're free to use keys that may be already defined there. Unless you specifically need a Sprite + * to have a unique animation, you should favor using global animations instead, as they allow for + * the same animation to be used across multiple Sprites, saving on memory. However, if this Sprite + * is the only one to use this animation, it's sensible to create it here. + * + * If an invalid key is given this method will return `false`. + * + * If you pass the key of an animation that already exists locally, that animation will be returned. + * + * A brand new animation is only created if the key is valid and not already in use by this Sprite. + * + * If you wish to re-use an existing key, call the `remove` method first, then this method. + * + * @method Phaser.Animations.AnimationState#create + * @since 3.50.0 + * + * @param {Phaser.Types.Animations.Animation} config - The configuration settings for the Animation. + * + * @return {(Phaser.Animations.Animation|false)} The Animation that was created, or `false` if the key is already in use. + */ + create: function (config) + { + var key = config.key; + + var anim = false; + + if (key) + { + anim = this.get(key); + + if (!anim) + { + anim = new Animation(this, key, config); + + if (!this.anims) + { + this.anims = new CustomMap(); + } + + this.anims.set(key, anim); + } + else + { + console.warn('Animation key already exists: ' + key); + } + } + + return anim; + }, + + /** + * Create one, or more animations from a loaded Aseprite JSON file. + * + * Aseprite is a powerful animated sprite editor and pixel art tool. + * + * You can find more details at https://www.aseprite.org/ + * + * To export a compatible JSON file in Aseprite, please do the following: + * + * 1. Go to "File - Export Sprite Sheet" + * + * 2. On the **Layout** tab: + * 2a. Set the "Sheet type" to "Packed" + * 2b. Set the "Constraints" to "None" + * 2c. Check the "Merge Duplicates" checkbox + * + * 3. On the **Sprite** tab: + * 3a. Set "Layers" to "Visible layers" + * 3b. Set "Frames" to "All frames", unless you only wish to export a sub-set of tags + * + * 4. On the **Borders** tab: + * 4a. Check the "Trim Sprite" and "Trim Cells" options + * 4b. Ensure "Border Padding", "Spacing" and "Inner Padding" are all > 0 (1 is usually enough) + * + * 5. On the **Output** tab: + * 5a. Check "Output File", give your image a name and make sure you choose "png files" as the file type + * 5b. Check "JSON Data" and give your json file a name + * 5c. The JSON Data type can be either a Hash or Array, Phaser doesn't mind. + * 5d. Make sure "Tags" is checked in the Meta options + * 5e. In the "Item Filename" input box, make sure it says just "{frame}" and nothing more. + * + * 6. Click export + * + * This was tested with Aseprite 1.2.25. + * + * This will export a png and json file which you can load using the Aseprite Loader, i.e.: + * + * ```javascript + * function preload () + * { + * this.load.path = 'assets/animations/aseprite/'; + * this.load.aseprite('paladin', 'paladin.png', 'paladin.json'); + * } + * ``` + * + * Once loaded, you can call this method on a Sprite with the 'atlas' key: + * + * ```javascript + * const sprite = this.add.sprite(400, 300); + * + * sprite.anims.createFromAseprite('paladin'); + * ``` + * + * Any animations defined in the JSON will now be available to use on this Sprite and you play them + * via their Tag name. For example, if you have an animation called 'War Cry' on your Aseprite timeline, + * you can play it on the Sprite using that Tag name: + * + * ```javascript + * const sprite = this.add.sprite(400, 300); + * + * sprite.anims.createFromAseprite('paladin'); + * + * sprite.play('War Cry'); + * ``` + * + * When calling this method you can optionally provide an array of tag names, and only those animations + * will be created. For example: + * + * ```javascript + * sprite.anims.createFromAseprite('paladin', [ 'step', 'War Cry', 'Magnum Break' ]); + * ``` + * + * This will only create the 3 animations defined. Note that the tag names are case-sensitive. + * + * @method Phaser.Animations.AnimationState#createFromAseprite + * @since 3.60.0 + * + * @param {string} key - The key of the loaded Aseprite atlas. It must have been loaded prior to calling this method. + * @param {string[]} [tags] - An array of Tag names. If provided, only animations found in this array will be created. + * + * @return {Phaser.Animations.Animation[]} An array of Animation instances that were successfully created. + */ + createFromAseprite: function (key, tags) + { + return this.animationManager.createFromAseprite(key, tags, this.parent); + }, + + /** + * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. + * + * Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}. + * + * It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases. + * If you're working with a sprite sheet, see the `generateFrameNumbers` method instead. + * + * Example: + * + * If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on, + * then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', end: 6, zeroPad: 4 })`. + * + * The `end` value tells it to look for 6 frames, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad` + * value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do: + * + * ```javascript + * this.anims.create({ + * key: 'ruby', + * repeat: -1, + * frames: this.anims.generateFrameNames('gems', { + * prefix: 'ruby_', + * end: 6, + * zeroPad: 4 + * }) + * }); + * ``` + * + * Please see the animation examples for further details. + * + * @method Phaser.Animations.AnimationState#generateFrameNames + * @since 3.50.0 + * + * @param {string} key - The key for the texture containing the animation frames. + * @param {Phaser.Types.Animations.GenerateFrameNames} [config] - The configuration object for the animation frame names. + * + * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. + */ + generateFrameNames: function (key, config) + { + return this.animationManager.generateFrameNames(key, config); + }, + + /** + * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}. + * + * If you're working with a texture atlas, see the `generateFrameNames` method instead. + * + * It's a helper method, designed to make it easier for you to extract frames from sprite sheets. + * + * Example: + * + * If you have a sprite sheet loaded called `explosion` and it contains 12 frames, then you can call this method using: + * `this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 })`. + * + * The `end` value tells it to stop after 12 frames. To create an animation using this method, you can do: + * + * ```javascript + * this.anims.create({ + * key: 'boom', + * frames: this.anims.generateFrameNumbers('explosion', { + * start: 0, + * end: 11 + * }) + * }); + * ``` + * + * Note that `start` is optional and you don't need to include it if the animation starts from frame 0. + * + * To specify an animation in reverse, swap the `start` and `end` values. + * + * If the frames are not sequential, you may pass an array of frame numbers instead, for example: + * + * `this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })` + * + * Please see the animation examples and `GenerateFrameNumbers` config docs for further details. + * + * @method Phaser.Animations.AnimationState#generateFrameNumbers + * @since 3.50.0 + * + * @param {string} key - The key for the texture containing the animation frames. + * @param {Phaser.Types.Animations.GenerateFrameNumbers} [config] - The configuration object for the animation frames. + * + * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. + */ + generateFrameNumbers: function (key, config) + { + return this.animationManager.generateFrameNumbers(key, config); + }, + + /** + * Removes a locally created Animation from this Sprite, based on the given key. + * + * Once an Animation has been removed, this Sprite cannot play it again without re-creating it. + * + * @method Phaser.Animations.AnimationState#remove + * @since 3.50.0 + * + * @param {string} key - The key of the animation to remove. + * + * @return {Phaser.Animations.Animation} The Animation instance that was removed from this Sprite, if the key was valid. + */ + remove: function (key) + { + var anim = this.get(key); + + if (anim) + { + if (this.currentAnim === anim) + { + this.stop(); + } + + this.anims.delete(key); + } + + return anim; + }, + + /** + * Destroy this Animation component. + * + * Unregisters event listeners and cleans up its references. + * + * @method Phaser.Animations.AnimationState#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.animationManager.off(Events.REMOVE_ANIMATION, this.globalRemove, this); + + if (this.anims) + { + this.anims.clear(); + } + + this.animationManager = null; + this.parent = null; + this.nextAnim = null; + this.nextAnimsQueue.length = 0; + + this.currentAnim = null; + this.currentFrame = null; + }, + + /** + * `true` if the current animation is paused, otherwise `false`. + * + * @name Phaser.Animations.AnimationState#isPaused + * @readonly + * @type {boolean} + * @since 3.4.0 + */ + isPaused: { + + get: function () + { + return this._paused; + } + + } + +}); + +module.exports = AnimationState; + + +/***/ }, + +/***/ 57090 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Add Animation Event. + * + * This event is dispatched when a new animation is added to the global Animation Manager. + * + * This can happen either as a result of an animation instance being added to the Animation Manager, + * or the Animation Manager creating a new animation directly. + * + * @event Phaser.Animations.Events#ADD_ANIMATION + * @type {string} + * @since 3.0.0 + * + * @param {string} key - The key of the Animation that was added to the global Animation Manager. + * @param {Phaser.Animations.Animation} animation - An instance of the newly created Animation. + */ +module.exports = 'add'; + + +/***/ }, + +/***/ 25312 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Animation Complete Event. + * + * This event is dispatched by a Sprite when an animation playing on it completes playback. + * This happens when the animation gets to the end of its sequence, factoring in any delays + * or repeats it may have to process. + * + * An animation that is set to loop, or repeat forever, will never fire this event, because + * it never actually completes. If you need to handle this, listen for the `ANIMATION_STOP` + * event instead, as this is emitted when the animation is stopped directly. + * + * Listen for it on the Sprite using `sprite.on('animationcomplete', listener)` + * + * The animation event flow is as follows: + * + * 1. `ANIMATION_START` + * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) + * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) + * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) + * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) + * + * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. + * + * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. + * + * @event Phaser.Animations.Events#ANIMATION_COMPLETE + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} animation - A reference to the Animation that completed. + * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. + * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation updated. + * @param {string} frameKey - The unique key of the Animation Frame within the Animation. + */ +module.exports = 'animationcomplete'; + + +/***/ }, + +/***/ 89580 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Animation Complete Dynamic Key Event. + * + * This event is dispatched by a Sprite when an animation playing on it completes playback. + * This happens when the animation gets to the end of its sequence, factoring in any delays + * or repeats it may have to process. + * + * An animation that is set to loop, or repeat forever, will never fire this event, because + * it never actually completes. If you need to handle this, listen for the `ANIMATION_STOP` + * event instead, as this is emitted when the animation is stopped directly. + * + * The difference between this and the `ANIMATION_COMPLETE` event is that this one has a + * dynamic event name that contains the name of the animation within it. For example, + * if you had an animation called `explode` you could listen for the completion of that + * specific animation by using: `sprite.on('animationcomplete-explode', listener)`. Or, if you + * wish to use types: `sprite.on(Phaser.Animations.Events.ANIMATION_COMPLETE_KEY + 'explode', listener)`. + * + * The animation event flow is as follows: + * + * 1. `ANIMATION_START` + * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) + * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) + * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) + * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) + * + * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. + * + * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. + * + * @event Phaser.Animations.Events#ANIMATION_COMPLETE_KEY + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} animation - A reference to the Animation that completed. + * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. + * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation updated. + * @param {string} frameKey - The unique key of the Animation Frame within the Animation. + */ +module.exports = 'animationcomplete-'; + + +/***/ }, + +/***/ 52860 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Animation Repeat Event. + * + * This event is dispatched by a Sprite when an animation repeats playing on it. + * This happens if the animation was created, or played, with a `repeat` value specified. + * + * An animation will repeat when it reaches the end of its sequence. + * + * Listen for it on the Sprite using `sprite.on('animationrepeat', listener)` + * + * The animation event flow is as follows: + * + * 1. `ANIMATION_START` + * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) + * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) + * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) + * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) + * + * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. + * + * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. + * + * @event Phaser.Animations.Events#ANIMATION_REPEAT + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has repeated. + * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. + * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation repeated. + * @param {string} frameKey - The unique key of the Animation Frame within the Animation. + */ +module.exports = 'animationrepeat'; + + +/***/ }, + +/***/ 63850 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Animation Restart Event. + * + * This event is dispatched by a Sprite when an animation restarts playing on it. + * This only happens when the `Sprite.anims.restart` method is called. + * + * Listen for it on the Sprite using `sprite.on('animationrestart', listener)` + * + * The animation event flow is as follows: + * + * 1. `ANIMATION_START` + * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) + * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) + * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) + * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) + * + * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. + * + * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. + * + * @event Phaser.Animations.Events#ANIMATION_RESTART + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has restarted. + * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. + * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation restarted. + * @param {string} frameKey - The unique key of the Animation Frame within the Animation. + */ +module.exports = 'animationrestart'; + + +/***/ }, + +/***/ 99085 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Animation Start Event. + * + * This event is dispatched by a Sprite when an animation starts playing on it. + * This happens when the animation is played, factoring in any delay that may have been specified. + * This event happens after the delay has expired and prior to the first update event. + * + * Listen for it on the Sprite using `sprite.on('animationstart', listener)` + * + * The animation event flow is as follows: + * + * 1. `ANIMATION_START` + * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) + * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) + * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) + * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) + * + * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. + * + * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. + * + * @event Phaser.Animations.Events#ANIMATION_START + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has started. + * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. + * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation started. + * @param {string} frameKey - The unique key of the Animation Frame within the Animation. + */ +module.exports = 'animationstart'; + + +/***/ }, + +/***/ 28087 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Animation Stop Event. + * + * This event is dispatched by a Sprite when an animation is stopped on it. An animation + * will only be stopped if a method such as `Sprite.stop` or `Sprite.anims.stopAfterDelay` + * is called. It can also be emitted if a new animation is started before the current one completes. + * + * Listen for it on the Sprite using `sprite.on('animationstop', listener)` + * + * The animation event flow is as follows: + * + * 1. `ANIMATION_START` + * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) + * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) + * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) + * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) + * + * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. + * + * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. + * + * @event Phaser.Animations.Events#ANIMATION_STOP + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has stopped. + * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. + * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation stopped. + * @param {string} frameKey - The unique key of the Animation Frame within the Animation. + */ +module.exports = 'animationstop'; + + +/***/ }, + +/***/ 1794 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Animation Update Event. + * + * This event is dispatched by a Sprite when an animation playing on it updates. This happens when the animation changes frame. + * An animation will change frame based on the frame rate and other factors like `timeScale` and `delay`. It can also change + * frame when stopped or restarted. + * + * Listen for it on the Sprite using `sprite.on('animationupdate', listener)` + * + * If an animation is playing faster than the game frame-rate can handle, it's entirely possible for it to emit several + * update events in a single game frame, so please be aware of this in your code. The **final** event received that frame + * is the one that is rendered to the game. + * + * The animation event flow is as follows: + * + * 1. `ANIMATION_START` + * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) + * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) + * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) + * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) + * + * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. + * + * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. + * + * @event Phaser.Animations.Events#ANIMATION_UPDATE + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has updated. + * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. + * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation updated. + * @param {string} frameKey - The unique key of the Animation Frame within the Animation. + */ +module.exports = 'animationupdate'; + + +/***/ }, + +/***/ 52562 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pause All Animations Event. + * + * This event is dispatched when the global Animation Manager is told to pause. + * + * When this happens all current animations will stop updating, although it doesn't necessarily mean + * that the game has paused as well. + * + * @event Phaser.Animations.Events#PAUSE_ALL + * @type {string} + * @since 3.0.0 + */ +module.exports = 'pauseall'; + + +/***/ }, + +/***/ 57953 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Remove Animation Event. + * + * This event is dispatched when an animation is removed from the global Animation Manager. + * + * @event Phaser.Animations.Events#REMOVE_ANIMATION + * @type {string} + * @since 3.0.0 + * + * @param {string} key - The key of the Animation that was removed from the global Animation Manager. + * @param {Phaser.Animations.Animation} animation - An instance of the removed Animation. + */ +module.exports = 'remove'; + + +/***/ }, + +/***/ 68339 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Resume All Animations Event. + * + * This event is dispatched when the global Animation Manager resumes, having been previously paused. + * + * When this happens all current animations will continue updating again. + * + * @event Phaser.Animations.Events#RESUME_ALL + * @type {string} + * @since 3.0.0 + */ +module.exports = 'resumeall'; + + +/***/ }, + +/***/ 74943 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Animations.Events + */ + +module.exports = { + + ADD_ANIMATION: __webpack_require__(57090), + ANIMATION_COMPLETE: __webpack_require__(25312), + ANIMATION_COMPLETE_KEY: __webpack_require__(89580), + ANIMATION_REPEAT: __webpack_require__(52860), + ANIMATION_RESTART: __webpack_require__(63850), + ANIMATION_START: __webpack_require__(99085), + ANIMATION_STOP: __webpack_require__(28087), + ANIMATION_UPDATE: __webpack_require__(1794), + PAUSE_ALL: __webpack_require__(52562), + REMOVE_ANIMATION: __webpack_require__(57953), + RESUME_ALL: __webpack_require__(68339) + +}; + + +/***/ }, + +/***/ 60421 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Animations + */ + +module.exports = { + + Animation: __webpack_require__(42099), + AnimationFrame: __webpack_require__(41138), + AnimationManager: __webpack_require__(60848), + AnimationState: __webpack_require__(9674), + Events: __webpack_require__(74943) + +}; + + +/***/ }, + +/***/ 2161 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CustomMap = __webpack_require__(90330); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(24736); + +/** + * @classdesc + * A key-value store used by the Phaser framework to cache loaded assets and other data. + * Items are stored and retrieved using string-based keys. The BaseCache emits events when + * items are added or removed, allowing other systems to react to cache changes. Multiple + * BaseCache instances are owned by the CacheManager, one per asset type (JSON, binary, + * audio, etc.), and you can also create custom caches via `CacheManager.addCustom()`. + * + * @class BaseCache + * @memberof Phaser.Cache + * @constructor + * @since 3.0.0 + */ +var BaseCache = new Class({ + + initialize: + + function BaseCache () + { + /** + * The Map in which the cache objects are stored. + * + * You can query the Map directly or use the BaseCache methods. + * + * @name Phaser.Cache.BaseCache#entries + * @type {Phaser.Structs.Map.} + * @since 3.0.0 + */ + this.entries = new CustomMap(); + + /** + * An instance of EventEmitter used by the cache to emit related events. + * + * @name Phaser.Cache.BaseCache#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + }, + + /** + * Adds an item to this cache. The item is referenced by a unique string, which you are responsible + * for setting and keeping track of. The item can only be retrieved by using this string. + * + * @method Phaser.Cache.BaseCache#add + * @fires Phaser.Cache.Events#ADD + * @since 3.0.0 + * + * @param {string} key - The unique key by which the data added to the cache will be referenced. + * @param {*} data - The data to be stored in the cache. + * + * @return {this} This BaseCache object. + */ + add: function (key, data) + { + this.entries.set(key, data); + + this.events.emit(Events.ADD, this, key, data); + + return this; + }, + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.exists`. + * + * @method Phaser.Cache.BaseCache#has + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be checked in this cache. + * + * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. + */ + has: function (key) + { + return this.entries.has(key); + }, + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.has` and is called directly by the Loader. + * + * @method Phaser.Cache.BaseCache#exists + * @since 3.7.0 + * + * @param {string} key - The unique key of the item to be checked in this cache. + * + * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. + */ + exists: function (key) + { + return this.entries.has(key); + }, + + /** + * Gets an item from this cache based on the given key. + * + * @method Phaser.Cache.BaseCache#get + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be retrieved from this cache. + * + * @return {*} The item in the cache, or `null` if no item matching the given key was found. + */ + get: function (key) + { + return this.entries.get(key); + }, + + /** + * Removes an item from this cache based on the given key. + * + * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. + * No additional checks are done on the item removed. If other systems or parts of your game code + * are relying on this item, it is up to you to sever those relationships prior to removing the item. + * + * @method Phaser.Cache.BaseCache#remove + * @fires Phaser.Cache.Events#REMOVE + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to remove from the cache. + * + * @return {this} This BaseCache object. + */ + remove: function (key) + { + var entry = this.get(key); + + if (entry) + { + this.entries.delete(key); + + this.events.emit(Events.REMOVE, this, key, entry.data); + } + + return this; + }, + + /** + * Returns all keys in use in this cache. + * + * @method Phaser.Cache.BaseCache#getKeys + * @since 3.17.0 + * + * @return {string[]} An array of strings containing all keys currently stored in this cache. + */ + getKeys: function () + { + return this.entries.keys(); + }, + + /** + * Destroys this cache and all items within it. Clears the entries Map, removes all + * event listeners from the EventEmitter, and nulls the internal references. + * + * @method Phaser.Cache.BaseCache#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.entries.clear(); + this.events.removeAllListeners(); + + this.entries = null; + this.events = null; + } + +}); + +module.exports = BaseCache; + + +/***/ }, + +/***/ 24047 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BaseCache = __webpack_require__(2161); +var Class = __webpack_require__(83419); +var GameEvents = __webpack_require__(8443); + +/** + * @classdesc + * The Cache Manager is the global cache owned and maintained by the Game instance. + * + * Various systems, such as the file Loader, rely on this cache in order to store the files + * they have loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache + * instances, one per type of file. Built-in caches are provided for binary files, bitmap fonts, + * JSON, physics data, shaders, audio, video, text, HTML, WaveFront OBJ, tilemaps, and XML. + * You can also add your own custom caches via the `addCustom` method. + * + * The Cache Manager is available in any Scene via `this.cache` and is shared across all Scenes. + * + * @class CacheManager + * @memberof Phaser.Cache + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager. + */ +var CacheManager = new Class({ + + initialize: + + function CacheManager (game) + { + /** + * A reference to the Phaser.Game instance that owns this CacheManager. + * + * @name Phaser.Cache.CacheManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * A Cache storing all binary files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#binary + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.binary = new BaseCache(); + + /** + * A Cache storing all bitmap font data files, typically added via the Loader. + * Only the font data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#bitmapFont + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.bitmapFont = new BaseCache(); + + /** + * A Cache storing all JSON data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#json + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.json = new BaseCache(); + + /** + * A Cache storing all physics data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#physics + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.physics = new BaseCache(); + + /** + * A Cache storing all shader source files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#shader + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.shader = new BaseCache(); + + /** + * A Cache storing all non-streaming audio files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#audio + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.audio = new BaseCache(); + + /** + * A Cache storing all non-streaming video files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#video + * @type {Phaser.Cache.BaseCache} + * @since 3.20.0 + */ + this.video = new BaseCache(); + + /** + * A Cache storing all text files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#text + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.text = new BaseCache(); + + /** + * A Cache storing all html files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#html + * @type {Phaser.Cache.BaseCache} + * @since 3.12.0 + */ + this.html = new BaseCache(); + + /** + * A Cache storing all tilemap data files, typically added via the Loader. + * Only the data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#tilemap + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.tilemap = new BaseCache(); + + /** + * A Cache storing all xml data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#xml + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.xml = new BaseCache(); + + /** + * A Cache storing all Phaser Compact Texture Atlas data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#atlas + * @type {Phaser.Cache.BaseCache} + * @since 4.0.0 + */ + this.atlas = new BaseCache(); + + /** + * An object that contains your own custom BaseCache entries. + * Add to this via the `addCustom` method. + * + * @name Phaser.Cache.CacheManager#custom + * @type {Object.} + * @since 3.0.0 + */ + this.custom = {}; + + this.game.events.once(GameEvents.DESTROY, this.destroy, this); + }, + + /** + * Add your own custom Cache for storing your own files. + * The cache will be available under `Cache.custom.key`. + * The cache will only be created if the key is not already in use. + * + * @method Phaser.Cache.CacheManager#addCustom + * @since 3.0.0 + * + * @param {string} key - The unique key of your custom cache. + * + * @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead. + */ + addCustom: function (key) + { + if (!this.custom.hasOwnProperty(key)) + { + this.custom[key] = new BaseCache(); + } + + return this.custom[key]; + }, + + /** + * Destroys all built-in BaseCaches and all custom caches, then nulls their references. Called automatically when the Game instance is destroyed. + * + * @method Phaser.Cache.CacheManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + var keys = [ + 'binary', + 'bitmapFont', + 'json', + 'physics', + 'shader', + 'audio', + 'video', + 'text', + 'html', + 'tilemap', + 'xml', + 'atlas' + ]; + + for (var i = 0; i < keys.length; i++) + { + this[keys[i]].destroy(); + this[keys[i]] = null; + } + + for (var key in this.custom) + { + this.custom[key].destroy(); + } + + this.custom = null; + + this.game = null; + } + +}); + +module.exports = CacheManager; + + +/***/ }, + +/***/ 51464 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Cache Add Event. + * + * This event is dispatched by any Cache that extends the BaseCache each time a new object is added to it. + * + * @event Phaser.Cache.Events#ADD + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Cache.BaseCache} cache - The cache to which the object was added. + * @param {string} key - The key of the object added to the cache. + * @param {*} object - A reference to the object that was added to the cache. + */ +module.exports = 'add'; + + +/***/ }, + +/***/ 59261 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Cache Remove Event. + * + * This event is dispatched by any Cache that extends the BaseCache each time an object is removed from it. + * + * @event Phaser.Cache.Events#REMOVE + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Cache.BaseCache} cache - The cache from which the object was removed. + * @param {string} key - The key of the object removed from the cache. + * @param {*} object - A reference to the object that was removed from the cache. + */ +module.exports = 'remove'; + + +/***/ }, + +/***/ 24736 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Cache.Events + */ + +module.exports = { + + ADD: __webpack_require__(51464), + REMOVE: __webpack_require__(59261) + +}; + + +/***/ }, + +/***/ 83388 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Cache + */ + +module.exports = { + + BaseCache: __webpack_require__(2161), + CacheManager: __webpack_require__(24047), + Events: __webpack_require__(24736) + +}; + + +/***/ }, + +/***/ 71911 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var DegToRad = __webpack_require__(39506); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(19715); +var Rectangle = __webpack_require__(87841); +var AlphaSingle = __webpack_require__(88509); +var TransformMatrix = __webpack_require__(61340); +var Visible = __webpack_require__(59715); +var ValueToColor = __webpack_require__(80333); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Base Camera class. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * The Base Camera is extended by the Camera class, which adds in special effects including Fade, + * Flash and Camera Shake, as well as the ability to follow Game Objects. + * + * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow + * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate + * to when they were added to the Camera class. + * + * @class BaseCamera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.12.0 + * + * @extends Phaser.Events.EventEmitter + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.Visible + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var BaseCamera = new Class({ + + Extends: EventEmitter, + + Mixins: [ + AlphaSingle, + Visible + ], + + initialize: + + function BaseCamera (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + EventEmitter.call(this); + + /** + * A reference to the Scene this camera belongs to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene; + + /** + * A reference to the Game Scene Manager. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#sceneManager + * @type {Phaser.Scenes.SceneManager} + * @since 3.12.0 + */ + this.sceneManager; + + /** + * A reference to the Game Scale Manager. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scaleManager + * @type {Phaser.Scale.ScaleManager} + * @since 3.16.0 + */ + this.scaleManager; + + /** + * A reference to the Scene's Camera Manager to which this Camera belongs. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#cameraManager + * @type {Phaser.Cameras.Scene2D.CameraManager} + * @since 3.17.0 + */ + this.cameraManager; + + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#id + * @type {number} + * @readonly + * @since 3.11.0 + */ + this.id = 0; + + /** + * The name of the Camera. This is left empty for your own use. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * Should this camera round its pixel values to integers? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#roundPixels + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.roundPixels = false; + + /** + * Is this Camera visible or not? + * + * A visible camera will render and perform input tests. + * An invisible camera will not render anything and will skip input tests. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#visible + * @type {boolean} + * @default true + * @since 3.10.0 + */ + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * + * Set this property along with the bounds via `Camera.setBounds`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#useBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useBounds = false; + + /** + * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. + * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. + * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. + * You can use it for culling or intersection checks. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#worldView + * @type {Phaser.Geom.Rectangle} + * @readonly + * @since 3.11.0 + */ + this.worldView = new Rectangle(); + + /** + * Is this Camera dirty? + * + * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. + * + * This flag is cleared during rendering with the new values. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#dirty + * @type {boolean} + * @default true + * @since 3.11.0 + */ + this.dirty = true; + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_x + * @type {number} + * @private + * @since 3.0.0 + */ + this._x = x; + + /** + * The y position of the Camera, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_y + * @type {number} + * @private + * @since 3.0.0 + */ + this._y = y; + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_width + * @type {number} + * @private + * @since 3.11.0 + */ + this._width = width; + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_height + * @type {number} + * @private + * @since 3.11.0 + */ + this._height = height; + + /** + * The bounds the camera is restrained to during scrolling. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollX + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollX = 0; + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollY + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollY = 0; + + /** + * The Camera horizontal zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_zoomX + * @type {number} + * @private + * @default 1 + * @since 3.50.0 + */ + this._zoomX = 1; + + /** + * The Camera vertical zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_zoomY + * @type {number} + * @private + * @default 1 + * @since 3.50.0 + */ + this._zoomY = 1; + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._rotation = 0; + + /** + * A local transform matrix used to compute the camera view. + * + * In v3, this contained a combination of the external camera position, + * and the internal rotation and zoom. + * In v4, it instead contains the internal camera scroll, rotation, and zoom. + * Note that these are applied in the order of rotation, scale, then scroll. + * This makes it easier to apply scaleFactor to the scroll values. + * + * See also `matrixExternal` and `matrixCombined`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#matrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.0.0 + */ + this.matrix = new TransformMatrix(); + + /** + * A local transform matrix combining `matrix` and `matrixExternal`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#matrixCombined + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 4.0.0 + */ + this.matrixCombined = new TransformMatrix(); + + /** + * A local transform matrix used to compute the camera location. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#matrixExternal + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 4.0.0 + */ + this.matrixExternal = new TransformMatrix(); + + /** + * Does this Camera have a transparent background? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#transparent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.transparent = true; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#backgroundColor + * @type {Phaser.Display.Color} + * @since 3.0.0 + */ + this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#alpha + * @type {number} + * @default 1 + * @since 3.11.0 + */ + + /** + * Should the camera cull Game Objects before checking them for input hit tests? + * In some special cases it may be beneficial to disable this. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#disableCull + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.disableCull = false; + + /** + * A temporary array of culled objects. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#culledObjects + * @type {Phaser.GameObjects.GameObject[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.culledObjects = []; + + /** + * The mid-point of the Camera in 'world' coordinates. + * + * Use it to obtain exactly where in the world the center of the camera is currently looking. + * + * This value is updated in the preRender method, after the scroll values and follower + * have been processed. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#midPoint + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.11.0 + */ + this.midPoint = new Vector2(width / 2, height / 2); + + /** + * The horizontal origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originX + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originX = 0.5; + + /** + * The vertical origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originY + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originY = 0.5; + + /** + * Does this Camera have a custom viewport? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_customViewport + * @type {boolean} + * @private + * @default false + * @since 3.12.0 + */ + this._customViewport = false; + + /** + * The Mask this Camera is using during render. + * Set the mask using the `setMask` method. Remove the mask using the `clearMask` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#mask + * @type {?Phaser.Display.Masks.GeometryMask} + * @since 3.17.0 + */ + this.mask = null; + + /** + * The Camera that this Camera uses for translation during masking. + * + * If the mask is fixed in position this will be a reference to + * the CameraManager.default instance. Otherwise, it'll be a reference + * to itself. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_maskCamera + * @type {?Phaser.Cameras.Scene2D.BaseCamera} + * @private + * @since 3.17.0 + */ + this._maskCamera = null; + + /** + * This array is populated with all of the Game Objects that this Camera has rendered + * in the previous (or current, depending on when you inspect it) frame. + * + * It is cleared at the start of `Camera.preUpdate`, or if the Camera is destroyed. + * + * You should not modify this array as it is used internally by the input system, + * however you can read it as required. Note that Game Objects may appear in this + * list multiple times if they belong to multiple non-exclusive Containers. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#renderList + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.52.0 + */ + this.renderList = []; + + /** + * Is this Camera a Scene Camera? (which is the default), or a Camera + * belonging to a Texture? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#isSceneCamera + * @type {boolean} + * @default true + * @since 3.60.0 + */ + this.isSceneCamera = true; + + /** + * Whether to force the camera to render via a framebuffer. + * This only applies when using the WebGL renderer. + * This makes the camera contents available to other WebGL processes, + * such as `CaptureFrame`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#forceComposite + * @type {boolean} + * @default false + * @since 4.0.0 + * @webglOnly + */ + this.forceComposite = false; + + /** + * Can this Camera render rounded pixel values? + * + * This property is updated during the `preRender` method and should not be + * set directly. It is set based on the `roundPixels` property of the Camera + * combined with the zoom level. If the zoom is an integer then the WebGL + * Renderer can apply rounding during rendering. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels + * @type {boolean} + * @readonly + * @default true + * @since 3.86.0 + */ + this.renderRoundPixels = true; + }, + + /** + * Adds the given Game Object to this camera's render list. + * + * This is invoked during the rendering stage. Only objects that are actually rendered + * will appear in the render list. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#addToRenderList + * @since 3.52.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to add to the render list. + */ + addToRenderList: function (child) + { + this.renderList.push(child); + }, + + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAlpha + * @since 3.11.0 + * + * @param {number} [value=1] - The Camera alpha value. + * + * @return {this} This Camera instance. + */ + + /** + * Sets the rotation origin of this Camera. + * + * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setOrigin + * @since 3.11.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Camera instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this; + }, + + /** + * Calculates what the Camera.scrollX and scrollY values would need to be in order to move + * the Camera so it is centered on the given x and y coordinates, without actually moving + * the Camera there. The results are clamped based on the Camera bounds, if set. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getScroll + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {Phaser.Math.Vector2} [out] - A Vector2 to store the values in. If not given a new Vector2 is created. + * + * @return {Phaser.Math.Vector2} The scroll coordinates stored in the `x` and `y` properties. + */ + getScroll: function (x, y, out) + { + if (out === undefined) { out = new Vector2(); } + + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + out.x = x - originX; + out.y = y - originY; + + if (this.useBounds) + { + out.x = this.clampX(out.x); + out.y = this.clampY(out.y); + } + + return out; + }, + + /** + * Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. + * Calling this does not change the scrollY value. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOnX + * @since 3.16.0 + * + * @param {number} x - The horizontal coordinate to center on. + * + * @return {this} This Camera instance. + */ + centerOnX: function (x) + { + var originX = this.width * 0.5; + + this.midPoint.x = x; + + this.scrollX = x - originX; + + if (this.useBounds) + { + this.scrollX = this.clampX(this.scrollX); + } + + return this; + }, + + /** + * Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. + * Calling this does not change the scrollX value. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOnY + * @since 3.16.0 + * + * @param {number} y - The vertical coordinate to center on. + * + * @return {this} This Camera instance. + */ + centerOnY: function (y) + { + var originY = this.height * 0.5; + + this.midPoint.y = y; + + this.scrollY = y - originY; + + if (this.useBounds) + { + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Moves the Camera so that it is centered on the given coordinates, bounds allowing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOn + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * + * @return {this} This Camera instance. + */ + centerOn: function (x, y) + { + this.centerOnX(x); + this.centerOnY(y); + + return this; + }, + + /** + * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToBounds + * @since 3.0.0 + * + * @return {this} This Camera instance. + */ + centerToBounds: function () + { + if (this.useBounds) + { + var bounds = this._bounds; + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(bounds.centerX, bounds.centerY); + + this.scrollX = bounds.centerX - originX; + this.scrollY = bounds.centerY - originY; + } + + return this; + }, + + /** + * Moves the Camera so that it is re-centered based on its viewport size. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToSize + * @since 3.0.0 + * + * @return {this} This Camera instance. + */ + centerToSize: function () + { + this.scrollX = this.width * 0.5; + this.scrollY = this.height * 0.5; + + return this; + }, + + /** + * Takes an array of Game Objects and returns a new array featuring only those objects + * visible by this camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#cull + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] + * + * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. + * + * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. + */ + cull: function (renderableObjects) + { + if (this.disableCull) + { + return renderableObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return renderableObjects; + } + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var cullTop = this.y; + var cullBottom = cullTop + cameraH; + var cullLeft = this.x; + var cullRight = cullLeft + cameraW; + var culledObjects = this.culledObjects; + var length = renderableObjects.length; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var object = renderableObjects[index]; + + if (!object.hasOwnProperty('width') || object.parentContainer) + { + culledObjects.push(object); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc); + var ty = (objectX * mvb + objectY * mvd); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd); + + if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom)) + { + culledObjects.push(object); + } + } + + return culledObjects; + }, + + /** + * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. + * You can optionally provide a Vector2, or similar object, to store the results in. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getWorldPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} x - The x position to convert to world space. + * @param {number} y - The y position to convert to world space. + * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. + */ + getWorldPoint: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var cameraMatrix = this.matrixCombined.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + // Invert Matrix + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + output.x = x; + output.y = y; + + return output; + } + + determinant = 1 / determinant; + + var ima = mvd * determinant; + var imb = -mvb * determinant; + var imc = -mvc * determinant; + var imd = mva * determinant; + var ime = (mvc * mvf - mvd * mve) * determinant; + var imf = (mvb * mve - mva * mvf) * determinant; + + // Apply transform to point + output.x = (x * ima + y * imc) + ime; + output.y = (x * imb + y * imd) + imf; + + return output; + }, + + /** + * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings + * so that they are ignored by this Camera. This means they will not be rendered by this Camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#ignore + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group)} entries - The Game Object, or array of Game Objects, to be ignored by this Camera. + * + * @return {this} This Camera instance. + */ + ignore: function (entries) + { + var id = this.id; + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + for (var i = 0; i < entries.length; i++) + { + var entry = entries[i]; + + if (Array.isArray(entry)) + { + this.ignore(entry); + } + else if (entry.isParent) + { + this.ignore(entry.getChildren()); + } + else + { + entry.cameraFilter |= id; + } + } + + return this; + }, + + /** + * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampX + * @since 3.11.0 + * + * @param {number} x - The value to horizontally scroll clamp. + * + * @return {number} The adjusted value to use as scrollX. + */ + clampX: function (x) + { + var bounds = this._bounds; + + var dw = this.displayWidth; + + var bx = bounds.x + ((dw - this.width) / 2); + var bw = Math.max(bx, bx + bounds.width - dw); + + if (x < bx) + { + x = bx; + } + else if (x > bw) + { + x = bw; + } + + return x; + }, + + /** + * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampY + * @since 3.11.0 + * + * @param {number} y - The value to vertically scroll clamp. + * + * @return {number} The adjusted value to use as scrollY. + */ + clampY: function (y) + { + var bounds = this._bounds; + + var dh = this.displayHeight; + + var by = bounds.y + ((dh - this.height) / 2); + var bh = Math.max(by, by + bounds.height - dh); + + if (y < by) + { + y = by; + } + else if (y > bh) + { + y = bh; + } + + return y; + }, + + /* + var gap = this._zoomInversed; + return gap * Math.round((src.x - this.scrollX * src.scrollFactorX) / gap); + */ + + /** + * If this Camera has previously had movement bounds set on it, this will remove them. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#removeBounds + * @since 3.0.0 + * + * @return {this} This Camera instance. + */ + removeBounds: function () + { + this.useBounds = false; + + this.dirty = true; + + this._bounds.setEmpty(); + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAngle + * @since 3.0.0 + * + * @param {number} [value=0] - The camera's angle of rotation, given in degrees. + * + * @return {this} This Camera instance. + */ + setAngle: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = DegToRad(value); + + return this; + }, + + /** + * Sets the background color for this Camera. + * + * By default a Camera has a transparent background but it can be given a solid color, with any level + * of transparency, via this method. + * + * The color value can be specified using CSS color notation, hex or numbers. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBackgroundColor + * @since 3.0.0 + * + * @param {(string|number|Phaser.Types.Display.InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. + * + * @return {this} This Camera instance. + */ + setBackgroundColor: function (color) + { + if (color === undefined) { color = 'rgba(0,0,0,0)'; } + + this.backgroundColor = ValueToColor(color); + + this.transparent = (this.backgroundColor.alpha === 0); + + return this; + }, + + /** + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBounds + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the bounds. + * @param {number} y - The top-left y coordinate of the bounds. + * @param {number} width - The width of the bounds, in pixels. + * @param {number} height - The height of the bounds, in pixels. + * @param {boolean} [centerOn=false] - If `true` the Camera will automatically be centered on the new bounds. + * + * @return {this} This Camera instance. + */ + setBounds: function (x, y, width, height, centerOn) + { + if (centerOn === undefined) { centerOn = false; } + + this._bounds.setTo(x, y, width, height); + + this.dirty = true; + this.useBounds = true; + + if (centerOn) + { + this.centerToBounds(); + } + else + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Sets the `forceComposite` property of this Camera. + * This property is only used by the WebGL Renderer. + * If `true` the camera will render via a framebuffer, + * making it available to other WebGL systems. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setForceComposite + * @since 4.0.0 + * @webglOnly + * + * @param {boolean} value - The value to set the property to. + * + * @return {this} This Camera instance. + */ + setForceComposite: function (value) + { + this.forceComposite = value; + + return this; + }, + + /** + * Returns a rectangle containing the bounds of the Camera. + * + * If the Camera does not have any bounds the rectangle will be empty. + * + * The rectangle is a copy of the bounds, so is safe to modify. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getBounds + * @since 3.16.0 + * + * @param {Phaser.Geom.Rectangle} [out] - An optional Rectangle to store the bounds in. If not given, a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A rectangle containing the bounds of this Camera. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + var source = this._bounds; + + out.setTo(source.x, source.y, source.width, source.height); + + return out; + }, + + /** + * Sets the name of this Camera. + * This value is for your own use and isn't used internally. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setName + * @since 3.0.0 + * + * @param {string} [value=''] - The name of the Camera. + * + * @return {this} This Camera instance. + */ + setName: function (value) + { + if (value === undefined) { value = ''; } + + this.name = value; + + return this; + }, + + /** + * Set the position of the Camera viewport within the game. + * + * This does not change where the camera is 'looking'. See `setScroll` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setPosition + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. + * + * @return {this} This Camera instance. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRotation + * @since 3.0.0 + * + * @param {number} [value=0] - The rotation of the Camera, in radians. + * + * @return {this} This Camera instance. + */ + setRotation: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = value; + + return this; + }, + + /** + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels + * @since 3.0.0 + * + * @param {boolean} value - `true` to round Camera pixels, `false` to not. + * + * @return {this} This Camera instance. + */ + setRoundPixels: function (value) + { + this.roundPixels = value; + + return this; + }, + + /** + * Sets the Scene the Camera is bound to. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene the camera is bound to. + * @param {boolean} [isSceneCamera=true] - Is this Camera being used for a Scene (true) or a Texture? (false) + * + * @return {this} This Camera instance. + */ + setScene: function (scene, isSceneCamera) + { + if (isSceneCamera === undefined) { isSceneCamera = true; } + + if (this.scene && this._customViewport) + { + this.sceneManager.customViewports--; + } + + this.scene = scene; + this.isSceneCamera = isSceneCamera; + + var sys = scene.sys; + + this.sceneManager = sys.game.scene; + this.scaleManager = sys.scale; + this.cameraManager = sys.cameras; + + this.updateSystem(); + + return this; + }, + + /** + * Set the position of where the Camera is looking within the game. + * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. + * Use this method, or the scroll properties, to move your camera around the game world. + * + * This does not change where the camera viewport is placed. See `setPosition` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScroll + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the Camera in the game world. + * @param {number} [y=x] - The y coordinate of the Camera in the game world. + * + * @return {this} This Camera instance. + */ + setScroll: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollX = x; + this.scrollY = y; + + return this; + }, + + /** + * Set the size of the Camera viewport. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the Camera viewport. + * @param {number} [height=width] - The height of the Camera viewport. + * + * @return {this} This Camera instance. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * This method sets the position and size of the Camera viewport in a single call. + * + * If you're trying to change where the Camera is looking at in your game, then see + * the method `Camera.setScroll` instead. This method is for changing the viewport + * itself, not what the camera can see. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * Note that this is a limited method, and comes with several caveats: + * + * - The viewport is an axis-aligned rectangle, and cannot be rotated. + * - Filters and masks may appear in the wrong place if the viewport changes. + * + * It is more powerful and reliable to use a + * `RenderTexture` or `DynamicTexture` instead. + * Point its camera where you want the viewport, + * set its size, and then draw your game objects to it. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setViewport + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} y - The top-left y coordinate of the Camera viewport. + * @param {number} width - The width of the Camera viewport. + * @param {number} [height=width] - The height of the Camera viewport. + * + * @return {this} This Camera instance. + */ + setViewport: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Set the zoom value of the Camera. + * + * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. + * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. + * + * A value of 1 means 'no zoom' and is the default. + * + * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. + * + * As of Phaser 3.50 you can now set the horizontal and vertical zoom values independently. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setZoom + * @since 3.0.0 + * + * @param {number} [x=1] - The horizontal zoom value of the Camera. The minimum it can be is 0.001. + * @param {number} [y=x] - The vertical zoom value of the Camera. The minimum it can be is 0.001. + * + * @return {this} This Camera instance. + */ + setZoom: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + if (x === 0) + { + x = 0.001; + } + + if (y === 0) + { + y = 0.001; + } + + this.zoomX = x; + this.zoomY = y; + + return this; + }, + + /** + * Sets the mask to be applied to this Camera during rendering. + * + * The mask must have been previously created and must be a GeometryMask. + * This only works in the Canvas Renderer. + * In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}). + * + * If a mask is already set on this Camera it will be immediately replaced. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setMask + * @since 3.17.0 + * + * @param {Phaser.Display.Masks.GeometryMask} mask - The mask this Camera will use when rendering. + * @param {boolean} [fixedPosition=true] - Should the mask translate along with the Camera, or be fixed in place and not impacted by the Cameras transform? + * + * @return {this} This Camera instance. + */ + setMask: function (mask, fixedPosition) + { + if (fixedPosition === undefined) { fixedPosition = true; } + + this.mask = mask; + + this._maskCamera = (fixedPosition) ? this.cameraManager.default : this; + + return this; + }, + + /** + * Clears the mask that this Camera was using. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clearMask + * @since 3.17.0 + * + * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? + * + * @return {this} This Camera instance. + */ + clearMask: function (destroyMask) + { + if (destroyMask === undefined) { destroyMask = false; } + + if (destroyMask && this.mask) + { + this.mask.destroy(); + } + + this.mask = null; + + return this; + }, + + /** + * Sets the visibility of this Camera. + * + * An invisible Camera will skip rendering and input tests of everything it can see. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setVisible + * @since 3.10.0 + * + * @param {boolean} value - The visible state of the Camera. + * + * @return {this} This Camera instance. + */ + + /** + * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Cameras.Scene2D.JSONCamera} A well-formed object suitable for conversion to JSON. + */ + toJSON: function () + { + var output = { + name: this.name, + x: this.x, + y: this.y, + width: this.width, + height: this.height, + zoom: this.zoom, + rotation: this.rotation, + roundPixels: this.roundPixels, + scrollX: this.scrollX, + scrollY: this.scrollY, + backgroundColor: this.backgroundColor.rgba + }; + + if (this.useBounds) + { + output['bounds'] = { + x: this._bounds.x, + y: this._bounds.y, + width: this._bounds.width, + height: this._bounds.height + }; + } + + return output; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function () + { + // NOOP + }, + + /** + * Sets whether this Camera is being used as a Scene Camera (the default), + * or a Texture Camera used to render to a texture. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setIsSceneCamera + * @since 3.60.0 + * + * @param {boolean} value - Is this being used as a Scene Camera, or a Texture camera? + */ + setIsSceneCamera: function (value) + { + this.isSceneCamera = value; + + return this; + }, + + /** + * Internal method called automatically when the viewport changes. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#updateSystem + * @private + * @since 3.12.0 + */ + updateSystem: function () + { + if (!this.scaleManager || !this.isSceneCamera) + { + return; + } + + var custom = (this._x !== 0 || this._y !== 0 || this.scaleManager.width !== this._width || this.scaleManager.height !== this._height); + + var sceneManager = this.sceneManager; + + if (custom && !this._customViewport) + { + // We need a custom viewport for this Camera + sceneManager.customViewports++; + } + else if (!custom && this._customViewport) + { + // We're turning off a custom viewport for this Camera + sceneManager.customViewports--; + } + + this.dirty = true; + this._customViewport = custom; + }, + + /** + * Destroys this Camera instance and its internal properties and references. + * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. + * + * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. + * + * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, + * rather than calling this method directly. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#destroy + * @fires Phaser.Cameras.Scene2D.Events#DESTROY + * @since 3.0.0 + */ + destroy: function () + { + this.emit(Events.DESTROY, this); + + this.removeAllListeners(); + + this.matrix.destroy(); + this.matrixCombined.destroy(); + this.matrixExternal.destroy(); + + this.culledObjects = []; + + if (this._customViewport) + { + // We're turning off a custom viewport for this Camera + this.sceneManager.customViewports--; + } + + this.renderList = []; + + this._bounds = null; + + this.scene = null; + this.scaleManager = null; + this.sceneManager = null; + this.cameraManager = null; + }, + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this._x; + }, + + set: function (value) + { + this._x = value; + this.updateSystem(); + } + + }, + + /** + * The y position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this._y; + }, + + set: function (value) + { + this._y = value; + this.updateSystem(); + } + + }, + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + return this._width; + }, + + set: function (value) + { + this._width = value; + this.updateSystem(); + } + + }, + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + return this._height; + }, + + set: function (value) + { + this._height = value; + this.updateSystem(); + } + + }, + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollX: { + + get: function () + { + return this._scrollX; + }, + + set: function (value) + { + if (value !== this._scrollX) + { + this._scrollX = value; + this.dirty = true; + } + } + + }, + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollY: { + + get: function () + { + return this._scrollY; + }, + + set: function (value) + { + if (value !== this._scrollY) + { + this._scrollY = value; + this.dirty = true; + } + } + + }, + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#zoom + * @type {number} + * @default 1 + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return (this._zoomX + this._zoomY) / 2; + }, + + set: function (value) + { + this._zoomX = value; + this._zoomY = value; + + this.dirty = true; + } + + }, + + /** + * The Camera horizontal zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#zoomX + * @type {number} + * @default 1 + * @since 3.50.0 + */ + zoomX: { + + get: function () + { + return this._zoomX; + }, + + set: function (value) + { + this._zoomX = value; + this.dirty = true; + } + + }, + + /** + * The Camera vertical zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#zoomY + * @type {number} + * @default 1 + * @since 3.50.0 + */ + zoomY: { + + get: function () + { + return this._zoomY; + }, + + set: function (value) + { + this._zoomY = value; + this.dirty = true; + } + + }, + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + this.dirty = true; + } + + }, + + /** + * The horizontal position of the center of the Camera's viewport, relative to the left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerX + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerX: { + + get: function () + { + return this.x + (0.5 * this.width); + } + + }, + + /** + * The vertical position of the center of the Camera's viewport, relative to the top of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerY + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerY: { + + get: function () + { + return this.y + (0.5 * this.height); + } + + }, + + /** + * The displayed width of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width + * would be 1600, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a width of 800 and zoom of 2 would have a display width + * of 400 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayWidth + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayWidth: { + + get: function () + { + return this.width / this.zoomX; + } + + }, + + /** + * The displayed height of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height + * would be 1200, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a height of 600 and zoom of 2 would have a display height + * of 300 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayHeight: { + + get: function () + { + return this.height / this.zoomY; + } + + } + +}); + +module.exports = BaseCamera; + + +/***/ }, + +/***/ 38058 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BaseCamera = __webpack_require__(71911); +var CenterOn = __webpack_require__(67502); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Effects = __webpack_require__(20052); +var Events = __webpack_require__(19715); +var Linear = __webpack_require__(28915); +var Rectangle = __webpack_require__(87841); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Camera provides a view into your game world and is the primary way scenes are rendered in Phaser. + * Every Scene has at least one Camera (the main camera), and you can add additional cameras via the + * Camera Manager. Cameras can be scrolled, zoomed, rotated, and fitted with special effects such as + * fade, flash, shake, pan, and zoom transitions. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * However, the viewport is limited to being an axis-aligned rectangle, and cannot be rotated. + * It is more powerful and reliable to use a + * `RenderTexture` or `DynamicTexture` instead. + * Point its camera where you want the viewport, + * set its size, and then draw your game objects to it. + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * A Camera also has built-in special effects including Fade, Flash and Camera Shake. + * + * You can apply full-camera filters. + * Some filters need off-screen data, such as Blur; + * use `camera.getPaddingWrapper()` to get a proxy for working with + * cameras with padding applied. + * + * @class Camera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Cameras.Scene2D.BaseCamera + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var Camera = new Class({ + + Extends: BaseCamera, + + initialize: + + function Camera (x, y, width, height) + { + BaseCamera.call(this, x, y, width, height); + + /** + * The filters for this camera. + * Filters control special effects and masks. + * + * This object contains two lists of filters: `internal` and `external`. + * See {@link Phaser.GameObjects.Components.FilterList} for more information. + * + * @name Phaser.Cameras.Scene2D.Camera#filters + * @type {Phaser.Types.GameObjects.FiltersInternalExternal} + * @since 4.0.0 + */ + this.filters = { + internal: new Components.FilterList(this), + external: new Components.FilterList(this) + }; + + /** + * Is this Camera for Game Object transform inversion? + * This is used by the `Filters` component to cancel out the transform + * of the Game Object when rendering the object for filtering. + * + * @name Phaser.Cameras.Scene2D.Camera#isObjectInversion + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.isObjectInversion = false; + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + * + * @name Phaser.Cameras.Scene2D.Camera#inputEnabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.inputEnabled = true; + + /** + * The Camera Fade effect handler. + * To fade this camera see the `Camera.fade` methods. + * + * @name Phaser.Cameras.Scene2D.Camera#fadeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Fade} + * @since 3.5.0 + */ + this.fadeEffect = new Effects.Fade(this); + + /** + * The Camera Flash effect handler. + * To flash this camera see the `Camera.flash` method. + * + * @name Phaser.Cameras.Scene2D.Camera#flashEffect + * @type {Phaser.Cameras.Scene2D.Effects.Flash} + * @since 3.5.0 + */ + this.flashEffect = new Effects.Flash(this); + + /** + * The Camera Shake effect handler. + * To shake this camera see the `Camera.shake` method. + * + * @name Phaser.Cameras.Scene2D.Camera#shakeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Shake} + * @since 3.5.0 + */ + this.shakeEffect = new Effects.Shake(this); + + /** + * The Camera Pan effect handler. + * To pan this camera see the `Camera.pan` method. + * + * @name Phaser.Cameras.Scene2D.Camera#panEffect + * @type {Phaser.Cameras.Scene2D.Effects.Pan} + * @since 3.11.0 + */ + this.panEffect = new Effects.Pan(this); + + /** + * The Camera Rotate To effect handler. + * To rotate this camera see the `Camera.rotateTo` method. + * + * @name Phaser.Cameras.Scene2D.Camera#rotateToEffect + * @type {Phaser.Cameras.Scene2D.Effects.RotateTo} + * @since 3.23.0 + */ + this.rotateToEffect = new Effects.RotateTo(this); + + /** + * The Camera Zoom effect handler. + * To zoom this camera see the `Camera.zoomTo` method. + * + * @name Phaser.Cameras.Scene2D.Camera#zoomEffect + * @type {Phaser.Cameras.Scene2D.Effects.Zoom} + * @since 3.11.0 + */ + this.zoomEffect = new Effects.Zoom(this); + + /** + * The linear interpolation value to use when following a target. + * + * Can also be set via `setLerp` or as part of the `startFollow` call. + * + * The default value of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @name Phaser.Cameras.Scene2D.Camera#lerp + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.lerp = new Vector2(1, 1); + + /** + * The values stored in this property are subtracted from the Camera targets position, allowing you to + * offset the camera from the actual target x/y coordinates by this amount. + * Can also be set via `setFollowOffset` or as part of the `startFollow` call. + * + * @name Phaser.Cameras.Scene2D.Camera#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.followOffset = new Vector2(); + + /** + * The Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * You can directly set this property to be an instance of a Rectangle. Or, you can use the + * `setDeadzone` method for a chainable approach. + * + * The rectangle you provide can have its dimensions adjusted dynamically, however, please + * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. + * + * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property + * to `null`. + * + * @name Phaser.Cameras.Scene2D.Camera#deadzone + * @type {?Phaser.Geom.Rectangle} + * @since 3.11.0 + */ + this.deadzone = null; + + /** + * Internal follow target reference. + * + * @name Phaser.Cameras.Scene2D.Camera#_follow + * @type {?any} + * @private + * @default null + * @since 3.0.0 + */ + this._follow = null; + }, + + /** + * Sets the Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point + * of the camera. This allows you to use the object for additional game related checks, such as + * testing if an object is within it or not via a Rectangle.contains call. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * Calling this method with no arguments will reset an active deadzone. + * + * @method Phaser.Cameras.Scene2D.Camera#setDeadzone + * @since 3.11.0 + * + * @param {number} [width] - The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. + * @param {number} [height] - The height of the deadzone rectangle in pixels. + * + * @return {this} This Camera instance. + */ + setDeadzone: function (width, height) + { + if (width === undefined) + { + this.deadzone = null; + } + else + { + if (this.deadzone) + { + this.deadzone.width = width; + this.deadzone.height = height; + } + else + { + this.deadzone = new Rectangle(0, 0, width, height); + } + + if (this._follow) + { + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = this._follow.x - this.followOffset.x; + var fy = this._follow.y - this.followOffset.y; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + } + + CenterOn(this.deadzone, this.midPoint.x, this.midPoint.y); + } + + return this; + }, + + /** + * Fades the Camera in from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeIn + * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_START + * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE + * @since 3.3.0 + * + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. + * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. + * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. + * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + fadeIn: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeOut + * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_START + * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE + * @since 3.3.0 + * + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. + * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. + * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. + * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + fadeOut: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera from the given color to transparent over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeFrom + * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_START + * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE + * @since 3.5.0 + * + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. + * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. + * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. + * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. + * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + fadeFrom: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); + }, + + /** + * Fades the Camera from transparent to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fade + * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_START + * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE + * @since 3.0.0 + * + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. + * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. + * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. + * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. + * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + fade: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); + }, + + /** + * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#flash + * @fires Phaser.Cameras.Scene2D.Events#FLASH_START + * @fires Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE + * @since 3.0.0 + * + * @param {number} [duration=250] - The duration of the effect in milliseconds. + * @param {number} [red=255] - The amount to fade the red channel towards. A value between 0 and 255. + * @param {number} [green=255] - The amount to fade the green channel towards. A value between 0 and 255. + * @param {number} [blue=255] - The amount to fade the blue channel towards. A value between 0 and 255. + * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. + * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + flash: function (duration, red, green, blue, force, callback, context) + { + return this.flashEffect.start(duration, red, green, blue, force, callback, context); + }, + + /** + * Shakes the Camera by the given intensity over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#shake + * @fires Phaser.Cameras.Scene2D.Events#SHAKE_START + * @fires Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE + * @since 3.0.0 + * + * @param {number} [duration=100] - The duration of the effect in milliseconds. + * @param {(number|Phaser.Math.Vector2)} [intensity=0.05] - The intensity of the shake. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + shake: function (duration, intensity, force, callback, context) + { + return this.shakeEffect.start(duration, intensity, force, callback, context); + }, + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#pan + * @fires Phaser.Cameras.Scene2D.Events#PAN_START + * @fires Phaser.Cameras.Scene2D.Events#PAN_COMPLETE + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the pan effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + pan: function (x, y, duration, ease, force, callback, context) + { + return this.panEffect.start(x, y, duration, ease, force, callback, context); + }, + + /** + * Rotate the Camera to the given angle over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#rotateTo + * @since 3.23.0 + * + * @param {number} angle - The destination angle in radians to rotate the Camera view to. + * @param {boolean} [shortestPath=false] - If true, take the shortest distance to the destination. This adjusts the destination angle to be within one half turn of the start angle. + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the rotation effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraRotateCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera rotation. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + rotateTo: function (angle, shortestPath, duration, ease, force, callback, context) + { + return this.rotateToEffect.start(angle, shortestPath, duration, ease, force, callback, context); + }, + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#zoomTo + * @fires Phaser.Cameras.Scene2D.Events#ZOOM_START + * @fires Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the zoom. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the zoom effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraZoomCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera zoom value. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {this} This Camera instance. + */ + zoomTo: function (zoom, duration, ease, force, callback, context) + { + return this.zoomEffect.start(zoom, duration, ease, force, callback, context); + }, + + /** + * Updates camera matrix. Also resets any active effects on this Camera (such as shake, flash and fade) and quickly clears them all. + * + * @method Phaser.Cameras.Scene2D.Camera#preRender + * @since 3.0.0 + */ + preRender: function () + { + this.renderList.length = 0; + + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoomX = this.zoomX; + var zoomY = this.zoomY; + + this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY)); + + var originX = width * this.originX; + var originY = height * this.originY; + + var follow = this._follow; + var deadzone = this.deadzone; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (deadzone) + { + CenterOn(deadzone, this.midPoint.x, this.midPoint.y); + } + + var emitFollowEvent = false; + + if (follow && !this.panEffect.isRunning) + { + var lerp = this.lerp; + + var fx = follow.x - this.followOffset.x; + var fy = follow.y - this.followOffset.y; + + if (deadzone) + { + if (fx < deadzone.x) + { + sx = Linear(sx, sx - (deadzone.x - fx), lerp.x); + } + else if (fx > deadzone.right) + { + sx = Linear(sx, sx + (fx - deadzone.right), lerp.x); + } + + if (fy < deadzone.y) + { + sy = Linear(sy, sy - (deadzone.y - fy), lerp.y); + } + else if (fy > deadzone.bottom) + { + sy = Linear(sy, sy + (fy - deadzone.bottom), lerp.y); + } + } + else + { + sx = Linear(sx, fx - originX, lerp.x); + sy = Linear(sy, fy - originY, lerp.y); + } + + emitFollowEvent = true; + } + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoomX; + var displayHeight = height / zoomY; + + var vwx = midX - (displayWidth / 2); + var vwy = midY - (displayHeight / 2); + + this.worldView.setTo(vwx, vwy, displayWidth, displayHeight); + + var matrix = this.matrix; + var matrixExternal = this.matrixExternal; + + if (this.isObjectInversion) + { + // Game Object filter camera + matrix.loadIdentity(); + matrix.translate(originX, originY); + matrix.scale(zoomX, zoomY); + matrix.rotate(this.rotation); + matrix.translate(-sx - originX, -sy - originY); + } + else + { + // Regular camera + // Apply view transforms in order ITRS. + matrix.applyITRS(originX, originY, this.rotation, zoomX, zoomY); + matrix.translate(-sx - originX, -sy - originY); + } + + + matrixExternal.applyITRS(this.x, this.y, 0, 1, 1); + + this.shakeEffect.preRender(); + + matrixExternal.multiply(matrix, this.matrixCombined); + + if (emitFollowEvent) + { + this.emit(Events.FOLLOW_UPDATE, this, follow); + } + }, + + /** + * Returns the view matrix of the camera. This is used internally. + * + * This is `matrix` if the camera is intended to render to a framebuffer, + * and `matrixCombined` otherwise. + * + * @method Phaser.Cameras.Scene2D.Camera#getViewMatrix + * @webglonly + * @since 4.0.0 + * @param {boolean} [forceComposite=false] - If `true`, the view matrix will always be `matrix`. This is typically used when rendering to a framebuffer, so the external matrix is irrelevant. + * @return {Phaser.GameObjects.Components.TransformMatrix} The view matrix of the camera. + */ + getViewMatrix: function (forceComposite) + { + if ( + forceComposite || this.forceComposite || + this.filters.external.length > 0 || + this.filters.internal.length > 0 + ) + { + return this.matrix; + } + else + { + return this.matrixCombined; + } + }, + + /** + * Return a proxy for managing camera padding. + * + * Camera padding enlarges the camera, adding to each side of the region. + * This is useful when you need data from just outside the normal + * camera region, e.g. when using a Blur filter. + * + * Use the proxy in place of the camera. + * It conceals the complicated parts, so you can carry on using the camera + * just as before. + * You can still use the original camera to see the adjusted values. + * + * Padding affects the following properties on the original camera: + * + * - Subtracts from `x`, `y`, `scrollX`, `scrollY`. + * - Adds double to `width`, height`. + * + * Padding increases the rendered region, so it can have a performance cost. + * If you don't need the extra data at some time, set padding to 0. + * + * You can't use more than one such proxy at a time. If you try, + * they fight and nobody wins. + * + * @example + * // Create a padding proxy with 16 pixels of padding. + * var proxy = this.cameras.main.getPaddingWrapper(16); + * console.log(proxy.scrollX, this.cameras.main.scrollX); // 0, -16 + * + * // Adjust proxy scroll. + * proxy.scrollX += 4; + * console.log(proxy.scrollX, this.cameras.main.scrollX); // 4, -12 + * + * @method Phaser.Cameras.Scene2D.Camera#getPaddingWrapper + * @since 4.0.0 + * @param {number} [padding=0] - Initial padding value. + * @return {Phaser.Types.Cameras.Scene2D.CameraPaddingWrapper} The proxy for the camera. + */ + getPaddingWrapper: function (padding) + { + var data = { padding: 0 }; + + var handler = { + get: function (target, prop) + { + switch (prop) + { + case 'padding': return data.padding; + case 'x': + case 'y': + case 'scrollX': + case 'scrollY': return target[prop] + data.padding; + case 'width': + case 'height': return target[prop] - data.padding * 2; + default: return target[prop]; + } + }, + set: function (target, prop, value) + { + switch (prop) + { + case 'padding': { + var currentPadding = data.padding; + data.padding = value; + var d = data.padding - currentPadding; + target.x -= d; + target.y -= d; + target.width += d * 2; + target.height += d * 2; + target.scrollX -= d; + target.scrollY -= d; + return padding; + } + case 'x': + case 'y': + case 'scrollX': + case 'scrollY': return target[prop] = value - data.padding; + case 'width': + case 'height': return target[prop] = value + data.padding * 2; + default: return target[prop] = value; + } + } + }; + + var proxy = new Proxy(this, handler); + + proxy.padding = padding || 0; + + return proxy; + }, + + /** + * Sets the linear interpolation value to use when following a target. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @method Phaser.Cameras.Scene2D.Camera#setLerp + * @since 3.9.0 + * + * @param {number} [x=1] - The horizontal linear interpolation value for the follow target. A value between 0 and 1. + * @param {number} [y=1] - The vertical linear interpolation value for the follow target. A value between 0 and 1. + * + * @return {this} This Camera instance. + */ + setLerp: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.lerp.set(x, y); + + return this; + }, + + /** + * Sets the horizontal and vertical offset of the camera from its follow target. + * The values are subtracted from the targets position during the Cameras update step. + * + * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset + * @since 3.9.0 + * + * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [y=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + setFollowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.followOffset.set(x, y); + + return this; + }, + + /** + * Sets the Camera to follow a Game Object. + * + * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object + * in its center. + * + * You can set the linear interpolation value used in the follow code. + * Use low lerp values (such as 0.1) to automatically smooth the camera motion. + * + * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel + * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to + * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom + * value on the camera. So be sure to keep the camera zoom to integers. + * + * @method Phaser.Cameras.Scene2D.Camera#startFollow + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. + * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? + * @param {number} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) + { + if (roundPixels === undefined) { roundPixels = false; } + if (lerpX === undefined) { lerpX = 1; } + if (lerpY === undefined) { lerpY = lerpX; } + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = offsetX; } + + this._follow = target; + + this.roundPixels = roundPixels; + + lerpX = Clamp(lerpX, 0, 1); + lerpY = Clamp(lerpY, 0, 1); + + this.lerp.set(lerpX, lerpY); + + this.followOffset.set(offsetX, offsetY); + + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = target.x - offsetX; + var fy = target.y - offsetY; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + + if (this.useBounds) + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. + * + * @method Phaser.Cameras.Scene2D.Camera#stopFollow + * @since 3.0.0 + * + * @return {this} This Camera instance. + */ + stopFollow: function () + { + this._follow = null; + + return this; + }, + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + * + * @method Phaser.Cameras.Scene2D.Camera#resetFX + * @since 3.0.0 + * + * @return {this} This Camera instance. + */ + resetFX: function () + { + this.rotateToEffect.reset(); + this.panEffect.reset(); + this.shakeEffect.reset(); + this.flashEffect.reset(); + this.fadeEffect.reset(); + + return this; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.Camera#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (this.visible) + { + this.rotateToEffect.update(time, delta); + this.panEffect.update(time, delta); + this.zoomEffect.update(time, delta); + this.shakeEffect.update(time, delta); + this.flashEffect.update(time, delta); + this.fadeEffect.update(time, delta); + } + }, + + /** + * Destroys this Camera instance. You rarely need to call this directly. + * + * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as + * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. + * + * @method Phaser.Cameras.Scene2D.Camera#destroy + * @fires Phaser.Cameras.Scene2D.Events#DESTROY + * @since 3.0.0 + */ + destroy: function () + { + this.resetFX(); + + this.filters.internal.destroy(); + this.filters.external.destroy(); + + BaseCamera.prototype.destroy.call(this); + + this._follow = null; + + this.deadzone = null; + } + +}); + +module.exports = Camera; + + +/***/ }, + +/***/ 32743 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Camera = __webpack_require__(38058); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var PluginCache = __webpack_require__(37277); +var RectangleContains = __webpack_require__(37303); +var ScaleEvents = __webpack_require__(97480); +var SceneEvents = __webpack_require__(44594); + +/** + * @classdesc + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. + * + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. + * + * @class CameraManager + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. + */ +var CameraManager = new Class({ + + initialize: + + function CameraManager (scene) + { + /** + * The Scene that owns the Camera Manager plugin. + * + * @name Phaser.Cameras.Scene2D.CameraManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. + * + * @name Phaser.Cameras.Scene2D.CameraManager#roundPixels + * @type {boolean} + * @since 3.11.0 + */ + this.roundPixels = scene.sys.game.config.roundPixels; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameras + * @type {Phaser.Cameras.Scene2D.Camera[]} + * @since 3.0.0 + */ + this.cameras = []; + + /** + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. + * + * @name Phaser.Cameras.Scene2D.CameraManager#main + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + this.main; + + /** + * A default un-transformed Camera that doesn't exist on the camera list and doesn't + * count towards the total number of cameras being managed. It exists for other + * systems, as well as your own code, should they require a basic un-transformed + * camera instance from which to calculate a view matrix. + * + * @name Phaser.Cameras.Scene2D.CameraManager#default + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.17.0 + */ + this.default; + + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Cameras.Scene2D.CameraManager#boot + * @private + * @listens Phaser.Scenes.Events#DESTROY + * @since 3.5.1 + */ + boot: function () + { + var sys = this.systems; + + if (sys.settings.cameras) + { + // We have cameras to create + this.fromJSON(sys.settings.cameras); + } + else + { + // Make one + this.add(); + } + + this.main = this.cameras[0]; + + // Create a default camera + this.default = new Camera(0, 0, sys.scale.width, sys.scale.height).setScene(this.scene); + + sys.game.scale.on(ScaleEvents.RESIZE, this.onResize, this); + + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.Cameras.Scene2D.CameraManager#start + * @private + * @listens Phaser.Scenes.Events#UPDATE + * @listens Phaser.Scenes.Events#SHUTDOWN + * @since 3.5.0 + */ + start: function () + { + if (!this.main) + { + var sys = this.systems; + + if (sys.settings.cameras) + { + // We have cameras to create + this.fromJSON(sys.settings.cameras); + } + else + { + // Make one + this.add(); + } + + this.main = this.cameras[0]; + } + + var eventEmitter = this.systems.events; + + eventEmitter.on(SceneEvents.UPDATE, this.update, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. + * + * See the Camera class documentation for more details. + * + * @method Phaser.Cameras.Scene2D.CameraManager#add + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal position of the Camera viewport. + * @param {number} [y=0] - The vertical position of the Camera viewport. + * @param {number} [width] - The width of the Camera viewport. If not given it'll be the game config size. + * @param {number} [height] - The height of the Camera viewport. If not given it'll be the game config size. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * @param {string} [name=''] - The name of the Camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} The newly created Camera. + */ + add: function (x, y, width, height, makeMain, name) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.scale.width; } + if (height === undefined) { height = this.scene.sys.scale.height; } + if (makeMain === undefined) { makeMain = false; } + if (name === undefined) { name = ''; } + + var camera = new Camera(x, y, width, height); + + camera.setName(name); + camera.setScene(this.scene); + camera.setRoundPixels(this.roundPixels); + + camera.id = this.getNextID(); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + return camera; + }, + + /** + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#addExisting + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * + * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. + */ + addExisting: function (camera, makeMain) + { + if (makeMain === undefined) { makeMain = false; } + + var index = this.cameras.indexOf(camera); + + if (index === -1) + { + camera.id = this.getNextID(); + + camera.setRoundPixels(this.roundPixels); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + return camera; + } + + return null; + }, + + /** + * Gets the next available Camera ID number. + * + * The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero. + * You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getNextID + * @private + * @since 3.11.0 + * + * @return {number} The next available Camera ID, or 0 if they're all already in use. + */ + getNextID: function () + { + var cameras = this.cameras; + + var testID = 1; + + // Find the first free camera ID we can use + + for (var t = 0; t < 32; t++) + { + var found = false; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera && camera.id === testID) + { + found = true; + continue; + } + } + + if (found) + { + testID = testID << 1; + } + else + { + return testID; + } + } + + return 0; + }, + + /** + * Gets the total number of Cameras in this Camera Manager. + * + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getTotal + * @since 3.11.0 + * + * @param {boolean} [isVisible=false] - Set to `true` to only include visible Cameras in the total. + * + * @return {number} The total number of Cameras in this Camera Manager. + */ + getTotal: function (isVisible) + { + if (isVisible === undefined) { isVisible = false; } + + var total = 0; + + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (!isVisible || (isVisible && camera.visible)) + { + total++; + } + } + + return total; + }, + + /** + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `Phaser.Types.Cameras.Scene2D.CameraConfig` documentation for details of the object structure. + * + * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON + * @since 3.0.0 + * + * @param {(Phaser.Types.Cameras.Scene2D.CameraConfig|Phaser.Types.Cameras.Scene2D.CameraConfig[])} config - A Camera configuration object, or an array of them, to be added to this Camera Manager. + * + * @return {this} This Camera Manager instance. + */ + fromJSON: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var gameWidth = this.scene.sys.scale.width; + var gameHeight = this.scene.sys.scale.height; + + for (var i = 0; i < config.length; i++) + { + var cameraConfig = config[i]; + + var x = GetFastValue(cameraConfig, 'x', 0); + var y = GetFastValue(cameraConfig, 'y', 0); + var width = GetFastValue(cameraConfig, 'width', gameWidth); + var height = GetFastValue(cameraConfig, 'height', gameHeight); + + var camera = this.add(x, y, width, height); + + // Direct properties + camera.name = GetFastValue(cameraConfig, 'name', ''); + camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); + camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); + camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); + camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); + camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); + camera.visible = GetFastValue(cameraConfig, 'visible', true); + + // Background Color + + var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); + + if (backgroundColor) + { + camera.setBackgroundColor(backgroundColor); + } + + // Bounds + + var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); + + if (boundsConfig) + { + var bx = GetFastValue(boundsConfig, 'x', 0); + var by = GetFastValue(boundsConfig, 'y', 0); + var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); + var bheight = GetFastValue(boundsConfig, 'height', gameHeight); + + camera.setBounds(bx, by, bwidth, bheight); + } + } + + return this; + }, + + /** + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - The name of the Camera. + * + * @return {?Phaser.Cameras.Scene2D.Camera} The first Camera with a name matching the given string, otherwise `null`. + */ + getCamera: function (name) + { + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + if (cameras[i].name === name) + { + return cameras[i]; + } + } + + return null; + }, + + /** + * Returns an array of all cameras below the given Pointer. + * + * The first camera in the array is the top-most camera in the camera list. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer + * @since 3.10.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. + * + * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. + */ + getCamerasBelowPointer: function (pointer) + { + var cameras = this.cameras; + + var x = pointer.x; + var y = pointer.y; + + var output = []; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) + { + // So the top-most camera is at the top of the search array + output.unshift(camera); + } + } + + return output; + }, + + /** + * Removes the given Camera, or an array of Cameras, from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. + * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references + * and internal data until destroyed or re-added to a Camera Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#remove + * @since 3.0.0 + * + * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. + * @param {boolean} [runDestroy=true] - Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. + * + * @return {number} The total number of Cameras removed. + */ + remove: function (camera, runDestroy) + { + if (runDestroy === undefined) { runDestroy = true; } + + if (!Array.isArray(camera)) + { + camera = [ camera ]; + } + + var total = 0; + var cameras = this.cameras; + + for (var i = 0; i < camera.length; i++) + { + var index = cameras.indexOf(camera[i]); + + if (index !== -1) + { + if (runDestroy) + { + cameras[index].destroy(); + } + else + { + cameras[index].renderList = []; + } + + cameras.splice(index, 1); + + total++; + } + } + + if (!this.main && cameras[0]) + { + this.main = cameras[0]; + } + + return total; + }, + + /** + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. + * + * @method Phaser.Cameras.Scene2D.CameraManager#render + * @protected + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. + * @param {Phaser.GameObjects.DisplayList} displayList - The Display List for the Scene. + */ + render: function (renderer, displayList) + { + var scene = this.scene; + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.alpha > 0) + { + camera.preRender(); + + var visibleChildren = this.getVisibleChildren(displayList.getChildren(), camera); + + renderer.render(scene, visibleChildren, camera); + } + } + }, + + /** + * Takes an array of Game Objects and a Camera and returns a new array + * containing only those Game Objects that pass the `willRender` test + * against the given Camera. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getVisibleChildren + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject[]} children - An array of Game Objects to be checked against the camera. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to filter the Game Objects against. + * + * @return {Phaser.GameObjects.GameObject[]} A filtered list of only Game Objects within the Scene that will render against the given Camera. + */ + getVisibleChildren: function (children, camera) + { + return children.filter(function (child) + { + return child.willRender(camera); + }); + }, + + /** + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resetAll + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} The freshly created main Camera. + */ + resetAll: function () + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + this.cameras = []; + + this.main = this.add(); + + return this.main; + }, + + /** + * The main update loop. Called automatically when the Scene steps. + * + * @method Phaser.Cameras.Scene2D.CameraManager#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].update(time, delta); + } + }, + + /** + * The event handler that manages the `resize` event dispatched by the Scale Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#onResize + * @since 3.18.0 + * + * @param {Phaser.Structs.Size} gameSize - The default Game Size object. This is the un-modified game dimensions. + * @param {Phaser.Structs.Size} baseSize - The base Size object. The game dimensions. The canvas width / height values match this. + */ + onResize: function (gameSize, baseSize, displaySize, previousWidth, previousHeight) + { + for (var i = 0; i < this.cameras.length; i++) + { + var cam = this.cameras[i]; + + // if camera is at 0x0 and was the size of the previous game size, then we can safely assume it + // should be updated to match the new game size too + + if (cam._x === 0 && cam._y === 0 && cam._width === previousWidth && cam._height === previousHeight) + { + cam.setSize(baseSize.width, baseSize.height); + } + } + }, + + /** + * Resizes all cameras to the given dimensions. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the camera. + * @param {number} height - The new height of the camera. + */ + resize: function (width, height) + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].setSize(width, height); + } + }, + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + * + * @method Phaser.Cameras.Scene2D.CameraManager#shutdown + * @private + * @since 3.0.0 + */ + shutdown: function () + { + this.main = undefined; + + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + this.cameras = []; + + var eventEmitter = this.systems.events; + + eventEmitter.off(SceneEvents.UPDATE, this.update, this); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Phaser.Cameras.Scene2D.CameraManager#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.default.destroy(); + + this.systems.events.off(SceneEvents.START, this.start, this); + this.systems.events.off(SceneEvents.DESTROY, this.destroy, this); + this.systems.game.scale.off(ScaleEvents.RESIZE, this.onResize, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('CameraManager', CameraManager, 'cameras'); + +module.exports = CameraManager; + + +/***/ }, + +/***/ 5020 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); + +/** + * @classdesc + * A Camera Fade effect. + * + * This effect will fade the camera viewport to the given color, over the duration specified. + * + * Only the camera viewport is faded. None of the objects it is displaying are impacted, i.e. their colors do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect, if required. + * + * @class Fade + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.5.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Fade = new Class({ + + initialize: + + function Fade (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.5.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.5.0 + */ + this.isRunning = false; + + /** + * Has this effect finished running? + * + * This is different from `isRunning` because it remains set to `true` when the effect is over, + * until the effect is either reset or started again. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#isComplete + * @type {boolean} + * @readonly + * @default false + * @since 3.5.0 + */ + this.isComplete = false; + + /** + * The direction of the fade. + * `true` = fade out (transparent to color), `false` = fade in (color to transparent) + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#direction + * @type {boolean} + * @readonly + * @since 3.5.0 + */ + this.direction = true; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#duration + * @type {number} + * @readonly + * @default 0 + * @since 3.5.0 + */ + this.duration = 0; + + /** + * The value of the red color channel the camera will use for the fade effect. + * A value between 0 and 255. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#red + * @type {number} + * @private + * @since 3.5.0 + */ + this.red = 0; + + /** + * The value of the green color channel the camera will use for the fade effect. + * A value between 0 and 255. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#green + * @type {number} + * @private + * @since 3.5.0 + */ + this.green = 0; + + /** + * The value of the blue color channel the camera will use for the fade effect. + * A value between 0 and 255. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#blue + * @type {number} + * @private + * @since 3.5.0 + */ + this.blue = 0; + + /** + * The value of the alpha channel used during the fade effect. + * A value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#alpha + * @type {number} + * @private + * @since 3.5.0 + */ + this.alpha = 0; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#progress + * @type {number} + * @since 3.5.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#_elapsed + * @type {number} + * @private + * @since 3.5.0 + */ + this._elapsed = 0; + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdate + * @type {?Phaser.Types.Cameras.Scene2D.CameraFadeCallback} + * @private + * @default null + * @since 3.5.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdateScope + * @type {any} + * @private + * @since 3.5.0 + */ + this._onUpdateScope; + }, + + /** + * Fades the Camera to or from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#start + * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_START + * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_START + * @since 3.5.0 + * + * @param {boolean} [direction=true] - The direction of the fade. `true` = fade out (transparent to color), `false` = fade in (color to transparent) + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. + * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. + * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. + * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraFadeCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. + */ + start: function (direction, duration, red, green, blue, force, callback, context) + { + if (direction === undefined) { direction = true; } + if (duration === undefined) { duration = 1000; } + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + if (!force && this.isRunning) + { + return this.camera; + } + + this.isRunning = true; + this.isComplete = false; + this.duration = duration; + this.direction = direction; + this.progress = 0; + + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = (direction) ? Number.MIN_VALUE : 1; + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + var eventName = (direction) ? Events.FADE_OUT_START : Events.FADE_IN_START; + + this.camera.emit(eventName, this.camera, this, duration, red, green, blue); + + return this.camera; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#update + * @since 3.5.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.isRunning) + { + return; + } + + this._elapsed += delta; + + this.progress = Clamp(this._elapsed / this.duration, 0, 1); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress); + } + + if (this._elapsed < this.duration) + { + this.alpha = (this.direction) ? this.progress : 1 - this.progress; + } + else + { + this.alpha = (this.direction) ? 1 : 0; + this.effectComplete(); + } + }, + + /** + * Called internally by the Canvas Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderCanvas + * @since 3.5.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas context to render to. + * + * @return {boolean} `true` if the effect drew to the renderer, otherwise `false`. + */ + postRenderCanvas: function (ctx) + { + if (!this.isRunning && !this.isComplete) + { + return false; + } + + var camera = this.camera; + + ctx.fillStyle = 'rgba(' + this.red + ',' + this.green + ',' + this.blue + ',' + this.alpha + ')'; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderWebGL + * @since 3.5.0 + * + * @return {boolean} `true` if the effect should draw to the renderer, otherwise `false`. + */ + postRenderWebGL: function () + { + return this.isRunning || this.isComplete; + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#effectComplete + * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE + * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE + * @since 3.5.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + this.isComplete = true; + + var eventName = (this.direction) ? Events.FADE_OUT_COMPLETE : Events.FADE_IN_COMPLETE; + + this.camera.emit(eventName, this.camera, this); + }, + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#reset + * @since 3.5.0 + */ + reset: function () + { + this.isRunning = false; + this.isComplete = false; + + this._onUpdate = null; + this._onUpdateScope = null; + }, + + /** + * Destroys this effect, releasing it from the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#destroy + * @since 3.5.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + } + +}); + +module.exports = Fade; + + +/***/ }, + +/***/ 10662 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); + +/** + * @classdesc + * A Camera Flash effect. + * + * This effect will flash the camera viewport to the given color, over the duration specified. + * + * Only the camera viewport is flashed. None of the objects it is displaying are impacted, i.e. their colors do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect, if required. + * + * @class Flash + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.5.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Flash = new Class({ + + initialize: + + function Flash (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.5.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.5.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#duration + * @type {number} + * @readonly + * @default 0 + * @since 3.5.0 + */ + this.duration = 0; + + /** + * The value of the red color channel the camera will use for the flash effect. + * A value between 0 and 255. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#red + * @type {number} + * @private + * @since 3.5.0 + */ + this.red = 0; + + /** + * The value of the green color channel the camera will use for the flash effect. + * A value between 0 and 255. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#green + * @type {number} + * @private + * @since 3.5.0 + */ + this.green = 0; + + /** + * The value of the blue color channel the camera will use for the flash effect. + * A value between 0 and 255. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#blue + * @type {number} + * @private + * @since 3.5.0 + */ + this.blue = 0; + + /** + * The value of the alpha channel used during the flash effect. + * A value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#alpha + * @type {number} + * @since 3.5.0 + */ + this.alpha = 1; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#progress + * @type {number} + * @since 3.5.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#_elapsed + * @type {number} + * @private + * @since 3.5.0 + */ + this._elapsed = 0; + + /** + * This is an internal copy of the initial value of `this.alpha`, used to calculate the current alpha value of the flash effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#_alpha + * @type {number} + * @private + * @readonly + * @since 3.60.0 + */ + this._alpha; + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdate + * @type {?Phaser.Types.Cameras.Scene2D.CameraFlashCallback} + * @private + * @default null + * @since 3.5.0 + */ + this._onUpdate; + + /** + * On Update callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdateScope + * @type {any} + * @private + * @since 3.5.0 + */ + this._onUpdateScope; + }, + + /** + * Flashes the Camera to or from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#start + * @fires Phaser.Cameras.Scene2D.Events#FLASH_START + * @fires Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE + * @since 3.5.0 + * + * @param {number} [duration=250] - The duration of the effect in milliseconds. + * @param {number} [red=255] - The amount to flash the red channel towards. A value between 0 and 255. + * @param {number} [green=255] - The amount to flash the green channel towards. A value between 0 and 255. + * @param {number} [blue=255] - The amount to flash the blue channel towards. A value between 0 and 255. + * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraFlashCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. + */ + start: function (duration, red, green, blue, force, callback, context) + { + if (duration === undefined) { duration = 250; } + if (red === undefined) { red = 255; } + if (green === undefined) { green = 255; } + if (blue === undefined) { blue = 255; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + if (!force && this.isRunning) + { + return this.camera; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + this.red = red; + this.green = green; + this.blue = blue; + + this._alpha = this.alpha; + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit(Events.FLASH_START, this.camera, this, duration, red, green, blue); + + return this.camera; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#update + * @since 3.5.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.isRunning) + { + return; + } + + this._elapsed += delta; + + this.progress = Clamp(this._elapsed / this.duration, 0, 1); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress); + } + + if (this._elapsed < this.duration) + { + this.alpha = this._alpha * (1 - this.progress); + } + else + { + this.effectComplete(); + } + }, + + /** + * Called internally by the Canvas Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderCanvas + * @since 3.5.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas context to render to. + * + * @return {boolean} `true` if the effect drew to the renderer, otherwise `false`. + */ + postRenderCanvas: function (ctx) + { + if (!this.isRunning) + { + return false; + } + + var camera = this.camera; + + ctx.fillStyle = 'rgba(' + this.red + ',' + this.green + ',' + this.blue + ',' + this.alpha + ')'; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderWebGL + * @since 3.5.0 + * + * @return {boolean} `true` if the effect should draw to the renderer, otherwise `false`. + */ + postRenderWebGL: function () + { + return this.isRunning; + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#effectComplete + * @fires Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE + * @since 3.5.0 + */ + effectComplete: function () + { + this.alpha = this._alpha; + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit(Events.FLASH_COMPLETE, this.camera, this); + }, + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#reset + * @since 3.5.0 + */ + reset: function () + { + this.isRunning = false; + + this._onUpdate = null; + this._onUpdateScope = null; + }, + + /** + * Destroys this effect, releasing it from the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#destroy + * @since 3.5.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + } + +}); + +module.exports = Flash; + + +/***/ }, + +/***/ 20359 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var EaseMap = __webpack_require__(62640); +var Events = __webpack_require__(19715); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Camera Pan effect. + * + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * Only the camera scroll is moved. None of the objects it is displaying are impacted, i.e. their positions do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + * + * @class Pan + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Pan = new Class({ + + initialize: + + function Pan (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#duration + * @type {number} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting scroll coordinates to pan the camera from. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#source + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.source = new Vector2(); + + /** + * The zoom-adjusted scroll coordinates of the camera, recalculated each frame during the pan + * to account for the current camera zoom level. Used as an intermediate value when interpolating + * between the source and destination scroll positions. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#current + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.current = new Vector2(); + + /** + * The destination scroll coordinates to pan the camera to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#destination + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.destination = new Vector2(); + + /** + * The ease function to use during the pan. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdate + * @type {?Phaser.Types.Cameras.Scene2D.CameraPanCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * The context in which the `_onUpdate` callback is invoked. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#start + * @fires Phaser.Cameras.Scene2D.Events#PAN_START + * @fires Phaser.Cameras.Scene2D.Events#PAN_COMPLETE + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the pan effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. + */ + start: function (x, y, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source.set(cam.scrollX, cam.scrollY); + + // Destination + this.destination.set(x, y); + + // Zoom factored version + cam.getScroll(x, y, this.current); + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit(Events.PAN_START, this.camera, this, duration, x, y); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#update + * @since 3.11.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.isRunning) + { + return; + } + + this._elapsed += delta; + + var progress = Clamp(this._elapsed / this.duration, 0, 1); + + this.progress = progress; + + var cam = this.camera; + + if (this._elapsed < this.duration) + { + var v = this.ease(progress); + + cam.getScroll(this.destination.x, this.destination.y, this.current); + + var x = this.source.x + ((this.current.x - this.source.x) * v); + var y = this.source.y + ((this.current.y - this.source.y) * v); + + cam.setScroll(x, y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, x, y); + } + } + else + { + cam.centerOn(this.destination.x, this.destination.y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, cam.scrollX, cam.scrollY); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#effectComplete + * @fires Phaser.Cameras.Scene2D.Events#PAN_COMPLETE + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit(Events.PAN_COMPLETE, this.camera, this); + }, + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#reset + * @since 3.11.0 + */ + reset: function () + { + this.isRunning = false; + + this._onUpdate = null; + this._onUpdateScope = null; + }, + + /** + * Destroys this effect, releasing it from the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + this.source = null; + this.destination = null; + } + +}); + +module.exports = Pan; + + +/***/ }, + +/***/ 34208 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Jason Nicholls + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); +var EaseMap = __webpack_require__(62640); +var WrapAngle = __webpack_require__(86554); + +/** + * @classdesc + * A Camera Rotate effect that smoothly rotates the Camera to a target angle over a specified duration. + * + * This effect will rotate the Camera so that its viewport finishes at the given angle in radians, + * over the duration and with the ease specified. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * Only the camera is rotated. None of the objects it is displaying are impacted, i.e. their positions do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + * + * @class RotateTo + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.23.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var RotateTo = new Class({ + + initialize: + + function RotateTo (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.23.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.23.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#duration + * @type {number} + * @readonly + * @default 0 + * @since 3.23.0 + */ + this.duration = 0; + + /** + * The starting angle to rotate the camera from, in radians. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#source + * @type {number} + * @since 3.23.0 + */ + this.source = 0; + + /** + * The current camera angle during the rotation, in radians. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#current + * @type {number} + * @since 3.23.0 + */ + this.current = 0; + + /** + * The destination angle to rotate the camera to, in radians. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#destination + * @type {number} + * @since 3.23.0 + */ + this.destination = 0; + + /** + * The ease function to use during the rotation. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#ease + * @type {function} + * @since 3.23.0 + */ + this.ease; + + /** + * If this effect is running this holds the current progress, a value between 0 (start) and 1 (end). + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#progress + * @type {number} + * @since 3.23.0 + */ + this.progress = 0; + + /** + * The elapsed duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#_elapsed + * @type {number} + * @private + * @since 3.23.0 + */ + this._elapsed = 0; + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#_onUpdate + * @type {?CameraRotateCallback} + * @private + * @default null + * @since 3.23.0 + */ + this._onUpdate; + + /** + * Context (`this` value) for the update callback. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#_onUpdateScope + * @type {any} + * @private + * @since 3.23.0 + */ + this._onUpdateScope; + + /** + * Whether the rotation is progressing in a clockwise (`true`) or counter-clockwise (`false`) direction. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#clockwise + * @type {boolean} + * @since 3.23.0 + */ + this.clockwise = true; + + /** + * Whether the effect should rotate via the shortest angular path to the destination angle. + * + * @name Phaser.Cameras.Scene2D.Effects.RotateTo#shortestPath + * @type {boolean} + * @since 3.23.0 + */ + this.shortestPath = false; + }, + + /** + * Rotate the Camera to the given angle over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.RotateTo#start + * @fires Phaser.Cameras.Scene2D.Events#ROTATE_START + * @fires Phaser.Cameras.Scene2D.Events#ROTATE_COMPLETE + * @since 3.23.0 + * + * @param {number} angle - The destination angle in radians to rotate the Camera view to. + * @param {boolean} [shortestPath=false] - If true, take the shortest distance to the destination. This adjusts the destination angle to be within one half turn of the start angle. + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the rotation effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraRotateCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera rotation. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. + */ + start: function (angle, shortestPath, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + if (shortestPath === undefined) { shortestPath = false; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.shortestPath = shortestPath; + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source = cam.rotation; + + // Destination + this.destination = angle; + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + if (this.shortestPath) + { + var distance = WrapAngle(this.destination - this.source); + + this.destination = this.source + distance; + + this.clockwise = distance >= 0; + } + else + { + this.clockwise = this.destination >= this.source; + } + + this.camera.emit(Events.ROTATE_START, this.camera, this, duration, this.destination); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.RotateTo#update + * @since 3.23.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.isRunning) + { + return; + } + + this._elapsed += delta; + + var progress = Clamp(this._elapsed / this.duration, 0, 1); + + this.progress = progress; + + var cam = this.camera; + + if (this._elapsed < this.duration) + { + var v = this.ease(progress); + var r = this.source + v * (this.destination - this.source); + + cam.rotation = r; + + this.current = r; + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, r); + } + } + else + { + cam.rotation = this.destination; + + this.current = this.destination; + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, this.destination); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.RotateTo#effectComplete + * @since 3.23.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit(Events.ROTATE_COMPLETE, this.camera, this); + }, + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + * + * @method Phaser.Cameras.Scene2D.Effects.RotateTo#reset + * @since 3.23.0 + */ + reset: function () + { + this.isRunning = false; + + this._onUpdate = null; + this._onUpdateScope = null; + }, + + /** + * Destroys this effect, releasing it from the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.RotateTo#destroy + * @since 3.23.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + this.source = null; + this.destination = null; + } + +}); + +module.exports = RotateTo; + + +/***/ }, + +/***/ 30330 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Camera Shake effect. + * + * This effect will shake the camera viewport by a random amount, bounded by the specified intensity, each frame. + * + * Only the camera viewport is moved. None of the objects it is displaying are impacted, i.e. their positions do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + * + * @class Shake + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.5.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Shake = new Class({ + + initialize: + + function Shake (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.5.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.5.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#duration + * @type {number} + * @readonly + * @default 0 + * @since 3.5.0 + */ + this.duration = 0; + + /** + * The intensity of the effect. Use small float values. The default when the effect starts is 0.05. + * This is a Vector2 object, allowing you to control the shake intensity independently across x and y. + * You can modify this value while the effect is active to create more varied shake effects. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#intensity + * @type {Phaser.Math.Vector2} + * @since 3.5.0 + */ + this.intensity = new Vector2(); + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#progress + * @type {number} + * @since 3.5.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#_elapsed + * @type {number} + * @private + * @since 3.5.0 + */ + this._elapsed = 0; + + /** + * How much to offset the camera by horizontally. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#_offsetX + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._offsetX = 0; + + /** + * How much to offset the camera by vertically. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#_offsetY + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._offsetY = 0; + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdate + * @type {?Phaser.Types.Cameras.Scene2D.CameraShakeCallback} + * @private + * @default null + * @since 3.5.0 + */ + this._onUpdate; + + /** + * The context in which the `_onUpdate` callback is invoked. + * + * @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdateScope + * @type {any} + * @private + * @since 3.5.0 + */ + this._onUpdateScope; + }, + + /** + * Shakes the Camera by the given intensity over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Shake#start + * @fires Phaser.Cameras.Scene2D.Events#SHAKE_START + * @fires Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE + * @since 3.5.0 + * + * @param {number} [duration=100] - The duration of the effect in milliseconds. + * @param {(number|Phaser.Math.Vector2)} [intensity=0.05] - The intensity of the shake. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraShakeCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. + */ + start: function (duration, intensity, force, callback, context) + { + if (duration === undefined) { duration = 100; } + if (intensity === undefined) { intensity = 0.05; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + if (!force && this.isRunning) + { + return this.camera; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + if (typeof intensity === 'number') + { + this.intensity.set(intensity); + } + else + { + this.intensity.set(intensity.x, intensity.y); + } + + this._elapsed = 0; + this._offsetX = 0; + this._offsetY = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit(Events.SHAKE_START, this.camera, this, duration, intensity); + + return this.camera; + }, + + /** + * The pre-render step for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Shake#preRender + * @since 3.5.0 + */ + preRender: function () + { + if (this.isRunning) + { + this.camera.matrix.translate(this._offsetX, this._offsetY); + } + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Shake#update + * @since 3.5.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.isRunning) + { + return; + } + + this._elapsed += delta; + + this.progress = Clamp(this._elapsed / this.duration, 0, 1); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress); + } + + if (this._elapsed < this.duration) + { + var intensity = this.intensity; + var width = this.camera.width; + var height = this.camera.height; + var zoom = this.camera.zoom; + + this._offsetX = (Math.random() * intensity.x * width * 2 - intensity.x * width) * zoom; + this._offsetY = (Math.random() * intensity.y * height * 2 - intensity.y * height) * zoom; + + if (this.camera.roundPixels) + { + this._offsetX = Math.round(this._offsetX); + this._offsetY = Math.round(this._offsetY); + } + } + else + { + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Shake#effectComplete + * @fires Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE + * @since 3.5.0 + */ + effectComplete: function () + { + this._offsetX = 0; + this._offsetY = 0; + + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit(Events.SHAKE_COMPLETE, this.camera, this); + }, + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + * + * @method Phaser.Cameras.Scene2D.Effects.Shake#reset + * @since 3.5.0 + */ + reset: function () + { + this.isRunning = false; + + this._offsetX = 0; + this._offsetY = 0; + + this._onUpdate = null; + this._onUpdateScope = null; + }, + + /** + * Destroys this effect, releasing it from the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Shake#destroy + * @since 3.5.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + this.intensity = null; + } + +}); + +module.exports = Shake; + + +/***/ }, + +/***/ 45641 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var EaseMap = __webpack_require__(62640); +var Events = __webpack_require__(19715); + +/** + * @classdesc + * A Camera Zoom effect. + * + * This effect smoothly animates a Camera's zoom level from its current value to a target zoom value over a + * specified duration. Use it to create cinematic zoom-in or zoom-out transitions, focus the player's + * attention on a point of interest, or produce dramatic effects such as a slow zoom during a cutscene. + * + * The effect integrates with Phaser's easing system, allowing any of the built-in easing functions (or a + * custom one) to control the interpolation curve. It is accessed via `Camera.zoomTo` rather than being + * instantiated directly. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + * + * @class Zoom + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Zoom = new Class({ + + initialize: + + function Zoom (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#duration + * @type {number} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting zoom value. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#source + * @type {number} + * @since 3.11.0 + */ + this.source = 1; + + /** + * The destination zoom value. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#destination + * @type {number} + * @since 3.11.0 + */ + this.destination = 1; + + /** + * The ease function to use during the zoom. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdate + * @type {?Phaser.Types.Cameras.Scene2D.CameraZoomCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#start + * @fires Phaser.Cameras.Scene2D.Events#ZOOM_START + * @fires Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {number} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the zoom effect to start immediately, even if already running. + * @param {Phaser.Types.Cameras.Scene2D.CameraZoomCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera zoom value. + * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + * + * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. + */ + start: function (zoom, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source = cam.zoom; + + // Zooming to + this.destination = zoom; + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit(Events.ZOOM_START, this.camera, this, duration, zoom); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#update + * @since 3.11.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.isRunning) + { + return; + } + + this._elapsed += delta; + + this.progress = Clamp(this._elapsed / this.duration, 0, 1); + + if (this._elapsed < this.duration) + { + this.camera.zoom = this.source + ((this.destination - this.source) * this.ease(this.progress)); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.camera.zoom); + } + } + else + { + this.camera.zoom = this.destination; + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.destination); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#effectComplete + * @fires Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit(Events.ZOOM_COMPLETE, this.camera, this); + }, + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#reset + * @since 3.11.0 + */ + reset: function () + { + this.isRunning = false; + + this._onUpdate = null; + this._onUpdateScope = null; + }, + + /** + * Destroys this effect, releasing it from the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + } + +}); + +module.exports = Zoom; + + +/***/ }, + +/***/ 20052 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Scene2D.Effects + */ + +module.exports = { + + Fade: __webpack_require__(5020), + Flash: __webpack_require__(10662), + Pan: __webpack_require__(20359), + Shake: __webpack_require__(30330), + RotateTo: __webpack_require__(34208), + Zoom: __webpack_require__(45641) + +}; + + +/***/ }, + +/***/ 16438 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Destroy Camera Event. + * + * This event is dispatched by a Camera instance when it is destroyed by the Camera Manager. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('cameradestroy', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.DESTROY, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#DESTROY + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that was destroyed. + */ +module.exports = 'cameradestroy'; + + +/***/ }, + +/***/ 32726 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Fade In Complete Event. + * + * This event is dispatched by a Camera instance when the Fade In Effect completes. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeincomplete', listener)`. + * + * @event Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. + */ +module.exports = 'camerafadeincomplete'; + + +/***/ }, + +/***/ 87807 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Fade In Start Event. + * + * This event is dispatched by a Camera instance when the Fade In Effect starts. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeinstart', listener)`. + * + * @event Phaser.Cameras.Scene2D.Events#FADE_IN_START + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. + * @param {number} duration - The duration of the effect. + * @param {number} red - The red color channel value. + * @param {number} green - The green color channel value. + * @param {number} blue - The blue color channel value. + */ +module.exports = 'camerafadeinstart'; + + +/***/ }, + +/***/ 45917 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Fade Out Complete Event. + * + * This event is dispatched by a Camera instance when the Fade Out Effect completes. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeoutcomplete', listener)`. + * + * @event Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. + */ +module.exports = 'camerafadeoutcomplete'; + + +/***/ }, + +/***/ 95666 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Fade Out Start Event. + * + * This event is dispatched by a Camera instance when the Fade Out Effect starts. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeoutstart', listener)`. + * + * @event Phaser.Cameras.Scene2D.Events#FADE_OUT_START + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. + * @param {number} duration - The duration of the effect. + * @param {number} red - The red color channel value. + * @param {number} green - The green color channel value. + * @param {number} blue - The blue color channel value. + */ +module.exports = 'camerafadeoutstart'; + + +/***/ }, + +/***/ 47056 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Flash Complete Event. + * + * This event is dispatched by a Camera instance when the Flash Effect completes. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('cameraflashcomplete', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.FLASH_COMPLETE, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Flash} effect - A reference to the effect instance. + */ +module.exports = 'cameraflashcomplete'; + + +/***/ }, + +/***/ 91261 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Flash Start Event. + * + * This event is dispatched by a Camera instance when the Flash Effect starts. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('cameraflashstart', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.FLASH_START, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#FLASH_START + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Flash} effect - A reference to the effect instance. + * @param {number} duration - The duration of the effect. + * @param {number} red - The red color channel value. + * @param {number} green - The green color channel value. + * @param {number} blue - The blue color channel value. + */ +module.exports = 'cameraflashstart'; + + +/***/ }, + +/***/ 45047 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Follower Update Event. + * + * This event is dispatched by a Camera instance when it is following a + * Game Object and the Camera position has been updated as a result of + * that following. + * + * Listen to it from a Camera instance using: `camera.on('followupdate', listener)`. + * + * @event Phaser.Cameras.Scene2D.Events#FOLLOW_UPDATE + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that emitted the event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the camera is following. + */ +module.exports = 'followupdate'; + + +/***/ }, + +/***/ 81927 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Pan Complete Event. + * + * This event is dispatched by a Camera instance when the Pan Effect completes. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerapancomplete', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.PAN_COMPLETE, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#PAN_COMPLETE + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + */ +module.exports = 'camerapancomplete'; + + +/***/ }, + +/***/ 74264 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Pan Start Event. + * + * This event is dispatched by a Camera instance when the Pan Effect starts. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerapanstart', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.PAN_START, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#PAN_START + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + * @param {number} duration - The duration of the effect. + * @param {number} x - The destination scroll x coordinate. + * @param {number} y - The destination scroll y coordinate. + */ +module.exports = 'camerapanstart'; + + +/***/ }, + +/***/ 54419 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Post-Render Event. + * + * This event is dispatched by a Camera instance after is has finished rendering. + * It is dispatched whether the Camera is rendering to a texture or to the main canvas. + * + * Listen to it from a Camera instance using: `camera.on('postrender', listener)`. + * + * @event Phaser.Cameras.Scene2D.Events#POST_RENDER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that has finished rendering to a texture. + */ +module.exports = 'postrender'; + + +/***/ }, + +/***/ 79330 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Pre-Render Event. + * + * This event is dispatched by a Camera instance when it is about to render. + * It is only dispatched if the Camera is rendering to a texture. + * + * Listen to it from a Camera instance using: `camera.on('prerender', listener)`. + * + * @event Phaser.Cameras.Scene2D.Events#PRE_RENDER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that is about to render to a texture. + */ +module.exports = 'prerender'; + + +/***/ }, + +/***/ 93183 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Rotate Complete Event. + * + * This event is dispatched by a Camera instance when the Rotate Effect completes. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerarotatecomplete', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ROTATE_COMPLETE, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#ROTATE_COMPLETE + * @type {string} + * @since 3.23.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.RotateTo} effect - A reference to the effect instance. + */ +module.exports = 'camerarotatecomplete'; + + +/***/ }, + +/***/ 80112 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Rotate Start Event. + * + * This event is dispatched by a Camera instance when the Rotate Effect starts. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerarotatestart', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ROTATE_START, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#ROTATE_START + * @type {string} + * @since 3.23.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.RotateTo} effect - A reference to the effect instance. + * @param {number} duration - The duration of the effect. + * @param {number} destination - The destination value. + */ +module.exports = 'camerarotatestart'; + + +/***/ }, + +/***/ 62252 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Shake Complete Event. + * + * This event is dispatched by a Camera instance when the Shake Effect completes. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerashakecomplete', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.SHAKE_COMPLETE, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance. + */ +module.exports = 'camerashakecomplete'; + + +/***/ }, + +/***/ 86017 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Shake Start Event. + * + * This event is dispatched by a Camera instance when the Shake Effect starts. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerashakestart', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.SHAKE_START, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#SHAKE_START + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance. + * @param {number} duration - The duration of the effect. + * @param {number} intensity - The intensity of the effect. + */ +module.exports = 'camerashakestart'; + + +/***/ }, + +/***/ 539 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Zoom Complete Event. + * + * This event is dispatched by a Camera instance when the Zoom Effect completes. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerazoomcomplete', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ZOOM_COMPLETE, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + */ +module.exports = 'camerazoomcomplete'; + + +/***/ }, + +/***/ 51892 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Camera Zoom Start Event. + * + * This event is dispatched by a Camera instance when the Zoom Effect starts. + * + * Listen for it via either of the following: + * + * ```js + * this.cameras.main.on('camerazoomstart', () => {}); + * ``` + * + * or use the constant, to avoid having to remember the correct event string: + * + * ```js + * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ZOOM_START, () => {}); + * ``` + * + * @event Phaser.Cameras.Scene2D.Events#ZOOM_START + * @type {string} + * @since 3.3.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + * @param {number} duration - The duration of the effect. + * @param {number} zoom - The destination zoom value. + */ +module.exports = 'camerazoomstart'; + + +/***/ }, + +/***/ 19715 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Scene2D.Events + */ + +module.exports = { + + DESTROY: __webpack_require__(16438), + FADE_IN_COMPLETE: __webpack_require__(32726), + FADE_IN_START: __webpack_require__(87807), + FADE_OUT_COMPLETE: __webpack_require__(45917), + FADE_OUT_START: __webpack_require__(95666), + FLASH_COMPLETE: __webpack_require__(47056), + FLASH_START: __webpack_require__(91261), + FOLLOW_UPDATE: __webpack_require__(45047), + PAN_COMPLETE: __webpack_require__(81927), + PAN_START: __webpack_require__(74264), + POST_RENDER: __webpack_require__(54419), + PRE_RENDER: __webpack_require__(79330), + ROTATE_COMPLETE: __webpack_require__(93183), + ROTATE_START: __webpack_require__(80112), + SHAKE_COMPLETE: __webpack_require__(62252), + SHAKE_START: __webpack_require__(86017), + ZOOM_COMPLETE: __webpack_require__(539), + ZOOM_START: __webpack_require__(51892) + +}; + + +/***/ }, + +/***/ 87969 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Scene2D + */ + +module.exports = { + + Camera: __webpack_require__(38058), + BaseCamera: __webpack_require__(71911), + CameraManager: __webpack_require__(32743), + Effects: __webpack_require__(20052), + Events: __webpack_require__(19715) + +}; + + +/***/ }, + +/***/ 63091 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var GetValue = __webpack_require__(35154); + +/** + * @classdesc + * A Fixed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using keyboard keys. Unlike + * the `SmoothedKeyControl`, this control applies movement and zoom changes directly each + * update tick with no easing or smoothing. The camera responds instantly when a key is + * pressed and stops instantly when it is released, making it suitable for grid-based or + * precision camera navigation. + * + * ```javascript + * var camControl = new FixedKeyControl({ + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * speed: float OR { x: 0, y: 0 } + * }); + * ``` + * + * Movement is precise and has no 'smoothing' applied to it. + * + * You must call the `update` method of this controller every frame. + * + * @class FixedKeyControl + * @memberof Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Types.Cameras.Controls.FixedKeyControlConfig} config - The Fixed Key Control configuration object. + */ +var FixedKeyControl = new Class({ + + initialize: + + function FixedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#camera + * @type {?Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#left + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#right + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#up + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#down + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomIn + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomOut + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The amount by which the camera zoom level is changed on each update tick when the `zoomIn` or `zoomOut` keys are pressed. Unlike the scroll speed, this value is not scaled by delta time. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed + * @type {number} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The smallest zoom value the camera will reach when zoomed out. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#minZoom + * @type {number} + * @default 0.001 + * @since 3.53.0 + */ + this.minZoom = GetValue(config, 'minZoom', 0.001); + + /** + * The largest zoom value the camera will reach when zoomed in. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#maxZoom + * @type {number} + * @default 1000 + * @since 3.53.0 + */ + this.maxZoom = GetValue(config, 'maxZoom', 1000); + + /** + * The horizontal speed at which the camera will scroll, in pixels per millisecond. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedX = 0; + + /** + * The vertical speed at which the camera will scroll, in pixels per millisecond. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedY = 0; + + var speed = GetValue(config, 'speed', null); + + if (typeof speed === 'number') + { + this.speedX = speed; + this.speedY = speed; + } + else + { + this.speedX = GetValue(config, 'speed.x', 0); + this.speedY = GetValue(config, 'speed.y', 0); + } + + /** + * Internal property to track the current zoom level. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#start + * @since 3.0.0 + * + * @return {this} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#stop + * @since 3.0.0 + * + * @return {this} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {this} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + if (this.up && this.up.isDown) + { + cam.scrollY -= ((this.speedY * delta) | 0); + } + else if (this.down && this.down.isDown) + { + cam.scrollY += ((this.speedY * delta) | 0); + } + + if (this.left && this.left.isDown) + { + cam.scrollX -= ((this.speedX * delta) | 0); + } + else if (this.right && this.right.isDown) + { + cam.scrollX += ((this.speedX * delta) | 0); + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + cam.zoom -= this.zoomSpeed; + + if (cam.zoom < this.minZoom) + { + cam.zoom = this.minZoom; + } + } + else if (this.zoomOut && this.zoomOut.isDown) + { + cam.zoom += this.zoomSpeed; + + if (cam.zoom > this.maxZoom) + { + cam.zoom = this.maxZoom; + } + } + }, + + /** + * Destroys this Key Control, nulling its camera and key references to allow for garbage collection. + * This Key Control cannot be used again after being destroyed. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = FixedKeyControl; + + +/***/ }, + +/***/ 58818 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var GetValue = __webpack_require__(35154); + +/** + * @classdesc + * A Smoothed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using the defined keys. + * Unlike the Fixed Camera Control you can also provide physics values for acceleration, drag and maxSpeed for smoothing effects. + * + * ```javascript + * var controlConfig = { + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * up: cursors.up, + * down: cursors.down, + * zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), + * zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), + * zoomSpeed: 0.02, + * acceleration: 0.06, + * drag: 0.0005, + * maxSpeed: 1.0 + * }; + * ``` + * + * You must call the `update` method of this controller every frame. + * + * @class SmoothedKeyControl + * @memberof Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Types.Cameras.Controls.SmoothedKeyControlConfig} config - The Smoothed Key Control configuration object. + */ +var SmoothedKeyControl = new Class({ + + initialize: + + function SmoothedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#camera + * @type {?Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#left + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#right + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#up + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#down + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomIn + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomOut + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed + * @type {number} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The smallest zoom value the camera will reach when zoomed out. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#minZoom + * @type {number} + * @default 0.001 + * @since 3.53.0 + */ + this.minZoom = GetValue(config, 'minZoom', 0.001); + + /** + * The largest zoom value the camera will reach when zoomed in. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxZoom + * @type {number} + * @default 1000 + * @since 3.53.0 + */ + this.maxZoom = GetValue(config, 'maxZoom', 1000); + + /** + * The horizontal acceleration applied to the camera's movement when a directional key is held down. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelX = 0; + + /** + * The vertical acceleration applied to the camera's movement when a directional key is held down. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelY = 0; + + var accel = GetValue(config, 'acceleration', null); + + if (typeof accel === 'number') + { + this.accelX = accel; + this.accelY = accel; + } + else + { + this.accelX = GetValue(config, 'acceleration.x', 0); + this.accelY = GetValue(config, 'acceleration.y', 0); + } + + /** + * The horizontal drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragX = 0; + + /** + * The vertical drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragY = 0; + + var drag = GetValue(config, 'drag', null); + + if (typeof drag === 'number') + { + this.dragX = drag; + this.dragY = drag; + } + else + { + this.dragX = GetValue(config, 'drag.x', 0); + this.dragY = GetValue(config, 'drag.y', 0); + } + + /** + * The maximum horizontal speed the camera can reach. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedX = 0; + + /** + * The maximum vertical speed the camera can reach. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedY = 0; + + var maxSpeed = GetValue(config, 'maxSpeed', null); + + if (typeof maxSpeed === 'number') + { + this.maxSpeedX = maxSpeed; + this.maxSpeedY = maxSpeed; + } + else + { + this.maxSpeedX = GetValue(config, 'maxSpeed.x', 0); + this.maxSpeedY = GetValue(config, 'maxSpeed.y', 0); + } + + /** + * Internal property to track the speed of the control. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedX = 0; + + /** + * Internal property to track the speed of the control. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedY = 0; + + /** + * Internal property to track the zoom of the control. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#start + * @since 3.0.0 + * + * @return {this} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#stop + * @since 3.0.0 + * + * @return {this} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {this} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + // Apply Deceleration + + if (this._speedX > 0) + { + this._speedX -= this.dragX * delta; + + if (this._speedX < 0) + { + this._speedX = 0; + } + } + else if (this._speedX < 0) + { + this._speedX += this.dragX * delta; + + if (this._speedX > 0) + { + this._speedX = 0; + } + } + + if (this._speedY > 0) + { + this._speedY -= this.dragY * delta; + + if (this._speedY < 0) + { + this._speedY = 0; + } + } + else if (this._speedY < 0) + { + this._speedY += this.dragY * delta; + + if (this._speedY > 0) + { + this._speedY = 0; + } + } + + // Check for keys + + if (this.up && this.up.isDown) + { + this._speedY += this.accelY; + + if (this._speedY > this.maxSpeedY) + { + this._speedY = this.maxSpeedY; + } + } + else if (this.down && this.down.isDown) + { + this._speedY -= this.accelY; + + if (this._speedY < -this.maxSpeedY) + { + this._speedY = -this.maxSpeedY; + } + } + + if (this.left && this.left.isDown) + { + this._speedX += this.accelX; + + if (this._speedX > this.maxSpeedX) + { + this._speedX = this.maxSpeedX; + } + } + else if (this.right && this.right.isDown) + { + this._speedX -= this.accelX; + + if (this._speedX < -this.maxSpeedX) + { + this._speedX = -this.maxSpeedX; + } + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + this._zoom = -this.zoomSpeed; + } + else if (this.zoomOut && this.zoomOut.isDown) + { + this._zoom = this.zoomSpeed; + } + else + { + this._zoom = 0; + } + + // Apply to Camera + + if (this._speedX !== 0) + { + cam.scrollX -= ((this._speedX * delta) | 0); + } + + if (this._speedY !== 0) + { + cam.scrollY -= ((this._speedY * delta) | 0); + } + + if (this._zoom !== 0) + { + cam.zoom += this._zoom; + + if (cam.zoom < this.minZoom) + { + cam.zoom = this.minZoom; + } + else if (cam.zoom > this.maxZoom) + { + cam.zoom = this.maxZoom; + } + } + }, + + /** + * Destroys this Key Control. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = SmoothedKeyControl; + + +/***/ }, + +/***/ 38865 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Controls + */ + +module.exports = { + + FixedKeyControl: __webpack_require__(63091), + SmoothedKeyControl: __webpack_require__(58818) + +}; + + +/***/ }, + +/***/ 26638 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Cameras + */ + +/** + * @namespace Phaser.Types.Cameras + */ + +module.exports = { + + Controls: __webpack_require__(38865), + Scene2D: __webpack_require__(87969) + +}; + + +/***/ }, + +/***/ 8054 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Global constants. + * + * @ignore + */ + +var CONST = { + + /** + * Phaser Release Version + * + * @name Phaser.VERSION + * @const + * @type {string} + * @since 3.0.0 + */ + VERSION: '4.2.1', + + /** + * Phaser Release Version as displayed in the console.log header URL. + * + * @name Phaser.LOG_VERSION + * @const + * @type {string} + * @since 3.87.0 + */ + LOG_VERSION: 'v4021', + + BlendModes: __webpack_require__(10312), + + ScaleModes: __webpack_require__(29795), + + /** + * This setting will auto-detect if the browser is capable of supporting WebGL. + * If it is, it will use the WebGL Renderer. If not, it will fall back to the Canvas Renderer. + * + * @name Phaser.AUTO + * @const + * @type {number} + * @since 3.0.0 + */ + AUTO: 0, + + /** + * Forces Phaser to only use the Canvas Renderer, regardless if the browser supports + * WebGL or not. + * + * @name Phaser.CANVAS + * @const + * @type {number} + * @since 3.0.0 + */ + CANVAS: 1, + + /** + * Forces Phaser to use the WebGL Renderer. If the browser does not support it, there is + * no fallback to Canvas with this setting, so you should trap it and display a suitable + * message to the user. + * + * @name Phaser.WEBGL + * @const + * @type {number} + * @since 3.0.0 + */ + WEBGL: 2, + + /** + * A Headless Renderer doesn't create either a Canvas or WebGL Renderer. However, it still + * absolutely relies on the DOM being present and available. This mode is meant for unit testing, + * not for running Phaser on the server, which is something you really shouldn't do. + * + * @name Phaser.HEADLESS + * @const + * @type {number} + * @since 3.0.0 + */ + HEADLESS: 3, + + /** + * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead + * to help you remember what the value is doing in your code. + * + * @name Phaser.FOREVER + * @const + * @type {number} + * @since 3.0.0 + */ + FOREVER: -1, + + /** + * Direction constant representing no direction, or an unset direction. Used in various + * Phaser systems such as physics and input where a direction value is required but none applies. + * + * @name Phaser.NONE + * @const + * @type {number} + * @since 3.0.0 + */ + NONE: 4, + + /** + * Direction constant representing upward movement or orientation. Used in physics, + * tilemaps, and other Phaser systems that work with cardinal directions. + * + * @name Phaser.UP + * @const + * @type {number} + * @since 3.0.0 + */ + UP: 5, + + /** + * Direction constant representing downward movement or orientation. Used in physics, + * tilemaps, and other Phaser systems that work with cardinal directions. + * + * @name Phaser.DOWN + * @const + * @type {number} + * @since 3.0.0 + */ + DOWN: 6, + + /** + * Direction constant representing leftward movement or orientation. Used in physics, + * tilemaps, and other Phaser systems that work with cardinal directions. + * + * @name Phaser.LEFT + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT: 7, + + /** + * Direction constant representing rightward movement or orientation. Used in physics, + * tilemaps, and other Phaser systems that work with cardinal directions. + * + * @name Phaser.RIGHT + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT: 8 + +}; + +module.exports = CONST; + + +/***/ }, + +/***/ 69547 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(8054); +var DefaultPlugins = __webpack_require__(42363); +var Device = __webpack_require__(82264); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var IsPlainObject = __webpack_require__(41212); +var NOOP = __webpack_require__(29747); +var PhaserMath = __webpack_require__(75508); +var ValueToColor = __webpack_require__(80333); + +/** + * @classdesc + * The active game configuration settings, parsed from a {@link Phaser.Types.Core.GameConfig} object. + * This class takes the raw configuration object passed to `new Phaser.Game()` and resolves all + * values, applying defaults where properties are not specified. The resulting Config instance is + * read-only and available via `game.config`. It controls fundamental aspects of the game including + * canvas dimensions, renderer type, physics settings, audio configuration, and plugin loading. + * + * @class Config + * @memberof Phaser.Core + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Types.Core.GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + * + * @see Phaser.Game#config + */ +var Config = new Class({ + + initialize: + + function Config (config) + { + if (config === undefined) { config = {}; } + + var defaultBannerColor = [ + '#000814', + '#001d3d', + '#003566' + ]; + + var defaultBannerTextColor = '#ffffff'; + + // Scale Manager - Anything set in here over-rides anything set in the core game config + + var scaleConfig = GetValue(config, 'scale', null); + + /** + * @const {(number|string)} Phaser.Core.Config#width - The width of the underlying canvas, in pixels. + */ + this.width = GetValue(scaleConfig, 'width', 1024, config); + + /** + * @const {(number|string)} Phaser.Core.Config#height - The height of the underlying canvas, in pixels. + */ + this.height = GetValue(scaleConfig, 'height', 768, config); + + /** + * @const {(Phaser.Scale.ZoomType|number)} Phaser.Core.Config#zoom - The zoom factor, as used by the Scale Manager. + */ + this.zoom = GetValue(scaleConfig, 'zoom', 1, config); + + /** + * @const {?*} Phaser.Core.Config#parent - A parent DOM element into which the canvas created by the renderer will be injected. + */ + this.parent = GetValue(scaleConfig, 'parent', undefined, config); + + /** + * @const {Phaser.Scale.ScaleModeType} Phaser.Core.Config#scaleMode - The scale mode as used by the Scale Manager. The default is zero, which is no scaling. + */ + this.scaleMode = GetValue(scaleConfig, (scaleConfig) ? 'mode' : 'scaleMode', 0, config); + + /** + * @const {boolean} Phaser.Core.Config#expandParent - Is the Scale Manager allowed to adjust the CSS height property of the parent to be 100%? + */ + this.expandParent = GetValue(scaleConfig, 'expandParent', true, config); + + /** + * @const {boolean} Phaser.Core.Config#autoRound - Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. + */ + this.autoRound = GetValue(scaleConfig, 'autoRound', false, config); + + /** + * @const {Phaser.Scale.CenterType} Phaser.Core.Config#autoCenter - Automatically center the canvas within the parent? + */ + this.autoCenter = GetValue(scaleConfig, 'autoCenter', 0, config); + + /** + * @const {number} Phaser.Core.Config#resizeInterval - How many ms should elapse before checking if the browser size has changed? + */ + this.resizeInterval = GetValue(scaleConfig, 'resizeInterval', 500, config); + + /** + * @const {?(HTMLElement|string)} Phaser.Core.Config#fullscreenTarget - The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. + */ + this.fullscreenTarget = GetValue(scaleConfig, 'fullscreenTarget', null, config); + + /** + * @const {number} Phaser.Core.Config#minWidth - The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + this.minWidth = GetValue(scaleConfig, 'min.width', 0, config); + + /** + * @const {number} Phaser.Core.Config#maxWidth - The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + this.maxWidth = GetValue(scaleConfig, 'max.width', 0, config); + + /** + * @const {number} Phaser.Core.Config#minHeight - The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + this.minHeight = GetValue(scaleConfig, 'min.height', 0, config); + + /** + * @const {number} Phaser.Core.Config#maxHeight - The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + this.maxHeight = GetValue(scaleConfig, 'max.height', 0, config); + + /** + * @const {number} Phaser.Core.Config#snapWidth - The horizontal amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. + */ + this.snapWidth = GetValue(scaleConfig, 'snap.width', 0, config); + + /** + * @const {number} Phaser.Core.Config#snapHeight - The vertical amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. + */ + this.snapHeight = GetValue(scaleConfig, 'snap.height', 0, config); + + /** + * @const {number} Phaser.Core.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) + */ + this.renderType = GetValue(config, 'type', CONST.AUTO); + + /** + * @const {?HTMLCanvasElement} Phaser.Core.Config#canvas - Force Phaser to use your own Canvas element instead of creating one. + */ + this.canvas = GetValue(config, 'canvas', null); + + /** + * @const {?(CanvasRenderingContext2D|WebGLRenderingContext)} Phaser.Core.Config#context - Force Phaser to use your own Canvas context instead of creating one. + */ + this.context = GetValue(config, 'context', null); + + /** + * @const {?string} Phaser.Core.Config#canvasStyle - Optional CSS attributes to be set on the canvas object created by the renderer. + */ + this.canvasStyle = GetValue(config, 'canvasStyle', null); + + /** + * @const {boolean} Phaser.Core.Config#customEnvironment - Is Phaser running under a custom (non-native web) environment? If so, set this to `true` to skip internal Feature detection. If `true` the `renderType` cannot be left as `AUTO`. + */ + this.customEnvironment = GetValue(config, 'customEnvironment', false); + + /** + * @const {?object} Phaser.Core.Config#sceneConfig - The default Scene configuration object. + */ + this.sceneConfig = GetValue(config, 'scene', null); + + /** + * @const {string[]} Phaser.Core.Config#seed - A seed which the Random Data Generator will use. If not given, a dynamic seed based on the time is used. + */ + this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); + + PhaserMath.RND = new PhaserMath.RandomDataGenerator(this.seed); + + /** + * @const {string} Phaser.Core.Config#gameTitle - The title of the game. + */ + this.gameTitle = GetValue(config, 'title', ''); + + /** + * @const {string} Phaser.Core.Config#gameURL - The URL of the game. + */ + this.gameURL = GetValue(config, 'url', 'https://phaser.io/' + CONST.LOG_VERSION); + + /** + * @const {string} Phaser.Core.Config#gameVersion - The version of the game. + */ + this.gameVersion = GetValue(config, 'version', ''); + + /** + * @const {boolean} Phaser.Core.Config#autoFocus - If `true` the window will automatically be given focus immediately and on any future mousedown event. + */ + this.autoFocus = GetValue(config, 'autoFocus', true); + + /** + * @const {(number|boolean)} Phaser.Core.Config#stableSort - `false` or `0` = Use the built-in StableSort (needed for older browsers), `true` or `1` = Rely on ES2019 Array.sort being stable (modern browsers only), or `-1` = Try and determine this automatically based on browser inspection (not guaranteed to work, errs on side of caution). + */ + this.stableSort = GetValue(config, 'stableSort', -1); + + if (this.stableSort === -1) + { + this.stableSort = (Device.browser.es2019) ? 1 : 0; + } + + Device.features.stableSort = this.stableSort; + + // DOM Element Container + + /** + * @const {?boolean} Phaser.Core.Config#domCreateContainer - Should the game create a div element to act as a DOM Container? Only enable if you're using DOM Element objects. You must provide a parent object if you use this feature. + */ + this.domCreateContainer = GetValue(config, 'dom.createContainer', false); + + /** + * @const {?string} Phaser.Core.Config#domPointerEvents - The default `pointerEvents` attribute set on the DOM Container. + */ + this.domPointerEvents = GetValue(config, 'dom.pointerEvents', 'none'); + + // Input + + /** + * @const {boolean} Phaser.Core.Config#inputKeyboard - Enable the Keyboard Plugin. This can be disabled in games that don't need keyboard input. + */ + this.inputKeyboard = GetValue(config, 'input.keyboard', true); + + /** + * @const {*} Phaser.Core.Config#inputKeyboardEventTarget - The DOM Target to listen for keyboard events on. Defaults to `window` if not specified. + */ + this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); + + /** + * @const {?number[]} Phaser.Core.Config#inputKeyboardCapture - `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it is empty. + */ + this.inputKeyboardCapture = GetValue(config, 'input.keyboard.capture', []); + + /** + * @const {(boolean|object)} Phaser.Core.Config#inputMouse - Enable the Mouse Plugin. This can be disabled in games that don't need mouse input. + */ + this.inputMouse = GetValue(config, 'input.mouse', true); + + /** + * @const {?*} Phaser.Core.Config#inputMouseEventTarget - The DOM Target to listen for mouse events on. Defaults to the game canvas if not specified. + */ + this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); + + /** + * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultDown - Should `mousedown` DOM events have `preventDefault` called on them? + */ + this.inputMousePreventDefaultDown = GetValue(config, 'input.mouse.preventDefaultDown', true); + + /** + * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultUp - Should `mouseup` DOM events have `preventDefault` called on them? + */ + this.inputMousePreventDefaultUp = GetValue(config, 'input.mouse.preventDefaultUp', true); + + /** + * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultMove - Should `mousemove` DOM events have `preventDefault` called on them? + */ + this.inputMousePreventDefaultMove = GetValue(config, 'input.mouse.preventDefaultMove', true); + + /** + * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultWheel - Should `wheel` DOM events have `preventDefault` called on them? + */ + this.inputMousePreventDefaultWheel = GetValue(config, 'input.mouse.preventDefaultWheel', true); + + /** + * @const {boolean} Phaser.Core.Config#inputTouch - Enable the Touch Plugin. This can be disabled in games that don't need touch input. + */ + this.inputTouch = GetValue(config, 'input.touch', Device.input.touch); + + /** + * @const {?*} Phaser.Core.Config#inputTouchEventTarget - The DOM Target to listen for touch events on. Defaults to the game canvas if not specified. + */ + this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); + + /** + * @const {boolean} Phaser.Core.Config#inputTouchCapture - Should touch events be captured? I.e. have prevent default called on them. + */ + this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); + + /** + * @const {number} Phaser.Core.Config#inputActivePointers - The number of Pointer objects created by default. In a mouse-only, or non-multi touch game, you can leave this as 1. + */ + this.inputActivePointers = GetValue(config, 'input.activePointers', 1); + + /** + * @const {number} Phaser.Core.Config#inputSmoothFactor - The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. + */ + this.inputSmoothFactor = GetValue(config, 'input.smoothFactor', 0); + + /** + * @const {boolean} Phaser.Core.Config#inputWindowEvents - Should Phaser listen for input events on the Window? If you disable this, events like 'POINTER_UP_OUTSIDE' will no longer fire. + */ + this.inputWindowEvents = GetValue(config, 'input.windowEvents', true); + + /** + * @const {boolean} Phaser.Core.Config#inputGamepad - Enable the Gamepad Plugin. This can be disabled in games that don't need gamepad input. + */ + this.inputGamepad = GetValue(config, 'input.gamepad', false); + + /** + * @const {*} Phaser.Core.Config#inputGamepadEventTarget - The DOM Target to listen for gamepad events on. Defaults to `window` if not specified. + */ + this.inputGamepadEventTarget = GetValue(config, 'input.gamepad.target', window); + + /** + * @const {boolean} Phaser.Core.Config#disableContextMenu - Set to `true` to disable the right-click context menu. + */ + this.disableContextMenu = GetValue(config, 'disableContextMenu', false); + + /** + * @const {Phaser.Types.Core.AudioConfig} Phaser.Core.Config#audio - The Audio Configuration object. + */ + this.audio = GetValue(config, 'audio', {}); + + // If you do: { banner: false } it won't display any banner at all + + /** + * @const {boolean} Phaser.Core.Config#hideBanner - Don't write the banner line to the console.log. See `Phaser.Types.Core.BannerConfig` for details of this object. + */ + this.hideBanner = (GetValue(config, 'banner', null) === false); + + /** + * @const {boolean} Phaser.Core.Config#hidePhaser - Omit Phaser's name and version from the banner. + */ + this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); + + /** + * @const {string} Phaser.Core.Config#bannerTextColor - The color of the banner text. + */ + this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); + + /** + * @const {string[]} Phaser.Core.Config#bannerBackgroundColor - The background colors of the banner. + */ + this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); + + if (this.gameTitle === '' && this.hidePhaser) + { + this.hideBanner = true; + } + + /** + * @const {Phaser.Types.Core.FPSConfig} Phaser.Core.Config#fps - The Frame Rate Configuration object, as parsed by the Timestep class. + */ + this.fps = GetValue(config, 'fps', null); + + // Render Settings - Anything set in here over-rides anything set in the core game config + + var renderConfig = GetValue(config, 'render', null); + + /** + * @const {boolean} Phaser.Core.Config#autoMobileTextures - If iOS or Android detected, automatically restrict WebGL to use 1 texture per batch. This can help performance on some devices. + */ + this.autoMobileTextures = GetValue(renderConfig, 'autoMobileTextures', true, config); + + /** + * @const {boolean} Phaser.Core.Config#antialias - When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + */ + this.antialias = GetValue(renderConfig, 'antialias', true, config); + + /** + * @const {boolean} Phaser.Core.Config#antialiasGL - Sets the `antialias` property when the WebGL context is created. Setting this value does not impact any subsequent textures that are created, or the canvas style attributes. + */ + this.antialiasGL = GetValue(renderConfig, 'antialiasGL', true, config); + + /** + * @const {string} Phaser.Core.Config#mipmapFilter - Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'. + */ + this.mipmapFilter = GetValue(renderConfig, 'mipmapFilter', '', config); + + /** + * @const {boolean} Phaser.Core.Config#mipmapRegeneration - - Whether to regenerate mipmaps for framebuffers. If this is false, framebuffers will not use mipmaps. If this is true, framebuffers will use the `mipmapFilter` setting, and regenerate mipmaps if redrawn. This affects filters and DynamicTextures. Mipmap generation is expensive (10 microseconds or more per texture), so be careful with this setting. + */ + this.mipmapRegeneration = GetValue(renderConfig, 'mipmapRegeneration', false, config); + + /** + * @const {boolean} Phaser.Core.Config#desynchronized - When set to `true` it will create a desynchronized context for both 2D and WebGL. See https://developers.google.com/web/updates/2019/05/desynchronized for details. + */ + this.desynchronized = GetValue(renderConfig, 'desynchronized', false, config); + + /** + * @const {boolean} Phaser.Core.Config#roundPixels - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + */ + this.roundPixels = GetValue(renderConfig, 'roundPixels', false, config); + + /** + * @const {boolean} Phaser.Core.Config#selfShadow - On textured objects with lighting, this enables self-shadowing based on the diffuse map. + */ + this.selfShadow = GetValue(renderConfig, 'selfShadow', false, config); + + /** + * @const {number} Phaser.Core.Config#pathDetailThreshold - Threshold for combining points into a single path in the WebGL renderer for Graphics objects. This can be overridden at the Graphics object level. + */ + this.pathDetailThreshold = GetValue(renderConfig, 'pathDetailThreshold', 1, config); + + /** + * @const {boolean} Phaser.Core.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a nearest-neighbor filter mode). When enabled, this also sets `antialias` and `antialiasGL` to `false` and `roundPixels` to `true`. + */ + this.pixelArt = GetValue(renderConfig, 'pixelArt', false, config); + + if (this.pixelArt) + { + this.antialias = false; + this.antialiasGL = false; + this.roundPixels = true; + } + + /** + * @const {boolean} Phaser.Core.Config#smoothPixelArt - WebGL only. Sets `antialias` to true and `pixelArt` to false. Texture-based Game Objects use special shader setting that preserve blocky pixels, but smooth the edges between the pixels. This is only visible when objects are scaled up; otherwise, `antialias` is simpler. + */ + this.smoothPixelArt = GetValue(renderConfig, 'smoothPixelArt', false, config); + + if (this.smoothPixelArt) + { + this.antialias = true; + this.antialiasGL = true; + this.pixelArt = false; + } + + /** + * @const {boolean} Phaser.Core.Config#transparent - Whether the game canvas will have a transparent background. + */ + this.transparent = GetValue(renderConfig, 'transparent', false, config); + + /** + * @const {'keep'|'dither'|number} Phaser.Core.Config#alphaStrategy - The default alpha strategy to use when rendering transparent objects with compatible shaders. Strategies other than `keep` will discard fragments instead of turning them transparent, which creates a very grainy look. + */ + this.alphaStrategy = GetValue(renderConfig, 'alphaStrategy', 'keep', config); + + /** + * @const {boolean} Phaser.Core.Config#stencil - Whether to enable stencil testing. Disabling this will prevent creation of stencil buffers, which can save framebuffer memory. Disabling stencil prevents the use of stencil-based rendering. + */ + this.stencil = GetValue(renderConfig, 'stencil', true, config); + + /** + * @const {'keep'|'dither'|number} Phaser.Core.Config#stencilAlphaStrategy - The default alpha strategy to use when rendering stencils. Keeping transparent pixels still creates opaque stencil, which is usually not what you want. + */ + this.stencilAlphaStrategy = GetValue(renderConfig, 'stencilAlphaStrategy', 'dither', config); + + /** + * @const {boolean} Phaser.Core.Config#clearBeforeRender - Whether the game canvas will be cleared between each rendering frame. You can disable this if you have a full-screen background image or game object. + */ + this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true, config); + + /** + * @const {boolean} Phaser.Core.Config#preserveDrawingBuffer - If the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author. + */ + this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false, config); + + /** + * @const {boolean} Phaser.Core.Config#premultipliedAlpha - In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha. + */ + this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true, config); + + /** + * @const {boolean} Phaser.Core.Config#skipUnreadyShaders - Avert stuttering during shader compilation, by enabling parallel shader compilation, where supported. Objects which request a shader that is not yet ready will not be drawn. This prevents stutter, but may cause "pop-in" of objects unless you use a pre-touch strategy. + */ + this.skipUnreadyShaders = GetValue(renderConfig, 'skipUnreadyShaders', false, config); + + /** + * @const {boolean} Phaser.Core.Config#failIfMajorPerformanceCaveat - Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + */ + this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false, config); + + /** + * @const {string} Phaser.Core.Config#powerPreference - "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + */ + this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default', config); + + /** + * @const {number} Phaser.Core.Config#batchSize - The default WebGL Batch size. Represents the number of _quads_ that can be added to a single batch. + */ + this.batchSize = GetValue(renderConfig, 'batchSize', 16384, config); + + /** + * @const {number} Phaser.Core.Config#maxTextures - When in WebGL mode, this sets the maximum number of GPU Textures to use. The default, -1, will use all available units. The WebGL1 spec says all browsers should provide a minimum of 8. + */ + this.maxTextures = GetValue(renderConfig, 'maxTextures', -1, config); + + /** + * @const {number} Phaser.Core.Config#maxLights - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + this.maxLights = GetValue(renderConfig, 'maxLights', 10, config); + + /** + * @const {Object} Phaser.Core.Config#renderNodes - A map of custom Render Nodes to be added to the WebGL Renderer. The values will be added to the RenderNodeManager, using the keys as the names. + */ + this.renderNodes = GetValue(renderConfig, 'renderNodes', {}, config); + + var bgc = GetValue(config, 'backgroundColor', 0); + + /** + * @const {Phaser.Display.Color} Phaser.Core.Config#backgroundColor - The background color of the game canvas. The default is black. This value is ignored if `transparent` is set to `true`. + */ + this.backgroundColor = ValueToColor(bgc); + + if (this.transparent) + { + this.backgroundColor = ValueToColor(0x000000); + this.backgroundColor.alpha = 0; + } + + /** + * @const {Phaser.Types.Core.BootCallback} Phaser.Core.Config#preBoot - Called before Phaser boots. Useful for initializing anything not related to Phaser that Phaser may require while booting. + */ + this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); + + /** + * @const {Phaser.Types.Core.BootCallback} Phaser.Core.Config#postBoot - A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. + */ + this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); + + /** + * @const {Phaser.Types.Core.PhysicsConfig} Phaser.Core.Config#physics - The Physics Configuration object. + */ + this.physics = GetValue(config, 'physics', {}); + + /** + * @const {(boolean|string)} Phaser.Core.Config#defaultPhysicsSystem - The default physics system. It will be started for each scene. Either 'arcade' or 'matter'. + */ + this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); + + /** + * @const {string} Phaser.Core.Config#loaderBaseURL - A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + */ + this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); + + /** + * @const {string} Phaser.Core.Config#loaderPath - A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + */ + this.loaderPath = GetValue(config, 'loader.path', ''); + + /** + * @const {number} Phaser.Core.Config#loaderMaxParallelDownloads - The maximum number of files the Loader will attempt to download in parallel. Defaults to 32, or 6 on Android where parallel connections are more constrained. + */ + this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', (Device.os.android) ? 6 : 32); + + /** + * @const {(string|undefined)} Phaser.Core.Config#loaderCrossOrigin - 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + */ + this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); + + /** + * @const {string} Phaser.Core.Config#loaderResponseType - The response type of the XHR request, e.g. `blob`, `text`, etc. + */ + this.loaderResponseType = GetValue(config, 'loader.responseType', ''); + + /** + * @const {boolean} Phaser.Core.Config#loaderAsync - Should the XHR request use async or not? + */ + this.loaderAsync = GetValue(config, 'loader.async', true); + + /** + * @const {string} Phaser.Core.Config#loaderUser - Optional username for all XHR requests. + */ + this.loaderUser = GetValue(config, 'loader.user', ''); + + /** + * @const {string} Phaser.Core.Config#loaderPassword - Optional password for all XHR requests. + */ + this.loaderPassword = GetValue(config, 'loader.password', ''); + + /** + * @const {number} Phaser.Core.Config#loaderTimeout - Optional XHR timeout value, in ms. + */ + this.loaderTimeout = GetValue(config, 'loader.timeout', 0); + + /** + * @const {number} Phaser.Core.Config#loaderMaxRetries - The number of times to retry a file load if it fails. + */ + this.loaderMaxRetries = GetValue(config, 'loader.maxRetries', 2); + + /** + * @const {boolean} Phaser.Core.Config#loaderWithCredentials - Optional XHR withCredentials value. + */ + this.loaderWithCredentials = GetValue(config, 'loader.withCredentials', false); + + /** + * @const {string} Phaser.Core.Config#loaderImageLoadType - Optional load type for image, `XHR` is default, or `HTMLImageElement` for a lightweight way. + */ + this.loaderImageLoadType = GetValue(config, 'loader.imageLoadType', 'XHR'); + + // On iOS, Capacitor often runs on a capacitor:// protocol, meaning local files are served from capacitor:// rather than file:// + // See: https://github.com/photonstorm/phaser/issues/5685 + + /** + * @const {string[]} Phaser.Core.Config#loaderLocalScheme - An array of schemes that the Loader considers as being 'local' files. Defaults to: `[ 'file://', 'capacitor://' ]`. + */ + this.loaderLocalScheme = GetValue(config, 'loader.localScheme', [ 'file://', 'capacitor://' ]); + + /** + * @const {number} Phaser.Core.Config#glowQuality - The quality of the Glow filter (defaults to 10) + */ + this.glowQuality = GetValue(config, 'filters.glow.quality', 10); + + /** + * @const {number} Phaser.Core.Config#glowDistance - The distance of the Glow filter (defaults to 10) + */ + this.glowDistance = GetValue(config, 'filters.glow.distance', 10); + + /* + * Allows `plugins` property to either be an array, in which case it just replaces + * the default plugins like previously, or a config object. + * + * plugins: { + * global: [ + * { key: 'TestPlugin', plugin: TestPlugin, start: true, data: { msg: 'The plugin is alive' } }, + * ], + * scene: [ + * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } + * ], + * default: [], OR + * defaultMerge: [ + * 'ModPlayer' + * ] + * } + */ + + /** + * @const {any} Phaser.Core.Config#installGlobalPlugins - An array of global plugins to be installed. + */ + this.installGlobalPlugins = []; + + /** + * @const {any} Phaser.Core.Config#installScenePlugins - An array of Scene level plugins to be installed. + */ + this.installScenePlugins = []; + + var plugins = GetValue(config, 'plugins', null); + var defaultPlugins = DefaultPlugins.DefaultScene; + + if (plugins) + { + // Old 3.7 array format? + if (Array.isArray(plugins)) + { + this.defaultPlugins = plugins; + } + else if (IsPlainObject(plugins)) + { + this.installGlobalPlugins = GetFastValue(plugins, 'global', []); + this.installScenePlugins = GetFastValue(plugins, 'scene', []); + + if (Array.isArray(plugins.default)) + { + defaultPlugins = plugins.default; + } + else if (Array.isArray(plugins.defaultMerge)) + { + defaultPlugins = defaultPlugins.concat(plugins.defaultMerge); + } + } + } + + /** + * @const {any} Phaser.Core.Config#defaultPlugins - The plugins installed into every Scene (in addition to CoreScene and Global). + */ + this.defaultPlugins = defaultPlugins; + + // Default / Missing Images + var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; + + /** + * @const {string} Phaser.Core.Config#defaultImage - A base64 encoded PNG that will be used as the default blank texture. + */ + this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); + + /** + * @const {string} Phaser.Core.Config#missingImage - A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded. + */ + this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); + + /** + * @const {string} Phaser.Core.Config#whiteImage - A base64 encoded PNG used as the default solid white texture. This small 4x4 white image is used internally by Phaser for colored Game Objects and tinting. + */ + this.whiteImage = GetValue(config, 'images.white', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpi/P//PwMMMDEgAdwcgAADAJZuAwXJYZOzAAAAAElFTkSuQmCC'); + + if (window) + { + if (window.FORCE_WEBGL) + { + this.renderType = CONST.WEBGL; + } + else if (window.FORCE_CANVAS) + { + this.renderType = CONST.CANVAS; + } + } + } + +}); + +module.exports = Config; + + +/***/ }, + +/***/ 86054 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CanvasInterpolation = __webpack_require__(20623); +var CanvasPool = __webpack_require__(27919); +var CONST = __webpack_require__(8054); +var Features = __webpack_require__(89357); + +/** + * Called automatically by Phaser.Game and responsible for creating the renderer it will use. + * + * Inspects the game configuration to determine the appropriate render type (WebGL, Canvas, or Headless), + * validates that the chosen renderer is supported by the current device, sets up the canvas element + * (either adopting one provided in the game config or creating a new one from the CanvasPool), applies + * any canvas CSS styles and pixel art interpolation settings, then instantiates and assigns the renderer + * to `game.renderer`. + * + * Relies upon two webpack global flags, `WEBGL_RENDERER` and `CANVAS_RENDERER`, which are defined at + * build time and inlined into the bundle as compile-time constants. They are not available as runtime + * variables and determine which renderer classes are included in the build. + * + * @function Phaser.Core.CreateRenderer + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. + */ +var CreateRenderer = function (game) +{ + var config = game.config; + + if ((config.customEnvironment || config.canvas) && config.renderType === CONST.AUTO) + { + throw new Error('Must set explicit renderType in custom environment'); + } + + // Not a custom environment, didn't provide their own canvas and not headless, so determine the renderer: + if (!config.customEnvironment && !config.canvas && config.renderType !== CONST.HEADLESS) + { + if (config.renderType === CONST.AUTO) + { + config.renderType = Features.webGL ? CONST.WEBGL : CONST.CANVAS; + } + + if (config.renderType === CONST.WEBGL) + { + if (!Features.webGL) { throw new Error('Cannot create WebGL context, aborting.'); } + } + else if (config.renderType === CONST.CANVAS) + { + if (!Features.canvas) { throw new Error('Cannot create Canvas context, aborting.'); } + } + else + { + throw new Error('Unknown value for renderer type: ' + config.renderType); + } + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasPool.disableSmoothing(); + } + + var baseSize = game.scale.baseSize; + + var width = baseSize.width; + var height = baseSize.height; + + // Does the game config provide its own canvas element to use? + if (config.canvas) + { + game.canvas = config.canvas; + + game.canvas.width = width; + game.canvas.height = height; + } + else + { + game.canvas = CanvasPool.create(game, width, height, config.renderType); + } + + // Does the game config provide some canvas css styles to use? + if (config.canvasStyle) + { + game.canvas.style = config.canvasStyle; + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasInterpolation.setCrisp(game.canvas); + } + + if (config.renderType === CONST.HEADLESS) + { + // Nothing more to do here + return; + } + + var CanvasRenderer; + var WebGLRenderer; + + if (true) + { + CanvasRenderer = __webpack_require__(68627); + WebGLRenderer = __webpack_require__(74797); + + // Let the config pick the renderer type, as both are included + if (config.renderType === CONST.WEBGL) + { + game.renderer = new WebGLRenderer(game); + } + else + { + game.renderer = new CanvasRenderer(game); + game.context = game.renderer.gameContext; + } + } + + if (false) + // removed by dead control flow +{} + + if (false) + // removed by dead control flow +{} +}; + +module.exports = CreateRenderer; + + +/***/ }, + +/***/ 96391 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(8054); + +/** + * Called automatically by Phaser.Game during initialization to output a styled banner to the browser + * console. The banner displays the Phaser version number, the active renderer (WebGL, Canvas, or + * Headless), the audio system in use (Web Audio, HTML5 Audio, or No Audio), and optionally the + * game title, version, and URL as configured. In browsers that support CSS console styling the + * banner is rendered with the colors defined in the Game Config; in IE it falls back to a plain + * text log. The banner is skipped entirely when `config.hideBanner` is `true`. + * + * You can customize or disable the header via the Game Config object. + * + * @function Phaser.Core.DebugHeader + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. + */ +var DebugHeader = function (game) +{ + var config = game.config; + + if (config.hideBanner) + { + return; + } + + var renderType = 'WebGL'; + + if (config.renderType === CONST.CANVAS) + { + renderType = 'Canvas'; + } + else if (config.renderType === CONST.HEADLESS) + { + renderType = 'Headless'; + } + + var audioConfig = config.audio; + var deviceAudio = game.device.audio; + + var audioType; + + if (deviceAudio.webAudio && !audioConfig.disableWebAudio) + { + audioType = 'Web Audio'; + } + else if (audioConfig.noAudio || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + audioType = 'No Audio'; + } + else + { + audioType = 'HTML5 Audio'; + } + + if (!game.device.browser.ie) + { + var logoDataURI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAARBJREFUeNpi/P//P0OHsPB/BiCoePuWkYFEwALSXJElzMBgLwE2CNkQxgWr/yMr/p8QimlBu5DQ//+8vBBco/ofzAe6imH+qv/53/6jYJAYSA4ZoxoANYTPKhiuCQZwGcJU+e4dqpMmvsDq14krV2MPAxDha2CMKvoXoiE/PBQUDgQD8j82UFae9B9bOIC8B9UD9gIjjIMN7Ns6lWHn4XMoYu62RgxO3tkMjIyMII2MYAOAtmFVhA+ADHf2ycGMRhANjUq8YO+WKWCvgAORIV8CkpDCrzIwsLIymC1qAtuAD4Bsh3sBmqAY3qcGwL2AC4DCpKtzHlgzOLWihwEuzTCN0GhDJHeYC4gByBphACDAAH2dDIxdjr+VAAAAAElFTkSuQmCC'; + + var mainStyle = 'color: ' + config.bannerTextColor + ';'; + + var bannerBackgroundColor = Array.isArray(config.bannerBackgroundColor) + ? config.bannerBackgroundColor + : [ config.bannerBackgroundColor ]; + + // linear-gradient requires at least two color stops, so duplicate if there's only one + if (bannerBackgroundColor.length === 1) + { + bannerBackgroundColor = [ bannerBackgroundColor[0], bannerBackgroundColor[0] ]; + } + + var gradient = 'linear-gradient(to bottom, ' + bannerBackgroundColor.join(', ') + ')'; + + mainStyle += ' background-image: url("' + logoDataURI + '"), ' + gradient + ';'; + mainStyle += ' background-repeat: no-repeat;'; + mainStyle += ' background-position: 4px center, 0 0;'; + + mainStyle += ' padding: 2px 6px 2px 24px;'; + + var c = '%c'; + var args = [ null, mainStyle ]; + + // URL link background color (always transparent to support different browser themes) + args.push('background: transparent'); + + if (config.gameTitle) + { + c = c.concat(config.gameTitle); + + if (config.gameVersion) + { + c = c.concat(' v' + config.gameVersion); + } + + if (!config.hidePhaser) + { + c = c.concat(' / '); + } + } + + if (!config.hidePhaser) + { + c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); + } + + c = c.concat('%c ' + config.gameURL); + + // Inject the new string back into the args array + args[0] = c; + + console.log.apply(console, args); + } + else if (window['console']) + { + console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); + } +}; + +module.exports = DebugHeader; + + +/***/ }, + +/***/ 50127 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AddToDOM = __webpack_require__(40366); +var AnimationManager = __webpack_require__(60848); +var CacheManager = __webpack_require__(24047); +var CanvasPool = __webpack_require__(27919); +var Class = __webpack_require__(83419); +var Config = __webpack_require__(69547); +var CreateDOMContainer = __webpack_require__(83719); +var CreateRenderer = __webpack_require__(86054); +var DataManager = __webpack_require__(45893); +var DebugHeader = __webpack_require__(96391); +var Device = __webpack_require__(82264); +var DOMContentLoaded = __webpack_require__(57264); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(8443); +var InputManager = __webpack_require__(7003); +var PluginCache = __webpack_require__(37277); +var PluginManager = __webpack_require__(77332); +var ScaleManager = __webpack_require__(76531); +var SceneManager = __webpack_require__(60903); +var TextureEvents = __webpack_require__(69442); +var TextureManager = __webpack_require__(17130); +var TimeStep = __webpack_require__(65898); +var VisibilityHandler = __webpack_require__(51085); + +if (true) +{ + var SoundManagerCreator = __webpack_require__(14747); +} + +/** + * @classdesc + * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the global Phaser systems, such as sound and input. + * Once that is complete it will start the Scene Manager and then begin the main game loop. + * + * You should generally avoid accessing any of the systems created by Game, and instead use those + * made available to you via the Phaser.Scene Systems class instead. + * + * @class Game + * @memberof Phaser + * @constructor + * @fires Phaser.Core.Events#BLUR + * @fires Phaser.Core.Events#FOCUS + * @fires Phaser.Core.Events#HIDDEN + * @fires Phaser.Core.Events#VISIBLE + * @since 3.0.0 + * + * @param {Phaser.Types.Core.GameConfig} [config] - The configuration object for your Phaser Game instance. + */ +var Game = new Class({ + + initialize: + + function Game (config) + { + /** + * The parsed Game Configuration object. + * + * The values stored within this object are read-only and should not be changed at run-time. + * + * @name Phaser.Game#config + * @type {Phaser.Core.Config} + * @readonly + * @since 3.0.0 + */ + this.config = new Config(config); + + /** + * A reference to either the Canvas or WebGL Renderer that this Game is using. + * + * @name Phaser.Game#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = null; + + /** + * A reference to an HTML Div Element used as the DOM Element Container. + * + * Only set if `createDOMContainer` is `true` in the game config (by default it is `false`) and + * if you provide a parent element to insert the Phaser Game inside. + * + * See the DOM Element Game Object for more details. + * + * @name Phaser.Game#domContainer + * @type {HTMLDivElement} + * @since 3.17.0 + */ + this.domContainer = null; + + /** + * A reference to the HTML Canvas Element that Phaser uses to render the game. + * This is created automatically by Phaser unless you provide a `canvas` property + * in your Game Config. + * + * @name Phaser.Game#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = null; + + /** + * A reference to the Rendering Context belonging to the Canvas Element this game is rendering to. + * If the game is running under Canvas it will be a 2d Canvas Rendering Context. + * If the game is running under WebGL it will be a WebGL Rendering Context. + * This context is created automatically by Phaser unless you provide a `context` property + * in your Game Config. + * + * @name Phaser.Game#context + * @type {(CanvasRenderingContext2D|WebGLRenderingContext)} + * @since 3.0.0 + */ + this.context = null; + + /** + * A flag indicating when this Game instance has finished its boot process. + * + * @name Phaser.Game#isBooted + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isBooted = false; + + /** + * A flag indicating if this Game is currently running its game step or not. + * + * @name Phaser.Game#isRunning + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * An Event Emitter which is used to broadcast game-level events from the global systems. + * + * @name Phaser.Game#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * An instance of the Animation Manager. + * + * The Animation Manager is a global system responsible for managing all animations used within your game. + * + * @name Phaser.Game#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims = new AnimationManager(this); + + /** + * An instance of the Texture Manager. + * + * The Texture Manager is a global system responsible for managing all textures being used by your game. + * + * @name Phaser.Game#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures = new TextureManager(this); + + /** + * An instance of the Cache Manager. + * + * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. + * + * @name Phaser.Game#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache = new CacheManager(this); + + /** + * An instance of the Data Manager. This is a global manager, available from any Scene + * and allows you to share and exchange your own game-level data or events without having + * to use an internal event system. + * + * @name Phaser.Game#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry = new DataManager(this, new EventEmitter()); + + /** + * An instance of the Input Manager. + * + * The Input Manager is a global system responsible for the capture of browser-level input events. + * + * @name Phaser.Game#input + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.input = new InputManager(this, this.config); + + /** + * An instance of the Scene Manager. + * + * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. + * + * @name Phaser.Game#scene + * @type {Phaser.Scenes.SceneManager} + * @since 3.0.0 + */ + this.scene = new SceneManager(this, this.config.sceneConfig); + + /** + * A reference to the Device inspector. + * + * Contains information about the device running this game, such as OS, browser vendor and feature support. + * Used by various systems to determine capabilities and code paths. + * + * @name Phaser.Game#device + * @type {Phaser.DeviceConf} + * @since 3.0.0 + */ + this.device = Device; + + /** + * An instance of the Scale Manager. + * + * The Scale Manager is a global system responsible for handling scaling of the game canvas. + * + * @name Phaser.Game#scale + * @type {Phaser.Scale.ScaleManager} + * @since 3.16.0 + */ + this.scale = new ScaleManager(this, this.config); + + /** + * An instance of the base Sound Manager. + * + * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. + * + * You can disable the inclusion of the Sound Manager in your build by toggling the webpack `FEATURE_SOUND` flag. + * + * @name Phaser.Game#sound + * @type {(Phaser.Sound.NoAudioSoundManager|Phaser.Sound.HTML5AudioSoundManager|Phaser.Sound.WebAudioSoundManager)} + * @since 3.0.0 + */ + this.sound = null; + + if (true) + { + this.sound = SoundManagerCreator.create(this); + } + + /** + * An instance of the Time Step. + * + * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing + * them and calculating delta values. It then automatically calls the game step. + * + * @name Phaser.Game#loop + * @type {Phaser.Core.TimeStep} + * @since 3.0.0 + */ + this.loop = new TimeStep(this, this.config.fps); + + /** + * An instance of the Plugin Manager. + * + * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install + * those plugins into Scenes as required. + * + * @name Phaser.Game#plugins + * @type {Phaser.Plugins.PluginManager} + * @since 3.0.0 + */ + this.plugins = new PluginManager(this, this.config); + + /** + * Is this Game pending destruction at the start of the next frame? + * + * @name Phaser.Game#pendingDestroy + * @type {boolean} + * @private + * @since 3.5.0 + */ + this.pendingDestroy = false; + + /** + * Remove the Canvas once the destroy is over? + * + * @name Phaser.Game#removeCanvas + * @type {boolean} + * @private + * @since 3.5.0 + */ + this.removeCanvas = false; + + /** + * Remove everything when the game is destroyed. + * You cannot create a new Phaser instance on the same web page after doing this. + * + * @name Phaser.Game#noReturn + * @type {boolean} + * @private + * @since 3.12.0 + */ + this.noReturn = false; + + /** + * Does the window the game is running in currently have focus or not? + * This is modified by the VisibilityHandler. + * + * @name Phaser.Game#hasFocus + * @type {boolean} + * @readonly + * @since 3.9.0 + */ + this.hasFocus = false; + + /** + * Is the Game currently paused? This will stop everything from updating, + * except the `TimeStep` and related RequestAnimationFrame or setTimeout. + * Those will continue stepping, but the core Game step will be skipped. + * + * @name Phaser.Game#isPaused + * @type {boolean} + * @since 3.60.0 + */ + this.isPaused = false; + + // Wait for the DOM Ready event, then call boot. + DOMContentLoaded(this.boot.bind(this)); + }, + + /** + * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, + * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. + * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. + * + * @method Phaser.Game#boot + * @protected + * @fires Phaser.Core.Events#BOOT + * @listens Phaser.Textures.Events#READY + * @since 3.0.0 + */ + boot: function () + { + if (!PluginCache.hasCore('EventEmitter')) + { + console.warn('Aborting. Core Plugins missing.'); + return; + } + + this.isBooted = true; + + this.config.preBoot(this); + + this.scale.preBoot(); + + CreateRenderer(this); + + CreateDOMContainer(this); + + DebugHeader(this); + + AddToDOM(this.canvas, this.config.parent); + + // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready. + // So it will emit this internal event when done: + this.textures.once(TextureEvents.READY, this.texturesReady, this); + + this.events.emit(Events.BOOT); + + if (false) + // removed by dead control flow +{} + }, + + /** + * Called automatically when the Texture Manager has finished setting up and preparing the + * default textures. + * + * @method Phaser.Game#texturesReady + * @private + * @fires Phaser.Core.Events#READY + * @since 3.12.0 + */ + texturesReady: function () + { + // Start all the other systems + this.events.emit(Events.READY); + + this.start(); + }, + + /** + * Called automatically by Game.boot once all of the global systems have finished setting themselves up. + * By this point the Game is now ready to start the main loop running. + * It will also enable the Visibility Handler. + * + * @method Phaser.Game#start + * @protected + * @since 3.0.0 + */ + start: function () + { + this.isRunning = true; + + this.config.postBoot(this); + + if (this.renderer) + { + this.loop.start(this.step.bind(this)); + } + else + { + this.loop.start(this.headlessStep.bind(this)); + } + + VisibilityHandler(this); + + var eventEmitter = this.events; + + eventEmitter.on(Events.HIDDEN, this.onHidden, this); + eventEmitter.on(Events.VISIBLE, this.onVisible, this); + eventEmitter.on(Events.BLUR, this.onBlur, this); + eventEmitter.on(Events.FOCUS, this.onFocus, this); + }, + + /** + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. + * + * @method Phaser.Game#step + * @fires Phaser.Core.Events#PRE_STEP + * @fires Phaser.Core.Events#STEP + * @fires Phaser.Core.Events#POST_STEP + * @fires Phaser.Core.Events#PRE_RENDER + * @fires Phaser.Core.Events#POST_RENDER + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + step: function (time, delta) + { + if (this.pendingDestroy) + { + return this.runDestroy(); + } + + if (this.isPaused) + { + return; + } + + var eventEmitter = this.events; + + // Global Managers like Input and Sound update in the prestep + + eventEmitter.emit(Events.PRE_STEP, time, delta); + + // This is mostly meant for user-land code and plugins + + eventEmitter.emit(Events.STEP, time, delta); + + // Update the Scene Manager and all active Scenes + + this.scene.update(time, delta); + + // Our final event before rendering starts + + eventEmitter.emit(Events.POST_STEP, time, delta); + + var renderer = this.renderer; + + // Run the Pre-render (clearing the canvas, setting background colors, etc) + + renderer.preRender(); + + eventEmitter.emit(Events.PRE_RENDER, renderer, time, delta); + + // The main render loop. Iterates all Scenes and all Cameras in those scenes, rendering to the renderer instance. + + this.scene.render(renderer); + + // The Post-Render call. Tidies up loose end, takes snapshots, etc. + + renderer.postRender(); + + // The final event before the step repeats. Your last chance to do anything to the canvas before it all starts again. + + eventEmitter.emit(Events.POST_RENDER, renderer, time, delta); + }, + + /** + * A special version of the Game Step for the HEADLESS renderer only. + * + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * This process emits `prerender` and `postrender` events, even though nothing actually displays. + * + * @method Phaser.Game#headlessStep + * @fires Phaser.Core.Events#PRE_RENDER + * @fires Phaser.Core.Events#POST_RENDER + * @since 3.2.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + headlessStep: function (time, delta) + { + if (this.pendingDestroy) + { + return this.runDestroy(); + } + + if (this.isPaused) + { + return; + } + + var eventEmitter = this.events; + + // Global Managers like Input and Sound update in the prestep + + eventEmitter.emit(Events.PRE_STEP, time, delta); + + // This is mostly meant for user-land code and plugins + + eventEmitter.emit(Events.STEP, time, delta); + + // Update the Scene Manager and all active Scenes + + this.scene.update(time, delta); + + // Our final event before rendering starts + + eventEmitter.emit(Events.POST_STEP, time, delta); + + // Render + this.scene.isProcessing = false; + + eventEmitter.emit(Events.PRE_RENDER, null, time, delta); + + eventEmitter.emit(Events.POST_RENDER, null, time, delta); + }, + + /** + * Called automatically by the Visibility Handler. + * This will pause the main loop and then emit a pause event. + * + * @method Phaser.Game#onHidden + * @protected + * @fires Phaser.Core.Events#PAUSE + * @since 3.0.0 + */ + onHidden: function () + { + this.loop.pause(); + + this.events.emit(Events.PAUSE); + }, + + /** + * This will pause the entire game and emit a `PAUSE` event. + * + * All of Phaser's internal systems will be paused and the game will not re-render. + * + * Note that it does not pause any Loader requests that are currently in-flight. + * + * @method Phaser.Game#pause + * @fires Phaser.Core.Events#PAUSE + * @since 3.60.0 + */ + pause: function () + { + var wasPaused = this.isPaused; + + this.isPaused = true; + + if (!wasPaused) + { + this.events.emit(Events.PAUSE); + } + }, + + /** + * Called automatically by the Visibility Handler. + * This will resume the main loop and then emit a resume event. + * + * @method Phaser.Game#onVisible + * @protected + * @fires Phaser.Core.Events#RESUME + * @since 3.0.0 + */ + onVisible: function () + { + this.loop.resume(); + + this.events.emit(Events.RESUME, this.loop.pauseDuration); + }, + + /** + * This will resume the entire game and emit a `RESUME` event. + * + * All of Phaser's internal systems will be resumed and the game will start rendering again. + * + * @method Phaser.Game#resume + * @fires Phaser.Core.Events#RESUME + * @since 3.60.0 + */ + resume: function () + { + var wasPaused = this.isPaused; + + this.isPaused = false; + + if (wasPaused) + { + this.events.emit(Events.RESUME, 0); + } + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'blurred' state, which pauses it. + * + * @method Phaser.Game#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.hasFocus = false; + + this.loop.blur(); + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'focused' state, which resumes it. + * + * @method Phaser.Game#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.hasFocus = true; + + this.loop.focus(); + }, + + /** + * Returns the current game frame. + * + * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. + * + * @method Phaser.Game#getFrame + * @since 3.16.0 + * + * @return {number} The current game frame. + */ + getFrame: function () + { + return this.loop.frame; + }, + + /** + * Returns the time that the current game step started at, as based on `performance.now`. + * + * @method Phaser.Game#getTime + * @since 3.16.0 + * + * @return {number} The current game timestamp. + */ + getTime: function () + { + return this.loop.now; + }, + + /** + * Flags this Game instance as needing to be destroyed on the _next frame_, making this an asynchronous operation. + * + * It will wait until the current frame has completed and then call `runDestroy` internally. + * + * If you need to react to the game's eventual destruction, listen for the `DESTROY` event. + * + * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free up + * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. + * + * @method Phaser.Game#destroy + * @fires Phaser.Core.Events#DESTROY + * @since 3.0.0 + * + * @param {boolean} removeCanvas - Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. + * @param {boolean} [noReturn=false] - If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. + */ + destroy: function (removeCanvas, noReturn) + { + if (noReturn === undefined) { noReturn = false; } + + this.pendingDestroy = true; + + this.removeCanvas = removeCanvas; + this.noReturn = noReturn; + }, + + /** + * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. + * + * @method Phaser.Game#runDestroy + * @private + * @since 3.5.0 + */ + runDestroy: function () + { + this.scene.destroy(); + + this.events.emit(Events.DESTROY); + + this.events.removeAllListeners(); + + if (this.renderer) + { + this.renderer.destroy(); + } + + if (this.removeCanvas && this.canvas) + { + CanvasPool.remove(this.canvas); + + if (this.canvas.parentNode) + { + this.canvas.parentNode.removeChild(this.canvas); + } + } + + if (this.domContainer && this.domContainer.parentNode) + { + this.domContainer.parentNode.removeChild(this.domContainer); + } + + this.loop.destroy(); + + this.pendingDestroy = false; + } + +}); + +module.exports = Game; + +/** + * "Computers are good at following instructions, but not at reading your mind." - Donald Knuth + */ + + +/***/ }, + +/***/ 65898 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var GetValue = __webpack_require__(35154); +var NOOP = __webpack_require__(29747); +var RequestAnimationFrame = __webpack_require__(43092); + +// http://www.testufo.com/#test=animation-time-graph + +/** + * @classdesc + * The core runner class that Phaser uses to handle the game loop. It can use either Request Animation Frame, + * or SetTimeout, based on browser support and config settings, to create a continuous loop within the browser. + * + * Each time the loop fires, `TimeStep.step` is called and this is then passed onto the core Game update loop, + * it is the core heartbeat of your game. It will fire as often as Request Animation Frame is capable of handling + * on the target device. + * + * Note that there are lots of situations where a browser will stop updating your game. Such as if the player + * switches tabs, or covers up the browser window with another application. In these cases, the 'heartbeat' + * of your game will pause, and only resume when focus is returned to it by the player. There is no way to avoid + * this situation, all you can do is use the visibility events the browser, and Phaser, provide to detect when + * it has happened and then gracefully recover. + * + * @class TimeStep + * @memberof Phaser.Core + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. + * @param {Phaser.Types.Core.FPSConfig} config - The FPS configuration object, as parsed by the Game Config. + */ +var TimeStep = new Class({ + + initialize: + + function TimeStep (game, config) + { + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.Core.TimeStep#game + * @type {Phaser.Game} + * @readonly + * @since 3.0.0 + */ + this.game = game; + + /** + * The Request Animation Frame DOM Event handler. + * + * @name Phaser.Core.TimeStep#raf + * @type {Phaser.DOM.RequestAnimationFrame} + * @readonly + * @since 3.0.0 + */ + this.raf = new RequestAnimationFrame(); + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * + * @name Phaser.Core.TimeStep#started + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.started = false; + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * The difference between this value and `started` is that `running` is toggled when + * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if + * the TimeStep is actually stopped, not just paused. + * + * @name Phaser.Core.TimeStep#running + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.running = false; + + /** + * The minimum fps rate you want the Time Step to run at. + * + * Setting this cannot guarantee the browser runs at this rate, it merely influences + * the internal timing values to help the Timestep know when it has gone out of sync. + * + * @name Phaser.Core.TimeStep#minFps + * @type {number} + * @default 5 + * @since 3.0.0 + */ + this.minFps = GetValue(config, 'min', 5); + + /** + * The target fps rate for the Time Step to run at. + * + * Setting this value will not actually change the speed at which the browser runs, that is beyond + * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step + * is spiraling out of control. + * + * @name Phaser.Core.TimeStep#targetFps + * @type {number} + * @default 60 + * @since 3.0.0 + */ + this.targetFps = GetValue(config, 'target', 60); + + /** + * Enforce a frame rate limit. This forces how often the Game step will run. By default it is zero, + * which means it will run at whatever limit the browser (via RequestAnimationFrame) can handle, which + * is the optimum rate for fast-action or responsive games. + * + * However, if you are building a non-game app, like a graphics generator, or low-intensity game that doesn't + * require 60fps, then you can lower the step rate via this Game Config value: + * + * ```js + * fps: { + * limit: 30 + * } + * ``` + * + * Setting this _beyond_ the rate of RequestAnimationFrame will make no difference at all. + * + * Use it purely to _restrict_ updates in low-intensity situations only. + * + * You can change the FPS limit at any time by calling + * `TimeStep.setFPSLimit(limit)`. + * This will update the `fpsLimit`, `hasFpsLimit` and `_limitRate` properties. + * + * @name Phaser.Core.TimeStep#fpsLimit + * @type {number} + * @default 0 + * @readonly + * @since 3.60.0 + */ + this.fpsLimit = GetValue(config, 'limit', 0); + + /** + * Is the FPS rate limited? + * + * This is set by setting the Game Config `limit` value to a value above zero. + * + * Consider this property as read-only. + * + * @name Phaser.Core.TimeStep#hasFpsLimit + * @type {boolean} + * @default false + * @readonly + * @since 3.60.0 + */ + this.hasFpsLimit = (this.fpsLimit > 0); + + /** + * Internal value holding the fps rate limit in ms. + * + * @name Phaser.Core.TimeStep#_limitRate + * @type {number} + * @private + * @readonly + * @since 3.60.0 + */ + this._limitRate = (this.hasFpsLimit) ? (1000 / this.fpsLimit) : 0; + + /** + * The minimum fps value in ms. + * + * Defaults to 200ms between frames (i.e. super slow!) + * + * @name Phaser.Core.TimeStep#_min + * @type {number} + * @private + * @since 3.0.0 + */ + this._min = 1000 / this.minFps; + + /** + * The target fps value in ms. + * + * Defaults to 16.66ms between frames (i.e. normal) + * + * @name Phaser.Core.TimeStep#_target + * @type {number} + * @private + * @since 3.0.0 + */ + this._target = 1000 / this.targetFps; + + /** + * An exponential moving average of the frames per second. + * + * @name Phaser.Core.TimeStep#actualFps + * @type {number} + * @readonly + * @default 60 + * @since 3.0.0 + */ + this.actualFps = this.targetFps; + + /** + * The time at which the next fps rate update will take place. + * + * When an fps update happens, the `framesThisSecond` value is reset. + * + * @name Phaser.Core.TimeStep#nextFpsUpdate + * @type {number} + * @readonly + * @default 0 + * @since 3.0.0 + */ + this.nextFpsUpdate = 0; + + /** + * The number of frames processed this second. + * + * @name Phaser.Core.TimeStep#framesThisSecond + * @type {number} + * @readonly + * @default 0 + * @since 3.0.0 + */ + this.framesThisSecond = 0; + + /** + * A callback to be invoked each time the TimeStep steps. + * + * @name Phaser.Core.TimeStep#callback + * @type {Phaser.Types.Core.TimeStepCallback} + * @default NOOP + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * You can force the TimeStep to use SetTimeOut instead of Request Animation Frame by setting + * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. + * + * @name Phaser.Core.TimeStep#forceSetTimeOut + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); + + /** + * The time, updated each step by adding the elapsed delta time to the previous value. + * + * This differs from the `TimeStep.now` value, which is the high resolution time value + * as provided by Request Animation Frame. + * + * @name Phaser.Core.TimeStep#time + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.time = 0; + + /** + * The time at which the game started running. + * + * This value is adjusted if the game is then paused and resumes. + * + * @name Phaser.Core.TimeStep#startTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * The time of the previous step. + * + * This is typically a high resolution timer value, as provided by Request Animation Frame. + * + * @name Phaser.Core.TimeStep#lastTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + /** + * The current frame the game is on. This counter is incremented once every game step, regardless of how much + * time has passed and is unaffected by delta smoothing. + * + * @name Phaser.Core.TimeStep#frame + * @type {number} + * @readonly + * @default 0 + * @since 3.0.0 + */ + this.frame = 0; + + /** + * Is the browser currently considered in focus by the Page Visibility API? + * + * This value is set in the `blur` method, which is called automatically by the Game instance. + * + * @name Phaser.Core.TimeStep#inFocus + * @type {boolean} + * @readonly + * @default true + * @since 3.0.0 + */ + this.inFocus = true; + + /** + * The duration of the most recent game pause, if any, in ms. + * + * @name Phaser.Core.TimeStep#pauseDuration + * @type {number} + * @readonly + * @default 0 + * @since 3.85.0 + */ + this.pauseDuration = 0; + + /** + * The timestamp at which the game became paused, as determined by the Page Visibility API. + * + * @name Phaser.Core.TimeStep#_pauseTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pauseTime = 0; + + /** + * An internal counter to allow for the browser 'cooling down' after coming back into focus. + * + * @name Phaser.Core.TimeStep#_coolDown + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._coolDown = 0; + + /** + * The delta time, in ms, since the last game step. This is a clamped and smoothed average value. + * + * @name Phaser.Core.TimeStep#delta + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.delta = 0; + + /** + * Internal index of the delta history position. + * + * @name Phaser.Core.TimeStep#deltaIndex + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.deltaIndex = 0; + + /** + * Internal array holding the previous delta values, used for delta smoothing. + * + * @name Phaser.Core.TimeStep#deltaHistory + * @type {number[]} + * @since 3.0.0 + */ + this.deltaHistory = []; + + /** + * The maximum number of delta values that are retained in order to calculate a smoothed moving average. + * + * This can be changed in the Game Config via the `fps.deltaHistory` property. The default is 10. + * + * @name Phaser.Core.TimeStep#deltaSmoothingMax + * @type {number} + * @default 10 + * @since 3.0.0 + */ + this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); + + /** + * The number of frames that the cooldown is set to after the browser panics over the FPS rate, usually + * as a result of switching tabs and regaining focus. + * + * This can be changed in the Game Config via the `fps.panicMax` property. The default is 120. + * + * @name Phaser.Core.TimeStep#panicMax + * @type {number} + * @default 120 + * @since 3.0.0 + */ + this.panicMax = GetValue(config, 'panicMax', 120); + + /** + * The actual elapsed time in ms between one update and the next. + * + * Unlike with `delta`, no smoothing, capping, or averaging is applied to this value. + * So please be careful when using this value in math calculations. + * + * @name Phaser.Core.TimeStep#rawDelta + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rawDelta = 0; + + /** + * The time, set at the start of the current step. + * + * This is typically a high resolution timer value, as provided by Request Animation Frame. + * + * This can differ from the `time` value in that it isn't calculated based on the delta value. + * + * @name Phaser.Core.TimeStep#now + * @type {number} + * @default 0 + * @since 3.18.0 + */ + this.now = 0; + + /** + * Apply smoothing to the delta value used within Phaser's internal calculations? + * + * This can be changed in the Game Config via the `fps.smoothStep` property. The default is `true`. + * + * Smoothing helps settle down the delta values after browser tab switches, or other situations + * which could cause significant delta spikes or dips. By default it has been enabled in Phaser 3 + * since the first version, but is now exposed under this property (and the corresponding game config + * `smoothStep` value), to allow you to easily disable it, should you require. + * + * @name Phaser.Core.TimeStep#smoothStep + * @type {boolean} + * @since 3.22.0 + */ + this.smoothStep = GetValue(config, 'smoothStep', true); + }, + + /** + * Called by the Game instance when the DOM window.onBlur event triggers. + * + * @method Phaser.Core.TimeStep#blur + * @since 3.0.0 + */ + blur: function () + { + this.inFocus = false; + }, + + /** + * Called by the Game instance when the DOM window.onFocus event triggers. + * + * @method Phaser.Core.TimeStep#focus + * @since 3.0.0 + */ + focus: function () + { + this.inFocus = true; + + this.resetDelta(); + }, + + /** + * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) + * + * @method Phaser.Core.TimeStep#pause + * @since 3.0.0 + */ + pause: function () + { + this._pauseTime = window.performance.now(); + }, + + /** + * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) + * + * @method Phaser.Core.TimeStep#resume + * @since 3.0.0 + */ + resume: function () + { + this.resetDelta(); + + this.pauseDuration = this.time - this._pauseTime; + this.startTime += this.pauseDuration; + }, + + /** + * Resets the time, lastTime, fps averages and delta history. + * Called automatically when a browser sleeps then resumes. + * + * @method Phaser.Core.TimeStep#resetDelta + * @since 3.0.0 + */ + resetDelta: function () + { + var now = window.performance.now(); + + this.time = now; + this.lastTime = now; + this.nextFpsUpdate = now + 1000; + this.framesThisSecond = 0; + + // Pre-populate smoothing array + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = Math.min(this._target, this.deltaHistory[i]); + } + + this.delta = 0; + this.deltaIndex = 0; + + this._coolDown = this.panicMax; + }, + + /** + * Starts the Time Step running, if it is not already doing so. + * Called automatically by the Game Boot process. + * + * @method Phaser.Core.TimeStep#start + * @since 3.0.0 + * + * @param {Phaser.Types.Core.TimeStepCallback} callback - The callback to be invoked each time the Time Step steps. + */ + start: function (callback) + { + if (this.started) + { + return this; + } + + this.started = true; + this.running = true; + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = this._target; + } + + this.resetDelta(); + + this.startTime = window.performance.now(); + + this.callback = callback; + + var step = (this.hasFpsLimit) ? this.stepLimitFPS.bind(this) : this.step.bind(this); + + this.raf.start(step, this.forceSetTimeOut, this._target); + }, + + /** + * Takes the delta value and smooths it based on the previous frames. + * + * Called automatically as part of the step. + * + * @method Phaser.Core.TimeStep#smoothDelta + * @since 3.60.0 + * + * @param {number} delta - The delta value for this step. + * + * @return {number} The smoothed delta value. + */ + smoothDelta: function (delta) + { + var idx = this.deltaIndex; + var history = this.deltaHistory; + var max = this.deltaSmoothingMax; + + if (this._coolDown > 0 || !this.inFocus) + { + this._coolDown--; + + delta = Math.min(delta, this._target); + } + + if (delta > this._min) + { + // Probably super bad start time or browser tab context loss, + // so use the last 'sane' delta value + + delta = history[idx]; + + // Clamp delta to min (in case history has become corrupted somehow) + delta = Math.min(delta, this._min); + } + + // Smooth out the delta over the previous X frames + + // add the delta to the smoothing array + history[idx] = delta; + + // adjusts the delta history array index based on the smoothing count + // this stops the array growing beyond the size of deltaSmoothingMax + this.deltaIndex++; + + if (this.deltaIndex >= max) + { + this.deltaIndex = 0; + } + + // Loop the history array, adding the delta values together + var avg = 0; + + for (var i = 0; i < max; i++) + { + avg += history[i]; + } + + // Then divide by the array length to get the average delta + avg /= max; + + return avg; + }, + + /** + * Update the estimate of the frame rate, `fps`. Every second, the number + * of frames that occurred in that second are included in an exponential + * moving average of all frames per second, with an alpha of 0.25. This + * means that more recent seconds affect the estimated frame rate more than + * older seconds. + * + * When a browser window is NOT minimized, but is covered up (i.e. you're using + * another app which has spawned a window over the top of the browser), then it + * will start to throttle the raf callback time. It waits for a while, and then + * starts to drop the frame rate at 1 frame per second until it's down to just over 1fps. + * So if the game was running at 60fps, and the player opens a new window, then + * after 60 seconds (+ the 'buffer time') it'll be down to 1fps, firing at just 1Hz. + * + * When they make the game visible again, the frame rate is increased at a rate of + * approx. 8fps, back up to 60fps (or the max it can obtain) + * + * There is no easy way to determine if this drop in frame rate is because the + * browser is throttling raf, or because the game is struggling with performance + * because you're asking it to do too much on the device. + * + * Compute the new exponential moving average with an alpha of 0.25. + * + * @method Phaser.Core.TimeStep#updateFPS + * @since 3.60.0 + * + * @param {number} time - The timestamp passed in from RequestAnimationFrame or setTimeout. + */ + updateFPS: function (time) + { + this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; + this.nextFpsUpdate = time + 1000; + this.framesThisSecond = 0; + }, + + /** + * The main step method with an fps limiter. This is called each time the browser updates, either by Request Animation Frame, + * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. + * You generally should never call this method directly. + * + * @method Phaser.Core.TimeStep#stepLimitFPS + * @since 3.60.0 + * + * @param {number} time - The timestamp passed in from RequestAnimationFrame or setTimeout. + */ + stepLimitFPS: function (time) + { + this.now = time; + + // delta time (time is in ms) + // Math.max because Chrome will sometimes give negative deltas + var delta = Math.max(0, time - this.lastTime); + + this.rawDelta = delta; + + // Real-world timer advance + this.time += this.rawDelta; + + if (this.smoothStep) + { + delta = this.smoothDelta(delta); + } + + // Set as the world delta value (after smoothing, if applied) + this.delta += delta; + + if (time >= this.nextFpsUpdate) + { + this.updateFPS(time); + } + + this.framesThisSecond++; + + if (this.delta >= this._limitRate) + { + this.callback(time, this.delta); + + this.delta %= this._limitRate; + } + + // Shift time value over + this.lastTime = time; + + this.frame++; + }, + + /** + * The main step method. This is called each time the browser updates, either by Request Animation Frame, + * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. + * You generally should never call this method directly. + * + * @method Phaser.Core.TimeStep#step + * @since 3.0.0 + * + * @param {number} time - The timestamp passed in from RequestAnimationFrame or setTimeout. + */ + step: function (time) + { + this.now = time; + + // delta time (time is in ms) + // Math.max because Chrome will sometimes give negative deltas + var delta = Math.max(0, time - this.lastTime); + + this.rawDelta = delta; + + // Real-world timer advance + this.time += this.rawDelta; + + if (this.smoothStep) + { + delta = this.smoothDelta(delta); + } + + // Set as the world delta value (after smoothing, if applied) + this.delta = delta; + + if (time >= this.nextFpsUpdate) + { + this.updateFPS(time); + } + + this.framesThisSecond++; + + this.callback(time, delta); + + // Shift time value over + this.lastTime = time; + + this.frame++; + }, + + /** + * Manually advances the TimeStep by one step, using the current timestamp from `window.performance.now`. + * Calls `TimeStep.stepLimitFPS` if an FPS limit is active, otherwise calls `TimeStep.step`. + * + * @method Phaser.Core.TimeStep#tick + * @since 3.0.0 + */ + tick: function () + { + var now = window.performance.now(); + + if (this.hasFpsLimit) + { + this.stepLimitFPS(now); + } + else + { + this.step(now); + } + }, + + /** + * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. + * + * @method Phaser.Core.TimeStep#sleep + * @since 3.0.0 + */ + sleep: function () + { + if (this.running) + { + this.raf.stop(); + + this.running = false; + } + }, + + /** + * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. + * The `seamless` argument controls if the wake-up should adjust the start time or not. + * + * @method Phaser.Core.TimeStep#wake + * @since 3.0.0 + * + * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. + */ + wake: function (seamless) + { + if (seamless === undefined) { seamless = false; } + + var now = window.performance.now(); + + if (this.running) + { + return; + } + else if (seamless) + { + this.startTime += -this.lastTime + (this.lastTime + now); + } + + var step = (this.hasFpsLimit) ? this.stepLimitFPS.bind(this) : this.step.bind(this); + + this.raf.start(step, this.forceSetTimeOut, this._target); + + this.running = true; + + this.nextFpsUpdate = now + 1000; + this.framesThisSecond = 0; + this.fpsLimitTriggered = false; + + this.tick(); + }, + + /** + * Gets the duration which the game has been running, in seconds. + * + * @method Phaser.Core.TimeStep#getDuration + * @since 3.17.0 + * + * @return {number} The duration in seconds. + */ + getDuration: function () + { + return Math.round(this.lastTime - this.startTime) / 1000; + }, + + /** + * Gets the duration which the game has been running, in ms. + * + * @method Phaser.Core.TimeStep#getDurationMS + * @since 3.17.0 + * + * @return {number} The duration in ms. + */ + getDurationMS: function () + { + return Math.round(this.lastTime - this.startTime); + }, + + /** + * Sets the FPS limit (`fpsLimit` property) and related properties. + * + * Use this method to set the FPS limit at runtime, rather than setting the + * `fpsLimit` property directly, to ensure the related properties are + * updated correctly. If the TimeStep is running, it will be stopped and + * restarted with the new FPS limit. + * + * If you just want a constant limit, use the Game Config `fps: { limit: 30 }` value instead. + * + * @method Phaser.Core.TimeStep#setFPSLimit + * @since 4.2.0 + * + * @param {number} limit - The FPS limit to set. Set to 0 to remove the FPS limit. + * + * @return {this} The TimeStep object. + */ + setFPSLimit: function (limit) + { + this.fpsLimit = limit; + this.hasFpsLimit = (this.fpsLimit > 0); + this._limitRate = (this.hasFpsLimit) ? (1000 / this.fpsLimit) : 0; + + if (this.running) + { + var step = (this.hasFpsLimit) ? this.stepLimitFPS.bind(this) : this.step.bind(this); + this.raf.stop(); + this.raf.start(step, this.forceSetTimeOut, this._limitRate); + } + + return this; + }, + + /** + * Stops the TimeStep running. + * + * @method Phaser.Core.TimeStep#stop + * @since 3.0.0 + * + * @return {this} The TimeStep object. + */ + stop: function () + { + this.running = false; + this.started = false; + + this.raf.stop(); + + return this; + }, + + /** + * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null + * any objects. + * + * @method Phaser.Core.TimeStep#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.raf.destroy(); + + this.raf = null; + this.game = null; + this.callback = null; + } + +}); + +module.exports = TimeStep; + + +/***/ }, + +/***/ 51085 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Events = __webpack_require__(8443); + +/** + * The Visibility Handler is responsible for listening for document-level visibility change events and + * window blur/focus events, then re-emitting them through the Game's Event Emitter so that the rest of + * the framework can respond appropriately — for example, pausing the game loop when the player switches + * tabs or minimizes the browser window, and resuming it when they return. + * + * It listens for the standard `visibilitychange` event where supported, and falls back to vendor-prefixed + * equivalents (`webkitvisibilitychange`, `mozvisibilitychange`, `msvisibilitychange`) for older browsers. + * Window-level `blur` and `focus` events are also captured to handle cases where the tab remains visible + * but the window loses focus. + * + * If the game configuration has `autoFocus` enabled, the handler will also call `window.focus()` during + * setup to ensure the game captures keyboard input immediately on load. + * + * @function Phaser.Core.VisibilityHandler + * @fires Phaser.Core.Events#BLUR + * @fires Phaser.Core.Events#FOCUS + * @fires Phaser.Core.Events#HIDDEN + * @fires Phaser.Core.Events#VISIBLE + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Game instance this Visibility Handler is working on. + */ +var VisibilityHandler = function (game) +{ + var hiddenVar; + var eventEmitter = game.events; + + if (document.hidden !== undefined) + { + hiddenVar = 'visibilitychange'; + } + else + { + var vendors = [ 'webkit', 'moz', 'ms' ]; + + vendors.forEach(function (prefix) + { + if (document[prefix + 'Hidden'] !== undefined) + { + document.hidden = function () + { + return document[prefix + 'Hidden']; + }; + + hiddenVar = prefix + 'visibilitychange'; + } + + }); + } + + var onChange = function (event) + { + if (document.hidden || event.type === 'pause') + { + eventEmitter.emit(Events.HIDDEN); + } + else + { + eventEmitter.emit(Events.VISIBLE); + } + }; + + if (hiddenVar) + { + document.addEventListener(hiddenVar, onChange, false); + } + + window.onblur = function () + { + eventEmitter.emit(Events.BLUR); + }; + + window.onfocus = function () + { + eventEmitter.emit(Events.FOCUS); + }; + + // Automatically give the window focus unless config says otherwise + if (window.focus && game.config.autoFocus) + { + window.focus(); + } +}; + +module.exports = VisibilityHandler; + + +/***/ }, + +/***/ 97217 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Blur Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps + * tab, or if they simply remove focus from the browser to another app. + * + * @event Phaser.Core.Events#BLUR + * @type {string} + * @since 3.0.0 + */ +module.exports = 'blur'; + + +/***/ }, + +/***/ 47548 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Boot Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + * + * @event Phaser.Core.Events#BOOT + * @type {string} + * @since 3.0.0 + */ +module.exports = 'boot'; + + +/***/ }, + +/***/ 19814 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Context Lost Event. + * + * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Lost event from the browser. + * + * The renderer halts all rendering and cannot resume after this happens. + * + * @event Phaser.Core.Events#CONTEXT_LOST + * @type {string} + * @since 3.19.0 + */ +module.exports = 'contextlost'; + + +/***/ }, + +/***/ 68446 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Destroy Event. + * + * This event is dispatched when the game instance has been told to destroy itself. + * Lots of internal systems listen to this event in order to clear themselves out. + * Custom plugins and game code should also do the same. + * + * @event Phaser.Core.Events#DESTROY + * @type {string} + * @since 3.0.0 + */ +module.exports = 'destroy'; + + +/***/ }, + +/***/ 41700 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Focus Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it. + * + * @event Phaser.Core.Events#FOCUS + * @type {string} + * @since 3.0.0 + */ +module.exports = 'focus'; + + +/***/ }, + +/***/ 25432 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Hidden Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted. + * + * In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which + * control the main game loop, will automatically pause. There is no way to stop this from happening. It is something + * your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games) + * + * @event Phaser.Core.Events#HIDDEN + * @type {string} + * @since 3.0.0 + */ +module.exports = 'hidden'; + + +/***/ }, + +/***/ 65942 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Pause Event. + * + * This event is dispatched when the Game loop enters a paused state, usually as a result of the Visibility Handler. + * + * @event Phaser.Core.Events#PAUSE + * @type {string} + * @since 3.0.0 + */ +module.exports = 'pause'; + + +/***/ }, + +/***/ 59211 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Post-Render Event. + * + * This event is dispatched right at the end of the render process. + * + * Every Scene will have rendered and been drawn to the canvas by the time this event is fired. + * Use it for any last minute post-processing before the next game step begins. + * + * @event Phaser.Core.Events#POST_RENDER + * @type {string} + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer being used by the Game instance. + */ +module.exports = 'postrender'; + + +/***/ }, + +/***/ 47789 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Post-Step Event. + * + * This event is dispatched after the Scene Manager has updated. + * Hook into it from plugins or systems that need to do things before the render starts. + * + * @event Phaser.Core.Events#POST_STEP + * @type {string} + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ +module.exports = 'poststep'; + + +/***/ }, + +/***/ 39066 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Pre-Render Event. + * + * This event is dispatched immediately before any of the Scenes have started to render. + * + * The renderer will already have been initialized this frame, clearing itself and preparing to receive the Scenes for rendering, but it won't have actually drawn anything yet. + * + * @event Phaser.Core.Events#PRE_RENDER + * @type {string} + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer being used by the Game instance. + */ +module.exports = 'prerender'; + + +/***/ }, + +/***/ 460 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Pre-Step Event. + * + * This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened. + * Hook into it from plugins or systems that need to update before the Scene Manager does. + * + * @event Phaser.Core.Events#PRE_STEP + * @type {string} + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ +module.exports = 'prestep'; + + +/***/ }, + +/***/ 16175 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Ready Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready, + * and all local systems are now able to start. + * + * @event Phaser.Core.Events#READY + * @type {string} + * @since 3.0.0 + */ +module.exports = 'ready'; + + +/***/ }, + +/***/ 42331 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Resume Event. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + * + * @event Phaser.Core.Events#RESUME + * @type {string} + * @since 3.0.0 + * + * @param {number} pauseDuration - The duration, in ms, that the game was paused for, or 0 if {@link Phaser.Game#resume} was called. + */ +module.exports = 'resume'; + + +/***/ }, + +/***/ 11966 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Step Event. + * + * This event is dispatched after the Game Pre-Step and before the Scene Manager steps. + * Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have. + * + * @event Phaser.Core.Events#STEP + * @type {string} + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ +module.exports = 'step'; + + +/***/ }, + +/***/ 32969 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * This event is dispatched when the Scene Manager has created the System Scene, + * which other plugins and systems may use to initialize themselves. + * + * This event is dispatched just once by the Game instance. + * + * @event Phaser.Core.Events#SYSTEM_READY + * @type {string} + * @since 3.70.0 + * + * @param {Phaser.Scenes.Systems} sys - A reference to the Scene Systems class of the Scene that emitted this event. + */ +module.exports = 'systemready'; + + +/***/ }, + +/***/ 94830 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Visible Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a visible state, previously having been hidden. + * + * Only browsers that support the Visibility API will cause this event to be emitted. + * + * @event Phaser.Core.Events#VISIBLE + * @type {string} + * @since 3.0.0 + */ +module.exports = 'visible'; + + +/***/ }, + +/***/ 8443 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Core.Events + */ + +module.exports = { + + BLUR: __webpack_require__(97217), + BOOT: __webpack_require__(47548), + CONTEXT_LOST: __webpack_require__(19814), + DESTROY: __webpack_require__(68446), + FOCUS: __webpack_require__(41700), + HIDDEN: __webpack_require__(25432), + PAUSE: __webpack_require__(65942), + POST_RENDER: __webpack_require__(59211), + POST_STEP: __webpack_require__(47789), + PRE_RENDER: __webpack_require__(39066), + PRE_STEP: __webpack_require__(460), + READY: __webpack_require__(16175), + RESUME: __webpack_require__(42331), + STEP: __webpack_require__(11966), + SYSTEM_READY: __webpack_require__(32969), + VISIBLE: __webpack_require__(94830) + +}; + + +/***/ }, + +/***/ 42857 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Core + */ + +module.exports = { + + Config: __webpack_require__(69547), + CreateRenderer: __webpack_require__(86054), + DebugHeader: __webpack_require__(96391), + Events: __webpack_require__(8443), + TimeStep: __webpack_require__(65898), + VisibilityHandler: __webpack_require__(51085) + +}; + + +/***/ }, + +/***/ 46728 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(83419); +var CubicBezier = __webpack_require__(36316); +var Curve = __webpack_require__(80021); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Cubic Bézier curve is a smooth parametric curve defined by four points: a start point (`p0`), + * two control points (`p1` and `p2`) that shape the curvature, and an end point (`p3`). The curve + * passes through `p0` and `p3` but is only pulled toward the control points, allowing you to create + * a wide variety of smooth, flowing shapes. + * + * Cubic Bézier curves are commonly used in Phaser for defining movement paths, animating objects + * along arcs, and building complex `Path` objects. You can sample any position along the curve + * using a normalised `t` value from 0 (start) to 1 (end), or use the inherited helper methods such + * as `getPoints` and `getSpacedPoints` to obtain evenly distributed coordinates for rendering or + * movement. + * + * @class CubicBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + * @param {Phaser.Math.Vector2} p3 - End Point. + */ +var CubicBezierCurve = new Class({ + + Extends: Curve, + + initialize: + + function CubicBezierCurve (p0, p1, p2, p3) + { + Curve.call(this, 'CubicBezierCurve'); + + if (Array.isArray(p0)) + { + p3 = new Vector2(p0[6], p0[7]); + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * The start point of this curve. + * + * @name Phaser.Curves.CubicBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * The first control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + + /** + * The second control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p2 = p2; + + /** + * The end point of this curve. + * + * @name Phaser.Curves.CubicBezier#p3 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p3 = p3; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.CubicBezier#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * Returns the resolution of this curve, which is the number of points used to approximate it when calculating lengths or sampling. For a Cubic Bézier, the resolution is equal to the number of divisions requested. + * + * @method Phaser.Curves.CubicBezier#getResolution + * @since 3.0.0 + * + * @param {number} divisions - The amount of divisions used by this curve. + * + * @return {number} The resolution of the curve. + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Calculates the coordinates of the point at the given normalised position (`t`) along this curve using cubic Bézier interpolation. + * + * @method Phaser.Curves.CubicBezier#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + var p3 = this.p3; + + return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * Draws this curve to the specified graphics object. + * + * @method Phaser.Curves.CubicBezier#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The graphics object this curve should be drawn to. + * @param {number} [pointsTotal=32] - The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. + * + * @return {Phaser.GameObjects.Graphics} The graphics object this curve was drawn to. Useful for method chaining. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Returns a JSON object that describes this curve. + * + * @method Phaser.Curves.CubicBezier#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Curves.JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y, + this.p3.x, this.p3.y + ] + }; + } + +}); + +/** + * Generates a curve from a JSON object. + * + * @function Phaser.Curves.CubicBezier.fromJSON + * @since 3.0.0 + * + * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.CubicBezier} The curve generated from the JSON object. + */ +CubicBezierCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + var p3 = new Vector2(points[6], points[7]); + + return new CubicBezierCurve(p0, p1, p2, p3); +}; + +module.exports = CubicBezierCurve; + + +/***/ }, + +/***/ 80021 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var FromPoints = __webpack_require__(19217); +var Rectangle = __webpack_require__(87841); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Base Curve class, which all other curve types extend. + * + * A Curve represents a mathematical path through 2D space and provides methods for + * sampling points, calculating arc lengths, and obtaining tangent vectors along it. + * Curves are the building blocks of `Phaser.Curves.Path`, which allows Game Objects + * to follow complex routes through a scene. + * + * This class is not intended to be instantiated directly. Instead, use one of the + * concrete subclasses in the `Phaser.Curves` namespace, such as `LineCurve`, + * `QuadraticBezier`, `CubicBezier`, `EllipseCurve`, or `SplineCurve`. + * + * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + * + * @class Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {string} type - The curve type. + */ +var Curve = new Class({ + + initialize: + + function Curve (type) + { + /** + * String based identifier for the type of curve. + * + * @name Phaser.Curves.Curve#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The default number of divisions within the curve. + * + * @name Phaser.Curves.Curve#defaultDivisions + * @type {number} + * @default 5 + * @since 3.0.0 + */ + this.defaultDivisions = 5; + + /** + * The quantity of arc length divisions within the curve. + * + * @name Phaser.Curves.Curve#arcLengthDivisions + * @type {number} + * @default 100 + * @since 3.0.0 + */ + this.arcLengthDivisions = 100; + + /** + * An array of cached arc length values. + * + * @name Phaser.Curves.Curve#cacheArcLengths + * @type {number[]} + * @default [] + * @since 3.0.0 + */ + this.cacheArcLengths = []; + + /** + * Does the data of this curve need updating? + * + * @name Phaser.Curves.Curve#needsUpdate + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.needsUpdate = true; + + /** + * For a curve on a Path, `false` means the Path will ignore this curve. + * + * @name Phaser.Curves.Curve#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * A temporary calculation Vector. + * + * @name Phaser.Curves.Curve#_tmpVec2A + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2A = new Vector2(); + + /** + * A temporary calculation Vector. + * + * @name Phaser.Curves.Curve#_tmpVec2B + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2B = new Vector2(); + }, + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.Curve#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * @param {number} [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + // So you can chain graphics calls + return graphics.strokePoints(this.getPoints(pointsTotal)); + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * You can control the accuracy of the bounds. The value given is used to work out how many points + * to plot across the curve. Higher values are more accurate at the cost of calculation speed. + * + * @method Phaser.Curves.Curve#getBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the bounds in. If falsey a new object will be created. + * @param {number} [accuracy=16] - The accuracy of the bounds calculations. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out, accuracy) + { + if (!out) { out = new Rectangle(); } + if (accuracy === undefined) { accuracy = 16; } + + var len = this.getLength(); + + if (accuracy > len) + { + accuracy = len / 2; + } + + // The length of the curve in pixels + // So we'll have 1 spaced point per 'accuracy' pixels + + var spaced = Math.max(1, Math.round(len / accuracy)); + + return FromPoints(this.getSpacedPoints(spaced), out); + }, + + /** + * Returns an array of points, spaced out X distance pixels apart. + * The smaller the distance, the larger the array will be. + * + * @method Phaser.Curves.Curve#getDistancePoints + * @since 3.0.0 + * + * @param {number} distance - The distance, in pixels, between each point along the curve. + * + * @return {Phaser.Math.Vector2[]} An Array of Vector2 objects. + */ + getDistancePoints: function (distance) + { + var len = this.getLength(); + + var spaced = Math.max(1, len / distance); + + return this.getSpacedPoints(spaced); + }, + + /** + * Get a point at the end of the curve. + * + * @method Phaser.Curves.Curve#getEndPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - Optional Vector object to store the result in. + * + * @return {Phaser.Math.Vector2} Vector2 containing the coordinates of the curve's end point. + */ + getEndPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPointAt(1, out); + }, + + /** + * Returns the total arc length of the curve, in pixels. The length is calculated by summing the distances between sampled points along the curve. + * + * @method Phaser.Curves.Curve#getLength + * @since 3.0.0 + * + * @return {number} The total length of the curve. + */ + getLength: function () + { + var lengths = this.getLengths(); + + return lengths[lengths.length - 1]; + }, + + + /** + * Get a list of cumulative segment lengths. + * + * These lengths are calculated and cached the first time this method is called. + * + * - [0] 0 + * - [1] The first segment + * - [2] The first and second segment + * - ... + * - [divisions] All segments + * + * @method Phaser.Curves.Curve#getLengths + * @since 3.0.0 + * + * @param {number} [divisions] - The number of divisions or segments. + * + * @return {number[]} An array of cumulative lengths. + */ + getLengths: function (divisions) + { + if (divisions === undefined) { divisions = this.arcLengthDivisions; } + + if ((this.cacheArcLengths.length === divisions + 1) && !this.needsUpdate) + { + return this.cacheArcLengths; + } + + this.needsUpdate = false; + + var cache = []; + var current; + var last = this.getPoint(0, this._tmpVec2A); + var sum = 0; + + cache.push(0); + + for (var p = 1; p <= divisions; p++) + { + current = this.getPoint(p / divisions, this._tmpVec2B); + + sum += current.distance(last); + + cache.push(sum); + + last.copy(current); + } + + this.cacheArcLengths = cache; + + return cache; // { sums: cache, sum:sum }; Sum is in the last element. + }, + + // Get point at relative position in curve according to arc length + + // - u [0 .. 1] + + /** + * Get a point at a relative position on the curve, by arc length. + * + * @method Phaser.Curves.Curve#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - The relative position, [0..1]. + * @param {Phaser.Math.Vector2} [out] - A point to store the result in. + * + * @return {Phaser.Math.Vector2} The point. + */ + getPointAt: function (u, out) + { + var t = this.getUtoTmapping(u); + + return this.getPoint(t, out); + }, + + // Get sequence of points using getPoint( t ) + + /** + * Get a sequence of evenly spaced points from the curve. + * + * You can pass `divisions`, `stepRate`, or neither. + * + * The number of divisions will be + * + * 1. `divisions`, if `divisions` > 0; or + * 2. `this.getLength / stepRate`, if `stepRate` > 0; or + * 3. `this.defaultDivisions` + * + * `1 + divisions` points will be returned. + * + * @method Phaser.Curves.Curve#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [out,$return] + * + * @param {number} [divisions] - The number of divisions to make. + * @param {number} [stepRate] - The curve distance between points, implying `divisions`. + * @param {Phaser.Math.Vector2[]} [out] - An optional array to store the points in. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 points from the curve. + */ + getPoints: function (divisions, stepRate, out) + { + if (out === undefined) { out = []; } + + // If divisions is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!divisions) + { + if (!stepRate) + { + divisions = this.defaultDivisions; + } + else + { + divisions = this.getLength() / stepRate; + } + } + + for (var d = 0; d <= divisions; d++) + { + out.push(this.getPoint(d / divisions)); + } + + return out; + }, + + /** + * Get a random point from the curve. + * + * @method Phaser.Curves.Curve#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A point object to store the result in. + * + * @return {Phaser.Math.Vector2} The point. + */ + getRandomPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); + }, + + // Get sequence of points using getPointAt( u ) + + /** + * Get a sequence of equally spaced points (by arc distance) from the curve. + * + * `1 + divisions` points will be returned. + * + * @method Phaser.Curves.Curve#getSpacedPoints + * @since 3.0.0 + * + * @param {number} [divisions=this.defaultDivisions] - The number of divisions to make. + * @param {number} [stepRate] - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive. + * @param {Phaser.Math.Vector2[]} [out] - An optional array to store the points in. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 points. + */ + getSpacedPoints: function (divisions, stepRate, out) + { + if (out === undefined) { out = []; } + + // If divisions is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!divisions) + { + if (!stepRate) + { + divisions = this.defaultDivisions; + } + else + { + divisions = this.getLength() / stepRate; + } + } + + for (var d = 0; d <= divisions; d++) + { + var t = this.getUtoTmapping(d / divisions, null, divisions); + + out.push(this.getPoint(t)); + } + + return out; + }, + + /** + * Get a point at the start of the curve. + * + * @method Phaser.Curves.Curve#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A point to store the result in. + * + * @return {Phaser.Math.Vector2} The point. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPointAt(0, out); + }, + + /** + * Get a unit vector tangent at a relative position on the curve. + * If a subclass does not override this method with an analytic tangent derivation, + * the tangent is approximated by sampling two points a small delta apart and + * computing the normalized direction vector between them. + * + * @method Phaser.Curves.Curve#getTangent + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The relative position on the curve, [0..1]. + * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. + * + * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) + */ + getTangent: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var delta = 0.0001; + var t1 = t - delta; + var t2 = t + delta; + + // Capping in case of danger + + if (t1 < 0) + { + t1 = 0; + } + + if (t2 > 1) + { + t2 = 1; + } + + this.getPoint(t1, this._tmpVec2A); + this.getPoint(t2, out); + + return out.subtract(this._tmpVec2A).normalize(); + }, + + /** + * Get a unit vector tangent at a relative position on the curve, by arc length. + * + * @method Phaser.Curves.Curve#getTangentAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - The relative position on the curve, [0..1]. + * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. + * + * @return {Phaser.Math.Vector2} The tangent vector. + */ + getTangentAt: function (u, out) + { + var t = this.getUtoTmapping(u); + + return this.getTangent(t, out); + }, + + /** + * Given a distance in pixels along the curve, returns the corresponding t parameter value that can be used with `getPoint()` to find the position at that distance. This gives you equidistant points along the curve. + * + * @method Phaser.Curves.Curve#getTFromDistance + * @since 3.0.0 + * + * @param {number} distance - The distance, in pixels. + * @param {number} [divisions] - Optional amount of divisions. + * + * @return {number} The t value (between 0 and 1) at the given distance along the curve. + */ + getTFromDistance: function (distance, divisions) + { + if (distance <= 0) + { + return 0; + } + + return this.getUtoTmapping(0, distance, divisions); + }, + + /** + * Maps a uniform parameter u (0 to 1, distributed evenly by arc length) to the raw curve parameter t. This mapping ensures that points sampled at regular intervals of u will be equidistant along the curve, unlike the raw t parameter which may produce uneven spacing. + * + * @method Phaser.Curves.Curve#getUtoTmapping + * @since 3.0.0 + * + * @param {number} u - A float between 0 and 1. + * @param {number} distance - The distance, in pixels. + * @param {number} [divisions] - Optional amount of divisions. + * + * @return {number} The equidistant value. + */ + getUtoTmapping: function (u, distance, divisions) + { + var arcLengths = this.getLengths(divisions); + + var i = 0; + var il = arcLengths.length; + + var targetArcLength; // The targeted u distance value to get + + if (distance) + { + // Cannot overshoot the curve + targetArcLength = Math.min(distance, arcLengths[il - 1]); + } + else + { + targetArcLength = u * arcLengths[il - 1]; + } + + // binary search for the index with largest value smaller than target u distance + + var low = 0; + var high = il - 1; + var comparison; + + while (low <= high) + { + i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats + + comparison = arcLengths[i] - targetArcLength; + + if (comparison < 0) + { + low = i + 1; + } + else if (comparison > 0) + { + high = i - 1; + } + else + { + high = i; + break; + } + } + + i = high; + + if (arcLengths[i] === targetArcLength) + { + return i / (il - 1); + } + + // we could get finer grain at lengths, or use simple interpolation between two points + + var lengthBefore = arcLengths[i]; + var lengthAfter = arcLengths[i + 1]; + + var segmentLength = lengthAfter - lengthBefore; + + // determine where we are between the 'before' and 'after' points + + var segmentFraction = (targetArcLength - lengthBefore) / segmentLength; + + // add that fractional amount to t + + return (i + segmentFraction) / (il - 1); + }, + + /** + * Calculate and cache the arc lengths. + * + * @method Phaser.Curves.Curve#updateArcLengths + * @since 3.0.0 + * + * @see Phaser.Curves.Curve#getLengths() + */ + updateArcLengths: function () + { + this.needsUpdate = true; + + this.getLengths(); + } + +}); + +module.exports = Curve; + + +/***/ }, + +/***/ 73825 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var DegToRad = __webpack_require__(39506); +var GetValue = __webpack_require__(35154); +var RadToDeg = __webpack_require__(43396); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * An Ellipse Curve is a smooth curve that describes the path of an ellipse. It can be used + * to move Game Objects along an elliptical path, generate points distributed around an ellipse, + * or draw elliptical arcs as part of a Path or Graphics object. + * + * You can control the center position, horizontal and vertical radii, start and end angles, + * rotation, and whether the curve runs clockwise or anti-clockwise. Passing only `xRadius` + * will create a circle (both radii are equal by default). + * + * This curve extends the base `Phaser.Curves.Curve` class and can be used anywhere a Curve + * is accepted in Phaser, such as `Phaser.Curves.Path` or a `PathFollower` Game Object. + * + * See https://en.wikipedia.org/wiki/Ellipse for more details. + * + * @class Ellipse + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(number|Phaser.Types.Curves.EllipseCurveConfig)} [x=0] - The x coordinate of the ellipse, or an Ellipse Curve configuration object. + * @param {number} [y=0] - The y coordinate of the ellipse. + * @param {number} [xRadius=0] - The horizontal radius of ellipse. + * @param {number} [yRadius=0] - The vertical radius of ellipse. + * @param {number} [startAngle=0] - The start angle of the ellipse, in degrees. + * @param {number} [endAngle=360] - The end angle of the ellipse, in degrees. + * @param {boolean} [clockwise=false] - Whether the ellipse angles are given as clockwise (`true`) or counter-clockwise (`false`). + * @param {number} [rotation=0] - The rotation of the ellipse, in degrees. + */ +var EllipseCurve = new Class({ + + Extends: Curve, + + initialize: + + function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + if (typeof x === 'object') + { + var config = x; + + x = GetValue(config, 'x', 0); + y = GetValue(config, 'y', 0); + xRadius = GetValue(config, 'xRadius', 0); + yRadius = GetValue(config, 'yRadius', xRadius); + startAngle = GetValue(config, 'startAngle', 0); + endAngle = GetValue(config, 'endAngle', 360); + clockwise = GetValue(config, 'clockwise', false); + rotation = GetValue(config, 'rotation', 0); + } + else + { + if (yRadius === undefined) { yRadius = xRadius; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (clockwise === undefined) { clockwise = false; } + if (rotation === undefined) { rotation = 0; } + } + + Curve.call(this, 'EllipseCurve'); + + // Center point + + /** + * The center point of the ellipse. Used for calculating rotation. + * + * @name Phaser.Curves.Ellipse#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_xRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._xRadius = xRadius; + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_yRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._yRadius = yRadius; + + // Radians + + /** + * The starting angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_startAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._startAngle = DegToRad(startAngle); + + /** + * The end angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_endAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._endAngle = DegToRad(endAngle); + + /** + * Whether the ellipse arc is drawn clockwise (`true`) or anti-clockwise (`false`). + * + * @name Phaser.Curves.Ellipse#_clockwise + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._clockwise = clockwise; + + /** + * The rotation of the ellipse arc, in radians. + * + * @name Phaser.Curves.Ellipse#_rotation + * @type {number} + * @private + * @since 3.0.0 + */ + this._rotation = DegToRad(rotation); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Ellipse#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(0, out); + }, + + /** + * Returns the resolution of this curve, which is the number of points used to approximate it. For an Ellipse, this is double the requested divisions to provide accurate arc length calculations. + * + * @method Phaser.Curves.Ellipse#getResolution + * @since 3.0.0 + * + * @param {number} divisions - Optional divisions value. + * + * @return {number} The curve resolution. + */ + getResolution: function (divisions) + { + return divisions * 2; + }, + + /** + * Returns the point on this curve at the given normalized position `t`, where 0 is the start and 1 is the end. The result accounts for the start angle, end angle, clockwise direction, and rotation of the ellipse. + * + * @method Phaser.Curves.Ellipse#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var twoPi = Math.PI * 2; + var deltaAngle = this._endAngle - this._startAngle; + var samePoints = Math.abs(deltaAngle) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while (deltaAngle < 0) + { + deltaAngle += twoPi; + } + + while (deltaAngle > twoPi) + { + deltaAngle -= twoPi; + } + + if (deltaAngle < Number.EPSILON) + { + if (samePoints) + { + deltaAngle = 0; + } + else + { + deltaAngle = twoPi; + } + } + + if (this._clockwise && !samePoints) + { + if (deltaAngle === twoPi) + { + deltaAngle = - twoPi; + } + else + { + deltaAngle = deltaAngle - twoPi; + } + } + + var angle = this._startAngle + t * deltaAngle; + var x = this.p0.x + this._xRadius * Math.cos(angle); + var y = this.p0.y + this._yRadius * Math.sin(angle); + + if (this._rotation !== 0) + { + var cos = Math.cos(this._rotation); + var sin = Math.sin(this._rotation); + + var tx = x - this.p0.x; + var ty = y - this.p0.y; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.p0.x; + y = tx * sin + ty * cos + this.p0.y; + } + + return out.set(x, y); + }, + + /** + * Sets the horizontal radius of this curve. + * + * @method Phaser.Curves.Ellipse#setXRadius + * @since 3.0.0 + * + * @param {number} value - The horizontal radius of this curve. + * + * @return {this} This curve object. + */ + setXRadius: function (value) + { + this.xRadius = value; + + return this; + }, + + /** + * Sets the vertical radius of this curve. + * + * @method Phaser.Curves.Ellipse#setYRadius + * @since 3.0.0 + * + * @param {number} value - The vertical radius of this curve. + * + * @return {this} This curve object. + */ + setYRadius: function (value) + { + this.yRadius = value; + + return this; + }, + + /** + * Sets the width of this curve. The horizontal radius (`xRadius`) is set to half the given value. + * + * @method Phaser.Curves.Ellipse#setWidth + * @since 3.0.0 + * + * @param {number} value - The width of this curve. + * + * @return {this} This curve object. + */ + setWidth: function (value) + { + this.xRadius = value / 2; + + return this; + }, + + /** + * Sets the height of this curve. The vertical radius (`yRadius`) is set to half the given value. + * + * @method Phaser.Curves.Ellipse#setHeight + * @since 3.0.0 + * + * @param {number} value - The height of this curve. + * + * @return {this} This curve object. + */ + setHeight: function (value) + { + this.yRadius = value / 2; + + return this; + }, + + /** + * Sets the start angle of this curve. + * + * @method Phaser.Curves.Ellipse#setStartAngle + * @since 3.0.0 + * + * @param {number} value - The start angle of this curve, in degrees. + * + * @return {this} This curve object. + */ + setStartAngle: function (value) + { + this.startAngle = value; + + return this; + }, + + /** + * Sets the end angle of this curve. + * + * @method Phaser.Curves.Ellipse#setEndAngle + * @since 3.0.0 + * + * @param {number} value - The end angle of this curve, in degrees. + * + * @return {this} This curve object. + */ + setEndAngle: function (value) + { + this.endAngle = value; + + return this; + }, + + /** + * Sets if this curve extends clockwise or anti-clockwise. + * + * @method Phaser.Curves.Ellipse#setClockwise + * @since 3.0.0 + * + * @param {boolean} value - The clockwise state of this curve. + * + * @return {this} This curve object. + */ + setClockwise: function (value) + { + this.clockwise = value; + + return this; + }, + + /** + * Sets the rotation of this curve. + * + * @method Phaser.Curves.Ellipse#setRotation + * @since 3.0.0 + * + * @param {number} value - The rotation of this curve, in radians. + * + * @return {this} This curve object. + */ + setRotation: function (value) + { + this.rotation = value; + + return this; + }, + + /** + * The x coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.p0.x; + }, + + set: function (value) + { + this.p0.x = value; + } + + }, + + /** + * The y coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.p0.y; + }, + + set: function (value) + { + this.p0.y = value; + } + + }, + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#xRadius + * @type {number} + * @since 3.0.0 + */ + xRadius: { + + get: function () + { + return this._xRadius; + }, + + set: function (value) + { + this._xRadius = value; + } + + }, + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#yRadius + * @type {number} + * @since 3.0.0 + */ + yRadius: { + + get: function () + { + return this._yRadius; + }, + + set: function (value) + { + this._yRadius = value; + } + + }, + + /** + * The start angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#startAngle + * @type {number} + * @since 3.0.0 + */ + startAngle: { + + get: function () + { + return RadToDeg(this._startAngle); + }, + + set: function (value) + { + this._startAngle = DegToRad(value); + } + + }, + + /** + * The end angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#endAngle + * @type {number} + * @since 3.0.0 + */ + endAngle: { + + get: function () + { + return RadToDeg(this._endAngle); + }, + + set: function (value) + { + this._endAngle = DegToRad(value); + } + + }, + + /** + * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. + * + * @name Phaser.Curves.Ellipse#clockwise + * @type {boolean} + * @since 3.0.0 + */ + clockwise: { + + get: function () + { + return this._clockwise; + }, + + set: function (value) + { + this._clockwise = value; + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in degrees. + * + * @name Phaser.Curves.Ellipse#angle + * @type {number} + * @since 3.14.0 + */ + angle: { + + get: function () + { + return RadToDeg(this._rotation); + }, + + set: function (value) + { + this._rotation = DegToRad(value); + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in radians. + * + * @name Phaser.Curves.Ellipse#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + } + + }, + + /** + * JSON serialization of the curve. + * + * @method Phaser.Curves.Ellipse#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Curves.JSONEllipseCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + x: this.p0.x, + y: this.p0.y, + xRadius: this._xRadius, + yRadius: this._yRadius, + startAngle: RadToDeg(this._startAngle), + endAngle: RadToDeg(this._endAngle), + clockwise: this._clockwise, + rotation: RadToDeg(this._rotation) + }; + } + +}); + +/** + * Creates a curve from the provided Ellipse Curve Configuration object. + * + * @function Phaser.Curves.Ellipse.fromJSON + * @since 3.0.0 + * + * @param {Phaser.Types.Curves.JSONEllipseCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Ellipse} The ellipse curve constructed from the configuration object. + */ +EllipseCurve.fromJSON = function (data) +{ + return new EllipseCurve(data); +}; + +module.exports = EllipseCurve; + + +/***/ }, + +/***/ 33951 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var FromPoints = __webpack_require__(19217); +var Rectangle = __webpack_require__(87841); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A LineCurve is a straight line segment defined by exactly two endpoints. Despite being called a + * "curve", it implements the full `Phaser.Curves.Curve` interface, meaning it can be used anywhere + * a curve is expected — for example, as part of a `Phaser.Curves.Path` or as a motion path for a + * Tween. Because the line is perfectly straight, arc length calculations are exact and efficient, + * making LineCurve the most performant curve type. You can construct one from two `Vector2` points + * or from a flat array of four numbers `[x0, y0, x1, y1]`. + * + * @class Line + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - The first endpoint. + * @param {Phaser.Math.Vector2} [p1] - The second endpoint. + */ +var LineCurve = new Class({ + + Extends: Curve, + + initialize: + + // vec2s or array + function LineCurve (p0, p1) + { + Curve.call(this, 'LineCurve'); + + if (Array.isArray(p0)) + { + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * The first endpoint. + * + * @name Phaser.Curves.Line#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * The second endpoint. + * + * @name Phaser.Curves.Line#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + + // Override default Curve.arcLengthDivisions + + /** + * The quantity of arc length divisions within the curve. + * + * @name Phaser.Curves.Line#arcLengthDivisions + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.arcLengthDivisions = 1; + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * @method Phaser.Curves.Line#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + return FromPoints([ this.p0, this.p1 ], out); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Line#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * Returns the resolution of this curve. For a LineCurve the resolution is equal to the number of divisions requested, defaulting to 1 if none are provided. + * + * @method Phaser.Curves.Line#getResolution + * @since 3.0.0 + * + * @param {number} [divisions=1] - The number of divisions to consider. + * + * @return {number} The resolution. Equal to the number of divisions. + */ + getResolution: function (divisions) + { + if (divisions === undefined) { divisions = 1; } + + return divisions; + }, + + /** + * Gets a point at a relative position along the line, where 0 is the start point and 1 is the end point. + * + * @method Phaser.Curves.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + if (t === 1) + { + return out.copy(this.p1); + } + + out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); + + return out; + }, + + // Line curve is linear, so we can overwrite default getPointAt + + /** + * Gets a point at a given position on the line. + * + * @method Phaser.Curves.Line#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * Gets the slope of the line as a unit vector. + * + * @method Phaser.Curves.Line#getTangent + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} [t] - The relative position on the line, [0..1]. + * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. + * + * @return {Phaser.Math.Vector2} The tangent vector. + */ + getTangent: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + out.copy(this.p1).subtract(this.p0).normalize(); + + return out; + }, + + /** + * Converts a distance-based position along the line into a normalized `t` value in the range 0 to 1. + * If a `distance` is provided, the returned `t` represents that distance clamped to the line's total length. + * If no distance is given, `u` is returned directly. This override exists because a straight line has + * uniform arc length, so no iterative re-parameterization is needed. + * + * @method Phaser.Curves.Line#getUtoTmapping + * @since 3.0.0 + * + * @param {number} u - A float between 0 and 1. + * @param {number} distance - The distance, in pixels. + * @param {number} [divisions] - Optional amount of divisions. + * + * @return {number} The equidistant value. + */ + getUtoTmapping: function (u, distance, divisions) + { + var t; + + if (distance) + { + var arcLengths = this.getLengths(divisions); + var lineLength = arcLengths[arcLengths.length - 1]; + + // Cannot overshoot the curve + var targetLineLength = Math.min(distance, lineLength); + + t = targetLineLength / lineLength; + } + else + { + t = u; + } + + return t; + }, + + // Override default Curve.draw because this is better than calling getPoints on a line! + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.Line#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics) + { + graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Gets a JSON representation of the line. + * + * @method Phaser.Curves.Line#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Curves.JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y + ] + }; + } + +}); + +/** + * Configures this line from a JSON representation. + * + * @function Phaser.Curves.Line.fromJSON + * @since 3.0.0 + * + * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Line} A new LineCurve object. + */ +LineCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + + return new LineCurve(p0, p1); +}; + +module.exports = LineCurve; + + +/***/ }, + +/***/ 14744 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var QuadraticBezierInterpolation = __webpack_require__(32112); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A quadratic Bézier curve constructed from three points: a start point, a single control + * point, and an end point. This is a second-degree Bézier curve, where the control point + * influences the curvature of the path between the start and end points. + * + * @class QuadraticBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.2.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - The end point of the curve. + */ +var QuadraticBezier = new Class({ + + Extends: Curve, + + initialize: + + function QuadraticBezier (p0, p1, p2) + { + Curve.call(this, 'QuadraticBezierCurve'); + + if (Array.isArray(p0)) + { + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * The start point. + * + * @name Phaser.Curves.QuadraticBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p0 = p0; + + /** + * The first control point. + * + * @name Phaser.Curves.QuadraticBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p1 = p1; + + /** + * The end point of the curve. + * + * @name Phaser.Curves.QuadraticBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p2 = p2; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.QuadraticBezier#getStartPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * Returns the resolution of this curve. For a Quadratic Bezier, the resolution is equal to the number of divisions requested. + * + * @method Phaser.Curves.QuadraticBezier#getResolution + * @since 3.2.0 + * + * @param {number} divisions - Optional divisions value. + * + * @return {number} The curve resolution. + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.QuadraticBezier#getPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + + return out.set( + QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), + QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) + ); + }, + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.QuadraticBezier#draw + * @since 3.2.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - `Graphics` object to draw onto. + * @param {number} [pointsTotal=32] - Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. + * + * @return {Phaser.GameObjects.Graphics} `Graphics` object that was drawn to. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Converts the curve into a JSON compatible object. + * + * @method Phaser.Curves.QuadraticBezier#toJSON + * @since 3.2.0 + * + * @return {Phaser.Types.Curves.JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y + ] + }; + } + +}); + +/** + * Creates a curve from a JSON object, e.g. created by `toJSON`. + * + * @function Phaser.Curves.QuadraticBezier.fromJSON + * @since 3.2.0 + * + * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.QuadraticBezier} The created curve instance. + */ +QuadraticBezier.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + + return new QuadraticBezier(p0, p1, p2); +}; + +module.exports = QuadraticBezier; + + +/***/ }, + +/***/ 42534 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var CatmullRom = __webpack_require__(87842); +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Spline Curve is a smooth curve that passes through a series of control points, using Catmull-Rom + * interpolation to produce a natural-looking path. Unlike a Bezier curve, every control point is + * visited exactly, making it easy to define a precise route for objects to follow. + * + * Use a Spline Curve when you need a smooth path through multiple waypoints, such as a camera + * dolly track, a projectile flight path, or a patrol route for a game character. Points can be + * added at construction time or incrementally via `addPoint` and `addPoints`. + * + * @class Spline + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2[]|number[]|number[][])} [points] - The points that configure the curve. + */ +var SplineCurve = new Class({ + + Extends: Curve, + + initialize: + + function SplineCurve (points) + { + if (points === undefined) { points = []; } + + Curve.call(this, 'SplineCurve'); + + /** + * The Vector2 points that configure the curve. + * + * @name Phaser.Curves.Spline#points + * @type {Phaser.Math.Vector2[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + this.addPoints(points); + }, + + /** + * Add a list of points to the current list of Vector2 points of the curve. + * + * @method Phaser.Curves.Spline#addPoints + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - The points to add. Accepts an array of `Vector2` objects, a flat array of interleaved `x, y` number pairs, or an array of two-element `[x, y]` number arrays. + * + * @return {this} This curve object. + */ + addPoints: function (points) + { + for (var i = 0; i < points.length; i++) + { + var p = new Vector2(); + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + } + + return this; + }, + + /** + * Add a point to the current list of Vector2 points of the curve. + * + * @method Phaser.Curves.Spline#addPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to add. + * @param {number} y - The y coordinate of the point to add. + * + * @return {Phaser.Math.Vector2} The new Vector2 added to the curve + */ + addPoint: function (x, y) + { + var vec = new Vector2(x, y); + + this.points.push(vec); + + return vec; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Spline#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.points[0]); + }, + + /** + * Returns the resolution of this curve, which is the number of points used to approximate it per segment. For a Spline, this scales with the number of points and the requested divisions. + * + * @method Phaser.Curves.Spline#getResolution + * @since 3.0.0 + * + * @param {number} divisions - The number of divisions per segment used when approximating the curve. + * + * @return {number} The curve resolution. + */ + getResolution: function (divisions) + { + return divisions * this.points.length; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Spline#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var points = this.points; + + var point = (points.length - 1) * t; + + var intPoint = Math.floor(point); + + var weight = point - intPoint; + + var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; + var p1 = points[intPoint]; + var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; + var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; + + return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * Exports a JSON object containing this curve data. + * + * @method Phaser.Curves.Spline#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Curves.JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + var points = []; + + for (var i = 0; i < this.points.length; i++) + { + points.push(this.points[i].x); + points.push(this.points[i].y); + } + + return { + type: this.type, + points: points + }; + } + +}); + +/** + * Imports a JSON object containing this curve data. + * + * @function Phaser.Curves.Spline.fromJSON + * @since 3.0.0 + * + * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Spline} The spline curve created. + */ +SplineCurve.fromJSON = function (data) +{ + return new SplineCurve(data.points); +}; + +module.exports = SplineCurve; + + +/***/ }, + +/***/ 25410 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Curves + */ + +module.exports = { + Path: __webpack_require__(46669), + MoveTo: __webpack_require__(68618), + + CubicBezier: __webpack_require__(46728), + Curve: __webpack_require__(80021), + Ellipse: __webpack_require__(73825), + Line: __webpack_require__(33951), + QuadraticBezier: __webpack_require__(14744), + Spline: __webpack_require__(42534) +}; + + +/***/ }, + +/***/ 68618 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A MoveTo Curve is a special curve type consisting of a single point. Unlike other curve types, + * it does not draw anything — it simply repositions the current endpoint of a `Path`, analogous + * to the SVG `moveto` command. Use it within a `Phaser.Curves.Path` to create a gap between + * two sub-paths, or to begin drawing from a new position without connecting to the previous curve. + * + * @class MoveTo + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - `x` pixel coordinate. + * @param {number} [y=0] - `y` pixel coordinate. + */ +var MoveTo = new Class({ + + initialize: + + function MoveTo (x, y) + { + /** + * A flag indicating that this curve is inactive and does not contribute to the bounds, length, or rendering of its parent Path. It is always `false` for a MoveTo, which marks it as a positional marker rather than a drawable segment. + * + * @name Phaser.Curves.MoveTo#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * The lone point which this curve consists of. + * + * @name Phaser.Curves.MoveTo#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + }, + + /** + * Returns the single point that this MoveTo curve represents. Because a MoveTo has only one point, the value of `t` is ignored and `p0` is always returned. + * + * @method Phaser.Curves.MoveTo#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * Retrieves the point at given position in the curve. This will always return this curve's only point. + * + * @method Phaser.Curves.MoveTo#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - The position in the path to retrieve, between 0 and 1. Not used. + * @param {Phaser.Math.Vector2} [out] - An optional vector in which to store the point. + * + * @return {Phaser.Math.Vector2} The modified `out` vector, or a new `Vector2` if none was provided. + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * Gets the resolution of this curve. + * + * @method Phaser.Curves.MoveTo#getResolution + * @since 3.0.0 + * + * @return {number} The resolution of this curve. For a MoveTo the value is always 1. + */ + getResolution: function () + { + return 1; + }, + + /** + * Gets the length of this curve. + * + * @method Phaser.Curves.MoveTo#getLength + * @since 3.0.0 + * + * @return {number} The length of this curve. For a MoveTo the value is always 0. + */ + getLength: function () + { + return 0; + }, + + /** + * Converts this curve into a JSON-serializable object. + * + * @method Phaser.Curves.MoveTo#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Curves.JSONCurve} A primitive object with the curve's type and only point. + */ + toJSON: function () + { + return { + type: 'MoveTo', + points: [ + this.p0.x, this.p0.y + ] + }; + } + +}); + +module.exports = MoveTo; + + +/***/ }, + +/***/ 46669 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(83419); +var CubicBezierCurve = __webpack_require__(46728); +var EllipseCurve = __webpack_require__(73825); +var GameObjectFactory = __webpack_require__(39429); +var LineCurve = __webpack_require__(33951); +var MovePathTo = __webpack_require__(68618); +var QuadraticBezierCurve = __webpack_require__(14744); +var Rectangle = __webpack_require__(87841); +var SplineCurve = __webpack_require__(42534); +var Vector2 = __webpack_require__(26099); +var MATH_CONST = __webpack_require__(36383); + +/** + * @classdesc + * A Path combines multiple Curves into one continuous compound curve. It can contain any number of + * Curves of any type, including Line, Bezier, Ellipse, and Spline Curves. Paths are commonly used + * in Phaser to define routes for Game Objects to follow, either via the PathFollower component or + * by sampling points along the Path to drive a Tween or custom movement logic. + * + * A Curve in a Path does not have to start where the previous Curve ends - that is to say, a Path does not + * have to be an uninterrupted curve. Only the order of the Curves influences the actual points on the Path. + * + * @class Path + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The X coordinate of the Path's starting point or a {@link Phaser.Types.Curves.JSONPath}. + * @param {number} [y=0] - The Y coordinate of the Path's starting point. + */ +var Path = new Class({ + + initialize: + + function Path (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + /** + * The name of this Path. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.Curves.Path#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The default number of divisions within a curve. + * + * @name Phaser.Curves.Path#defaultDivisions + * @type {number} + * @default 12 + * @since 3.70.0 + */ + this.defaultDivisions = 12; + + /** + * The list of Curves which make up this Path. + * + * @name Phaser.Curves.Path#curves + * @type {Phaser.Curves.Curve[]} + * @default [] + * @since 3.0.0 + */ + this.curves = []; + + /** + * The cached length of each Curve in the Path. + * + * Used internally by {@link #getCurveLengths}. + * + * @name Phaser.Curves.Path#cacheLengths + * @type {number[]} + * @default [] + * @since 3.0.0 + */ + this.cacheLengths = []; + + /** + * Automatically closes the path. + * + * @name Phaser.Curves.Path#autoClose + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.autoClose = false; + + /** + * The starting point of the Path. + * + * This is not necessarily equivalent to the starting point of the first Curve in the Path. In an empty Path, it's also treated as the ending point. + * + * @name Phaser.Curves.Path#startPoint + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.startPoint = new Vector2(); + + /** + * A temporary vector used to avoid object creation when adding a Curve to the Path. + * + * @name Phaser.Curves.Path#_tmpVec2A + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2A = new Vector2(); + + /** + * A temporary vector used to avoid object creation when adding a Curve to the Path. + * + * @name Phaser.Curves.Path#_tmpVec2B + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2B = new Vector2(); + + if (typeof x === 'object') + { + this.fromJSON(x); + } + else + { + this.startPoint.set(x, y); + } + }, + + /** + * Appends a Curve to the end of the Path. + * + * The Curve does not have to start where the Path ends or, for an empty Path, at its defined starting point. + * + * @method Phaser.Curves.Path#add + * @since 3.0.0 + * + * @param {Phaser.Curves.Curve} curve - The Curve to append. + * + * @return {this} This Path object. + */ + add: function (curve) + { + this.curves.push(curve); + + return this; + }, + + /** + * Creates a circular Ellipse Curve positioned at the end of the Path. + * + * @method Phaser.Curves.Path#circleTo + * @since 3.0.0 + * + * @param {number} radius - The radius of the circle. + * @param {boolean} [clockwise=false] - `true` to create a clockwise circle as opposed to a counter-clockwise circle. + * @param {number} [rotation=0] - The rotation of the circle in degrees. + * + * @return {this} This Path object. + */ + circleTo: function (radius, clockwise, rotation) + { + if (clockwise === undefined) { clockwise = false; } + + return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation); + }, + + /** + * Ensures that the Path is closed. + * + * A closed Path starts and ends at the same point. If the Path is not closed, a straight Line Curve will be created from the ending point directly to the starting point. During the check, the actual starting point of the Path, i.e. the starting point of the first Curve, will be used as opposed to the Path's defined {@link startPoint}, which could differ. + * + * Calling this method on an empty Path will result in an error. + * + * @method Phaser.Curves.Path#closePath + * @since 3.0.0 + * + * @return {this} This Path object. + */ + closePath: function () + { + // Add a line curve if start and end of lines are not connected + var startPoint = this.curves[0].getPoint(0); + var endPoint = this.curves[this.curves.length - 1].getPoint(1); + + if (!startPoint.equals(endPoint)) + { + // This will copy a reference to the vectors, which probably isn't sensible + this.curves.push(new LineCurve(endPoint, startPoint)); + } + + return this; + }, + + /** + * Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points. + * + * @method Phaser.Curves.Path#cubicBezierTo + * @since 3.0.0 + * + * @param {(number|Phaser.Math.Vector2)} x - The x coordinate of the end point. Or, if a Vector2, the p1 value. + * @param {(number|Phaser.Math.Vector2)} y - The y coordinate of the end point. Or, if a Vector2, the p2 value. + * @param {(number|Phaser.Math.Vector2)} control1X - The x coordinate of the first control point. Or, if a Vector2, the p3 value. + * @param {number} [control1Y] - The y coordinate of the first control point. Not used if Vector2s are provided as the first 3 arguments. + * @param {number} [control2X] - The x coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments. + * @param {number} [control2Y] - The y coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments. + * + * @return {this} This Path object. + */ + cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + var p3; + + // Assume they're all Vector2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + p3 = control1X; + } + else + { + p1 = new Vector2(control1X, control1Y); + p2 = new Vector2(control2X, control2Y); + p3 = new Vector2(x, y); + } + + return this.add(new CubicBezierCurve(p0, p1, p2, p3)); + }, + + // Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point + + /** + * Creates a Quadratic Bezier Curve starting at the ending point of the Path. + * + * @method Phaser.Curves.Path#quadraticBezierTo + * @since 3.2.0 + * + * @param {(number|Phaser.Math.Vector2[])} x - The X coordinate of the second control point or, if it's a `Vector2`, the first control point. + * @param {number} [y] - The Y coordinate of the second control point or, if `x` is a `Vector2`, the second control point. + * @param {number} [controlX] - If `x` is not a `Vector2`, the X coordinate of the first control point. + * @param {number} [controlY] - If `x` is not a `Vector2`, the Y coordinate of the first control point. + * + * @return {this} This Path object. + */ + quadraticBezierTo: function (x, y, controlX, controlY) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + + // Assume they're all Vector2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + } + else + { + p1 = new Vector2(controlX, controlY); + p2 = new Vector2(x, y); + } + + return this.add(new QuadraticBezierCurve(p0, p1, p2)); + }, + + /** + * Draws all Curves in the Path to a Graphics Game Object. + * + * @method Phaser.Curves.Path#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [out,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics Game Object to draw to. + * @param {number} [pointsTotal=32] - The number of points to draw for each Curve. Higher numbers result in a smoother curve but require more processing. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object which was drawn to. + */ + draw: function (graphics, pointsTotal) + { + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.draw(graphics, pointsTotal); + } + + return graphics; + }, + + /** + * Creates an ellipse curve positioned at the previous end point, using the given parameters. + * + * @method Phaser.Curves.Path#ellipseTo + * @since 3.0.0 + * + * @param {number} [xRadius=0] - The horizontal radius of ellipse. + * @param {number} [yRadius=0] - The vertical radius of ellipse. + * @param {number} [startAngle=0] - The start angle of the ellipse, in degrees. + * @param {number} [endAngle=360] - The end angle of the ellipse, in degrees. + * @param {boolean} [clockwise=false] - Whether the ellipse angles are given as clockwise (`true`) or counter-clockwise (`false`). + * @param {number} [rotation=0] - The rotation of the ellipse, in degrees. + * + * @return {this} This Path object. + */ + ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + var ellipse = new EllipseCurve(0, 0, xRadius, yRadius, startAngle, endAngle, clockwise, rotation); + + var end = this.getEndPoint(this._tmpVec2A); + + // Calculate where to center the ellipse + var start = ellipse.getStartPoint(this._tmpVec2B); + + end.subtract(start); + + ellipse.x = end.x; + ellipse.y = end.y; + + return this.add(ellipse); + }, + + /** + * Creates a Path from a Path Configuration object. + * + * The provided object should be a {@link Phaser.Types.Curves.JSONPath}, as returned by {@link #toJSON}. Providing a malformed object may cause errors. + * + * @method Phaser.Curves.Path#fromJSON + * @since 3.0.0 + * + * @param {Phaser.Types.Curves.JSONPath} data - The JSON object containing the Path data. + * + * @return {this} This Path object. + */ + fromJSON: function (data) + { + // data should be an object matching the Path.toJSON object structure. + + this.curves = []; + this.cacheLengths = []; + + this.startPoint.set(data.x, data.y); + + this.autoClose = data.autoClose; + + for (var i = 0; i < data.curves.length; i++) + { + var curve = data.curves[i]; + + switch (curve.type) + { + case 'LineCurve': + this.add(LineCurve.fromJSON(curve)); + break; + + case 'EllipseCurve': + this.add(EllipseCurve.fromJSON(curve)); + break; + + case 'SplineCurve': + this.add(SplineCurve.fromJSON(curve)); + break; + + case 'CubicBezierCurve': + this.add(CubicBezierCurve.fromJSON(curve)); + break; + + case 'QuadraticBezierCurve': + this.add(QuadraticBezierCurve.fromJSON(curve)); + break; + } + } + + return this; + }, + + /** + * Returns a Rectangle with a position and size matching the bounds of this Path. + * + * @method Phaser.Curves.Path#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the bounds in. + * @param {number} [accuracy=16] - The accuracy of the bounds calculations. Higher values are more accurate at the cost of calculation speed. + * + * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. + */ + getBounds: function (out, accuracy) + { + if (out === undefined) { out = new Rectangle(); } + if (accuracy === undefined) { accuracy = 16; } + + out.x = Number.MAX_VALUE; + out.y = Number.MAX_VALUE; + + var bounds = new Rectangle(); + var maxRight = MATH_CONST.MIN_SAFE_INTEGER; + var maxBottom = MATH_CONST.MIN_SAFE_INTEGER; + + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.getBounds(bounds, accuracy); + + out.x = Math.min(out.x, bounds.x); + out.y = Math.min(out.y, bounds.y); + + maxRight = Math.max(maxRight, bounds.right); + maxBottom = Math.max(maxBottom, bounds.bottom); + } + + out.right = maxRight; + out.bottom = maxBottom; + + return out; + }, + + /** + * Returns an array containing the length of the Path at the end of each Curve. + * + * The result of this method will be cached to avoid recalculating it in subsequent calls. The cache is only invalidated when the {@link #curves} array changes in length, leading to potential inaccuracies if a Curve in the Path is changed, or if a Curve is removed and another is added in its place. + * + * @method Phaser.Curves.Path#getCurveLengths + * @since 3.0.0 + * + * @return {number[]} An array containing the length of the Path at the end of each one of its Curves. + */ + getCurveLengths: function () + { + // We use cache values if curves and cache array are same length + + if (this.cacheLengths.length === this.curves.length) + { + return this.cacheLengths; + } + + // Get length of sub-curve + // Push sums into cached array + + var lengths = []; + var sums = 0; + + for (var i = 0; i < this.curves.length; i++) + { + sums += this.curves[i].getLength(); + + lengths.push(sums); + } + + this.cacheLengths = lengths; + + return lengths; + }, + + /** + * Returns the Curve that forms the Path at the given normalized location (between 0 and 1). + * + * @method Phaser.Curves.Path#getCurveAt + * @since 3.60.0 + * + * @param {number} t - The normalized location on the Path, between 0 and 1. + * + * @return {?Phaser.Curves.Curve} The Curve that is part of this Path at a given location, or `null` if no curve was found. + */ + getCurveAt: function (t) + { + var d = t * this.getLength(); + var curveLengths = this.getCurveLengths(); + var i = 0; + + while (i < curveLengths.length) + { + if (curveLengths[i] >= d) + { + return this.curves[i]; + } + + i++; + } + + return null; + }, + + /** + * Returns the ending point of the Path. + * + * A Path's ending point is equivalent to the ending point of the last Curve in the Path. For an empty Path, the ending point is at the Path's defined {@link #startPoint}. + * + * @method Phaser.Curves.Path#getEndPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - The object to store the point in. + * + * @return {Phaser.Math.Vector2} The modified `out` object, or a new Vector2 if none was provided. + */ + getEndPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + if (this.curves.length > 0) + { + this.curves[this.curves.length - 1].getPoint(1, out); + } + else + { + out.copy(this.startPoint); + } + + return out; + }, + + /** + * Returns the total length of the Path. + * + * @see {@link #getCurveLengths} + * + * @method Phaser.Curves.Path#getLength + * @since 3.0.0 + * + * @return {number} The total length of the Path. + */ + getLength: function () + { + var lens = this.getCurveLengths(); + + return lens[lens.length - 1]; + }, + + // To get accurate point with reference to + // entire path distance at time t, + // following has to be done: + + // 1. Length of each sub path have to be known + // 2. Locate and identify type of curve + // 3. Get t for the curve + // 4. Return curve.getPointAt(t') + + /** + * Calculates the coordinates of the point at the given normalized location (between 0 and 1) on the Path. + * + * The location is relative to the entire Path, not to an individual Curve. A location of 0.5 is always in the middle of the Path and is thus an equal distance away from both its starting and ending points. In a Path with one Curve, it would be in the middle of the Curve; in a Path with two Curves, it could be anywhere on either one of them depending on their lengths. + * + * @method Phaser.Curves.Path#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The location of the point to return, between 0 and 1. + * @param {Phaser.Math.Vector2} [out] - The object in which to store the calculated point. + * + * @return {?Phaser.Math.Vector2} The modified `out` object, or a new `Vector2` if none was provided. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var d = t * this.getLength(); + var curveLengths = this.getCurveLengths(); + var i = 0; + + while (i < curveLengths.length) + { + if (curveLengths[i] >= d) + { + var diff = curveLengths[i] - d; + var curve = this.curves[i]; + + var segmentLength = curve.getLength(); + var u = (segmentLength === 0) ? 0 : 1 - diff / segmentLength; + + return curve.getPointAt(u, out); + } + + i++; + } + + // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) + { + points.push(points[0]); + } + + return points; + }, + + /** + * Returns a randomly chosen point anywhere on the path. This follows the same rules as `getPoint` in that it may return a point on any Curve inside this path. + * + * When calling this method multiple times, the points are not guaranteed to be equally spaced spatially. + * + * @method Phaser.Curves.Path#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. + * + * @return {Phaser.Math.Vector2} The modified `out` object, or a new `Vector2` if none was provided. + */ + getRandomPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); + }, + + /** + * Divides this Path into a set of equally spaced points. + * + * The resulting points are equally spaced with respect to the points' position on the path, but not necessarily equally spaced spatially. + * + * @method Phaser.Curves.Path#getSpacedPoints + * @since 3.0.0 + * + * @param {number} [divisions=40] - The amount of points to divide this Path into. + * + * @return {Phaser.Math.Vector2[]} A list of the points this path was subdivided into. + */ + getSpacedPoints: function (divisions) + { + if (divisions === undefined) { divisions = 40; } + + var points = []; + + for (var i = 0; i <= divisions; i++) + { + points.push(this.getPoint(i / divisions)); + } + + if (this.autoClose) + { + points.push(points[0]); + } + + return points; + }, + + /** + * Returns the starting point of the Path. + * + * @method Phaser.Curves.Path#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. + * + * @return {Phaser.Math.Vector2} The modified `out` object, or a new Vector2 if none was provided. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.startPoint); + }, + + /** + * Gets a unit vector tangent at a relative position on the path. + * + * @method Phaser.Curves.Path#getTangent + * @since 3.23.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The relative position on the path, [0..1]. + * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. + * + * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) + */ + getTangent: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var d = t * this.getLength(); + var curveLengths = this.getCurveLengths(); + var i = 0; + + while (i < curveLengths.length) + { + if (curveLengths[i] >= d) + { + var diff = curveLengths[i] - d; + var curve = this.curves[i]; + + var segmentLength = curve.getLength(); + var u = (segmentLength === 0) ? 0 : 1 - diff / segmentLength; + + return curve.getTangentAt(u, out); + } + + i++; + } + + return null; + }, + + /** + * Creates a line curve from the previous end point to x/y. + * + * @method Phaser.Curves.Path#lineTo + * @since 3.0.0 + * + * @param {(number|Phaser.Math.Vector2|Phaser.Types.Math.Vector2Like)} x - The X coordinate of the line's end point, or a `Vector2` / `Vector2Like` containing the entire end point. + * @param {number} [y] - The Y coordinate of the line's end point, if a number was passed as the X parameter. + * + * @return {this} This Path object. + */ + lineTo: function (x, y) + { + if (x instanceof Vector2) + { + this._tmpVec2B.copy(x); + } + else if (typeof x === 'object') + { + this._tmpVec2B.setFromObject(x); + } + else + { + this._tmpVec2B.set(x, y); + } + + var end = this.getEndPoint(this._tmpVec2A); + + return this.add(new LineCurve([ end.x, end.y, this._tmpVec2B.x, this._tmpVec2B.y ])); + }, + + /** + * Creates a spline curve starting at the previous end point, using the given points on the curve. + * + * @method Phaser.Curves.Path#splineTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - The points the newly created spline curve should consist of. + * + * @return {this} This Path object. + */ + splineTo: function (points) + { + points.unshift(this.getEndPoint()); + + return this.add(new SplineCurve(points)); + }, + + /** + * Creates a "gap" in this path from the path's current end point to the given coordinates. + * + * After calling this function, this Path's end point will be equal to the given coordinates. + * + * @method Phaser.Curves.Path#moveTo + * @since 3.0.0 + * + * @param {(number|Phaser.Math.Vector2|Phaser.Types.Math.Vector2Like)} x - The X coordinate of the position to move the path's end point to, or a `Vector2` / `Vector2Like` containing the entire new end point. + * @param {number} [y] - The Y coordinate of the position to move the path's end point to, if a number was passed as the X coordinate. + * + * @return {this} This Path object. + */ + moveTo: function (x, y) + { + if (x instanceof Vector2) + { + return this.add(new MovePathTo(x.x, x.y)); + } + else + { + return this.add(new MovePathTo(x, y)); + } + }, + + /** + * Converts this Path to a JSON object containing the path information and its constituent curves. + * + * @method Phaser.Curves.Path#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.Curves.JSONPath} The JSON object containing this path's data. + */ + toJSON: function () + { + var out = []; + + for (var i = 0; i < this.curves.length; i++) + { + out.push(this.curves[i].toJSON()); + } + + return { + type: 'Path', + x: this.startPoint.x, + y: this.startPoint.y, + autoClose: this.autoClose, + curves: out + }; + }, + + /** + * Clears the cached arc lengths and forces them to be recalculated on the next call to + * {@link #getCurveLengths} or any method that depends on it. Call this if you have modified + * a Curve within this Path in-place, since the cache is only automatically invalidated when + * the number of Curves changes. + * + * @method Phaser.Curves.Path#updateArcLengths + * @since 3.0.0 + */ + updateArcLengths: function () + { + this.cacheLengths = []; + + this.getCurveLengths(); + }, + + /** + * Disposes of this Path, clearing its internal references to objects so they can be garbage-collected. + * + * @method Phaser.Curves.Path#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.curves.length = 0; + this.cacheLengths.length = 0; + this.startPoint = undefined; + } + +}); + +/** + * Creates a new Path Object. + * + * @method Phaser.GameObjects.GameObjectFactory#path + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Path. + * @param {number} y - The vertical position of this Path. + * + * @return {Phaser.Curves.Path} The Path Object that was created. + */ +GameObjectFactory.register('path', function (x, y) +{ + return new Path(x, y); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +module.exports = Path; + + +/***/ }, + +/***/ 45893 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Events = __webpack_require__(24882); + +/** + * @callback DataEachCallback + * + * @param {*} parent - The parent object of the DataManager. + * @param {string} key - The key of the value. + * @param {*} value - The value. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Manager provides a way to store, retrieve, and manage arbitrary key-value data on any + * Game Object, System, or Plugin. Each entry is stored by a string key and can hold any value type. + * + * Data changes are communicated through events: a `setdata` event fires when a new key is created, + * and `changedata` / `changedata-key` events fire when an existing value is updated. This makes the + * Data Manager well suited for driving UI, triggering game logic, or syncing state between systems. + * + * The parent object must either extend `EventEmitter` directly, or expose a property called `events` + * that is an instance of `EventEmitter`. + * + * @class DataManager + * @memberof Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {object} parent - The object that this DataManager belongs to. + * @param {Phaser.Events.EventEmitter} [eventEmitter] - The DataManager's event emitter. + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * The object that this DataManager belongs to. + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The DataManager's event emitter. + * + * @name Phaser.Data.DataManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * The data list. + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * The public values list. You can use this to access anything you have stored + * in this Data Manager. For example, if you set a value called `gold` you can + * access it via: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also modify it directly: + * + * ```javascript + * this.data.values.gold += 1000; + * ``` + * + * Doing so will emit a `changedata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. + * + * @name Phaser.Data.DataManager#values + * @type {Object.} + * @default {} + * @since 3.10.0 + */ + this.values = {}; + + /** + * Whether setting data is frozen for this DataManager. + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + if (!parent.hasOwnProperty('sys') && this.events) + { + this.events.once(Events.DESTROY, this.destroy, this); + } + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * this.data.get('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * this.data.get([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + get: function (key) + { + var list = this.list; + + if (Array.isArray(key)) + { + var output = []; + + for (var i = 0; i < key.length; i++) + { + output.push(list[key[i]]); + } + + return output; + } + else + { + return list[key]; + } + }, + + /** + * Retrieves all data values in a new object. + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} All data values. + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Queries the DataManager for the values of keys matching the given regular expression. + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). + * + * @return {Object.} The values of the keys matching the search string. + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * data.set('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `get`: + * + * ```javascript + * data.get('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#set + * @fires Phaser.Data.Events#SET_DATA + * @fires Phaser.Data.Events#CHANGE_DATA + * @fires Phaser.Data.Events#CHANGE_DATA_KEY + * @since 3.0.0 + * + * @generic {any} T + * @genericUse {(string|T)} - [key] + * + * @param {(string|object)} key - The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. + * @param {*} [data] - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {this} This Data Manager instance. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (typeof key === 'string') + { + return this.setValue(key, data); + } + else + { + for (var entry in key) + { + this.setValue(entry, key[entry]); + } + } + + return this; + }, + + /** + * Increases a value for the given key. If the key doesn't already exist in the Data Manager then it is created with a value of 0 before being increased. + * + * When the key is first created, a `setdata` event is emitted. If the key already exists, a `changedata` event + * and a `changedata-key` event are emitted instead, where `key` is replaced with the actual key name. + * + * @method Phaser.Data.DataManager#inc + * @fires Phaser.Data.Events#SET_DATA + * @fires Phaser.Data.Events#CHANGE_DATA + * @fires Phaser.Data.Events#CHANGE_DATA_KEY + * @since 3.23.0 + * + * @param {string} key - The key to change the value for. + * @param {number} [amount=1] - The amount to increase the given key by. Pass a negative value to decrease the key. + * + * @return {this} This Data Manager instance. + */ + inc: function (key, amount) + { + if (this._frozen) + { + return this; + } + + if (amount === undefined) + { + amount = 1; + } + + var value = this.get(key); + + if (value === undefined) + { + value = 0; + } + + this.set(key, (value + amount)); + + return this; + }, + + /** + * Toggles a boolean value for the given key. If the key doesn't already exist in the Data Manager then it is created with a value of `false` before being toggled. + * + * When the key is first created, a `setdata` event is emitted. If the key already exists, a `changedata` event + * and a `changedata-key` event are emitted instead, where `key` is replaced with the actual key name. + * + * @method Phaser.Data.DataManager#toggle + * @fires Phaser.Data.Events#SET_DATA + * @fires Phaser.Data.Events#CHANGE_DATA + * @fires Phaser.Data.Events#CHANGE_DATA_KEY + * @since 3.23.0 + * + * @param {string} key - The key to toggle the value for. + * + * @return {this} This Data Manager instance. + */ + toggle: function (key) + { + if (this._frozen) + { + return this; + } + + this.set(key, !this.get(key)); + + return this; + }, + + /** + * Internal value setter, called automatically by the `set` method. + * + * @method Phaser.Data.DataManager#setValue + * @fires Phaser.Data.Events#SET_DATA + * @fires Phaser.Data.Events#CHANGE_DATA + * @fires Phaser.Data.Events#CHANGE_DATA_KEY + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * @param {*} data - The value to set. + * + * @return {this} This Data Manager instance. + */ + setValue: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.has(key)) + { + // Hit the key getter, which will in turn emit the events. + this.values[key] = data; + } + else + { + var _this = this; + var list = this.list; + var events = this.events; + var parent = this.parent; + + Object.defineProperty(this.values, key, { + + enumerable: true, + + configurable: true, + + get: function () + { + return list[key]; + }, + + set: function (value) + { + if (!_this._frozen) + { + var previousValue = list[key]; + list[key] = value; + + events.emit(Events.CHANGE_DATA, parent, key, value, previousValue); + events.emit(Events.CHANGE_DATA_KEY + key, parent, value, previousValue); + } + } + + }); + + list[key] = data; + + events.emit(Events.SET_DATA, parent, key, data); + } + + return this; + }, + + /** + * Passes all data entries to the given callback. The callback is invoked for every entry in the + * Data Manager, receiving the parent object, the key, the value, and any additional arguments + * provided to this method. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {this} This Data Manager instance. + */ + each: function (callback, context) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Merge the given object of key value pairs into this DataManager. + * + * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) + * will emit a `changedata` event. + * + * @method Phaser.Data.DataManager#merge + * @fires Phaser.Data.Events#SET_DATA + * @fires Phaser.Data.Events#CHANGE_DATA + * @fires Phaser.Data.Events#CHANGE_DATA_KEY + * @since 3.0.0 + * + * @param {Object.} data - The data to merge. + * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. + * + * @return {this} This Data Manager instance. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.setValue(key, data[key]); + } + } + + return this; + }, + + /** + * Remove the value for the given key. + * + * If the key is found in this Data Manager it is removed from the internal lists and a + * `removedata` event is emitted. + * + * You can also pass in an array of keys, in which case all keys in the array will be removed: + * + * ```javascript + * this.data.remove([ 'gold', 'armor', 'health' ]); + * ``` + * + * @method Phaser.Data.DataManager#remove + * @fires Phaser.Data.Events#REMOVE_DATA + * @since 3.0.0 + * + * @param {(string|string[])} key - The key to remove, or an array of keys to remove. + * + * @return {this} This Data Manager instance. + */ + remove: function (key) + { + if (this._frozen) + { + return this; + } + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.removeValue(key[i]); + } + } + else + { + return this.removeValue(key); + } + + return this; + }, + + /** + * Internal value remover, called automatically by the `remove` method. + * + * @method Phaser.Data.DataManager#removeValue + * @private + * @fires Phaser.Data.Events#REMOVE_DATA + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * + * @return {this} This Data Manager instance. + */ + removeValue: function (key) + { + if (this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit(Events.REMOVE_DATA, this.parent, key, data); + } + + return this; + }, + + /** + * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @fires Phaser.Data.Events#REMOVE_DATA + * @since 3.0.0 + * + * @param {string} key - The key of the value to retrieve and delete. + * + * @return {*} The value of the given key. + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit(Events.REMOVE_DATA, this.parent, key, data); + } + + return data; + }, + + /** + * Determines whether the given key is set in this Data Manager. + * + * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - The key to check. + * + * @return {boolean} Returns `true` if the key exists, otherwise `false`. + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts + * to create new values or update existing ones. + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. + * + * @return {this} This Data Manager instance. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * Delete all data in this Data Manager and unfreeze it. + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {this} This Data Manager instance. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + delete this.values[key]; + } + + this._frozen = false; + + return this; + }, + + /** + * Destroys this Data Manager. All stored data is deleted, all event listeners are removed, + * and the reference to the parent object is cleared. This is called automatically when the + * parent emits a `destroy` event. + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off(Events.CHANGE_DATA); + this.events.off(Events.SET_DATA); + this.events.off(Events.REMOVE_DATA); + + this.parent = null; + }, + + /** + * Gets or sets the frozen state of this Data Manager. + * A frozen Data Manager will block all attempts to create new values or update existing ones. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data Manager. + * + * @name Phaser.Data.DataManager#count + * @type {number} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }, + +/***/ 63646 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var DataManager = __webpack_require__(45893); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); + +/** + * @classdesc + * The Data Manager Plugin is a Scene Plugin that provides data storage and retrieval + * functionality for a Scene, integrated with the Scene lifecycle. It extends the base DataManager + * class with automatic event handling for Scene shutdown and destroy events, ensuring that stored + * data and event listeners are properly cleaned up when the Scene stops or is destroyed. + * It is accessed via `scene.data` within any Scene. + * + * @class DataManagerPlugin + * @extends Phaser.Data.DataManager + * @memberof Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that this DataManager belongs to. + */ +var DataManagerPlugin = new Class({ + + Extends: DataManager, + + initialize: + + function DataManagerPlugin (scene) + { + DataManager.call(this, scene, scene.sys.events); + + /** + * A reference to the Scene that this DataManager belongs to. + * + * @name Phaser.Data.DataManagerPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene's Systems. + * + * @name Phaser.Data.DataManagerPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Data.DataManagerPlugin#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.events = this.systems.events; + + this.events.once(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.Data.DataManagerPlugin#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + * + * @method Phaser.Data.DataManagerPlugin#shutdown + * @private + * @since 3.5.0 + */ + shutdown: function () + { + this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * Destroys this DataManagerPlugin, calling the base DataManager destroy method, + * removing all Scene event listeners, and clearing all internal references. + * This is called automatically when the owning Scene is destroyed. + * + * @method Phaser.Data.DataManagerPlugin#destroy + * @since 3.5.0 + */ + destroy: function () + { + DataManager.prototype.destroy.call(this); + + this.events.off(SceneEvents.START, this.start, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('DataManagerPlugin', DataManagerPlugin, 'data'); + +module.exports = DataManagerPlugin; + + +/***/ }, + +/***/ 10700 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Change Data Event. + * + * This event is dispatched by a Data Manager when an item in the data store is changed. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * a change data event from a Game Object you would use: `sprite.on('changedata', listener)`. + * + * This event is dispatched for all items that change in the Data Manager. + * To listen for the change of a specific item, use the `CHANGE_DATA_KEY_EVENT` event. + * + * @event Phaser.Data.Events#CHANGE_DATA + * @type {string} + * @since 3.0.0 + * + * @param {any} parent - A reference to the object that the Data Manager responsible for this event belongs to. + * @param {string} key - The unique key of the data item within the Data Manager. + * @param {any} value - The new value of the item in the Data Manager. + * @param {any} previousValue - The previous value of the item in the Data Manager. + */ +module.exports = 'changedata'; + + +/***/ }, + +/***/ 93608 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Change Data Key Event. + * + * This event is dispatched by a Data Manager when an item in the data store is changed. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * the change of a specific data item from a Game Object you would use: `sprite.on('changedata-key', listener)`, + * where `key` is the unique string key of the data item. For example, if you have a data item stored called `gold` + * then you can listen for `sprite.on('changedata-gold')`. + * + * @event Phaser.Data.Events#CHANGE_DATA_KEY + * @type {string} + * @since 3.16.1 + * + * @param {any} parent - A reference to the object that owns the instance of the Data Manager responsible for this event. + * @param {any} value - The item that was updated in the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. + * @param {any} previousValue - The previous item that was updated in the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. + */ +module.exports = 'changedata-'; + + +/***/ }, + +/***/ 60883 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Data Manager Destroy Event. + * + * The Data Manager will listen for the destroy event from its parent, and then close itself down. + * + * @event Phaser.Data.Events#DESTROY + * @type {string} + * @since 3.50.0 + */ +module.exports = 'destroy'; + + +/***/ }, + +/***/ 69780 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Remove Data Event. + * + * This event is dispatched by a Data Manager when an item is removed from it. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * the removal of a data item on a Game Object you would use: `sprite.on('removedata', listener)`. + * + * @event Phaser.Data.Events#REMOVE_DATA + * @type {string} + * @since 3.0.0 + * + * @param {any} parent - A reference to the object that owns the instance of the Data Manager responsible for this event. + * @param {string} key - The unique key of the data item within the Data Manager. + * @param {any} data - The item that was removed from the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. + */ +module.exports = 'removedata'; + + +/***/ }, + +/***/ 22166 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Set Data Event. + * + * This event is dispatched by a Data Manager when a new item is added to the data store. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * the addition of a new data item on a Game Object you would use: `sprite.on('setdata', listener)`. + * + * @event Phaser.Data.Events#SET_DATA + * @type {string} + * @since 3.0.0 + * + * @param {any} parent - A reference to the object that owns the instance of the Data Manager responsible for this event. + * @param {string} key - The unique key of the data item within the Data Manager. + * @param {any} data - The item that was added to the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. + */ +module.exports = 'setdata'; + + +/***/ }, + +/***/ 24882 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Data.Events + */ + +module.exports = { + + CHANGE_DATA: __webpack_require__(10700), + CHANGE_DATA_KEY: __webpack_require__(93608), + DESTROY: __webpack_require__(60883), + REMOVE_DATA: __webpack_require__(69780), + SET_DATA: __webpack_require__(22166) + +}; + + +/***/ }, + +/***/ 44965 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Data + */ + +module.exports = { + + DataManager: __webpack_require__(45893), + DataManagerPlugin: __webpack_require__(63646), + Events: __webpack_require__(24882) + +}; + + +/***/ }, + +/***/ 7098 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Browser = __webpack_require__(84148); + +/** + * Determines the audio playback capabilities of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.audio` from within any Scene. + * + * @typedef {object} Phaser.Device.Audio + * @since 3.0.0 + * + * @property {boolean} audioData - Can this device play HTML Audio tags? + * @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files? + * @property {boolean} m4a - Can this device play m4a files? + * @property {boolean} aac - Can this device play aac files? + * @property {boolean} flac - Can this device play flac files? + * @property {boolean} mp3 - Can this device play mp3 files? + * @property {boolean} ogg - Can this device play ogg files? + * @property {boolean} opus - Can this device play opus files? + * @property {boolean} wav - Can this device play wav files? + * @property {boolean} webAudio - Does this device have the Web Audio API? + * @property {boolean} webm - Can this device play webm files? + */ +var Audio = { + + flac: false, + aac: false, + audioData: false, + dolby: false, + m4a: false, + mp3: false, + ogg: false, + opus: false, + wav: false, + webAudio: false, + webm: false + +}; + +function init () +{ + if (typeof importScripts === 'function') + { + return Audio; + } + + Audio.audioData = !!(window['Audio']); + + Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); + + var audioElement = document.createElement('audio'); + var result = !!audioElement.canPlayType; + + try + { + if (result) + { + var CanPlay = function (type1, type2) + { + var canPlayType1 = audioElement.canPlayType('audio/' + type1).replace(/^no$/, ''); + + if (type2) + { + return Boolean(canPlayType1 || audioElement.canPlayType('audio/' + type2).replace(/^no$/, '')); + } + else + { + return Boolean(canPlayType1); + } + }; + + // wav Mimetypes accepted: + // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements + + Audio.ogg = CanPlay('ogg; codecs="vorbis"'); + Audio.opus = CanPlay('ogg; codecs="opus"', 'opus'); + Audio.mp3 = CanPlay('mpeg'); + Audio.wav = CanPlay('wav'); + Audio.m4a = CanPlay('x-m4a'); + Audio.aac = CanPlay('aac'); + Audio.flac = CanPlay('flac', 'x-flac'); + Audio.webm = CanPlay('webm; codecs="vorbis"'); + + if (audioElement.canPlayType('audio/mp4; codecs="ec-3"') !== '') + { + if (Browser.edge) + { + Audio.dolby = true; + } + else if (Browser.safari && Browser.safariVersion >= 9) + { + if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) + { + var major = parseInt(RegExp.$1, 10); + var minor = parseInt(RegExp.$2, 10); + + if ((major === 10 && minor >= 11) || major > 10) + { + Audio.dolby = true; + } + } + } + } + } + } + catch (e) + { + // Nothing to do here + } + + return Audio; +} + +module.exports = init(); + + +/***/ }, + +/***/ 84148 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var OS = __webpack_require__(25892); + +/** + * Determines the browser type and version running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.browser` from within any Scene. + * + * @typedef {object} Phaser.Device.Browser + * @since 3.0.0 + * + * @property {boolean} chrome - Set to true if running in Chrome. + * @property {boolean} edge - Set to true if running in Microsoft Edge browser. + * @property {boolean} firefox - Set to true if running in Firefox. + * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). + * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. + * @property {boolean} opera - Set to true if running in Opera. + * @property {boolean} safari - Set to true if running in Safari. + * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle). + * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11 or earlier). + * @property {boolean} es2019 - Set to true if the browser appears to support ES2019 features. + * @property {number} chromeVersion - If running in Chrome this will contain the major version number. + * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. + * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. + * @property {number} safariVersion - If running in Safari this will contain the major version number. + * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} + */ +var Browser = { + + chrome: false, + chromeVersion: 0, + edge: false, + firefox: false, + firefoxVersion: 0, + ie: false, + ieVersion: 0, + mobileSafari: false, + opera: false, + safari: false, + safariVersion: 0, + silk: false, + trident: false, + tridentVersion: 0, + es2019: false + +}; + +function init () +{ + var ua = navigator.userAgent; + + if ((/Edg\/\d+/).test(ua)) + { + Browser.edge = true; + Browser.es2019 = true; + } + else if ((/OPR/).test(ua)) + { + Browser.opera = true; + Browser.es2019 = true; + } + else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) + { + Browser.chrome = true; + Browser.chromeVersion = parseInt(RegExp.$1, 10); + Browser.es2019 = (Browser.chromeVersion > 69); + } + else if ((/Firefox\D+(\d+)/).test(ua)) + { + Browser.firefox = true; + Browser.firefoxVersion = parseInt(RegExp.$1, 10); + Browser.es2019 = (Browser.firefoxVersion > 10); + } + else if ((/AppleWebKit\/(?!.*CriOS)/).test(ua) && OS.iOS) + { + Browser.mobileSafari = true; + Browser.es2019 = true; + } + else if ((/MSIE (\d+\.\d+);/).test(ua)) + { + Browser.ie = true; + Browser.ieVersion = parseInt(RegExp.$1, 10); + } + else if ((/Version\/(\d+\.\d+(\.\d+)?) Safari/).test(ua) && !OS.windowsPhone) + { + Browser.safari = true; + Browser.safariVersion = parseInt(RegExp.$1, 10); + Browser.es2019 = (Browser.safariVersion > 10); + } + else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) + { + Browser.ie = true; + Browser.trident = true; + Browser.tridentVersion = parseInt(RegExp.$1, 10); + Browser.ieVersion = parseInt(RegExp.$3, 10); + } + + // Silk gets its own if clause because its ua also contains 'Safari' + if ((/Silk/).test(ua)) + { + Browser.silk = true; + } + + return Browser; +} + +module.exports = init(); + + +/***/ }, + +/***/ 89289 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CanvasPool = __webpack_require__(27919); + +/** + * Determines the canvas features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.canvasFeatures` from within any Scene. + * + * @typedef {object} Phaser.Device.CanvasFeatures + * @since 3.0.0 + * + * @property {boolean} supportInverseAlpha - Set to true if the browser supports inverted alpha. + * @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes. + */ +var CanvasFeatures = { + + supportInverseAlpha: false, + supportNewBlendModes: false + +}; + +function checkBlendMode () +{ + var pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/'; + var pngEnd = 'AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=='; + + var magenta = new Image(); + + magenta.onload = function () + { + var yellow = new Image(); + + yellow.onload = function () + { + var canvas = CanvasPool.create2D(yellow, 6); + var context = canvas.getContext('2d', { willReadFrequently: true }); + + context.globalCompositeOperation = 'multiply'; + + context.drawImage(magenta, 0, 0); + context.drawImage(yellow, 2, 0); + + if (!context.getImageData(2, 0, 1, 1)) + { + return false; + } + + var data = context.getImageData(2, 0, 1, 1).data; + + CanvasPool.remove(yellow); + + CanvasFeatures.supportNewBlendModes = (data[0] === 255 && data[1] === 0 && data[2] === 0); + }; + + yellow.src = pngHead + '/wCKxvRF' + pngEnd; + }; + + magenta.src = pngHead + 'AP804Oa6' + pngEnd; + + return false; +} + +function checkInverseAlpha () +{ + var canvas = CanvasPool.create2D(this, 2); + var context = canvas.getContext('2d', { willReadFrequently: true }); + + context.fillStyle = 'rgba(10, 20, 30, 0.5)'; + + // Draw a single pixel + context.fillRect(0, 0, 1, 1); + + // Get the color values + var s1 = context.getImageData(0, 0, 1, 1); + + if (s1 === null) + { + return false; + } + + // Plot them to x2 + context.putImageData(s1, 1, 0); + + // Get those values + var s2 = context.getImageData(1, 0, 1, 1); + + var result = (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); + + CanvasPool.remove(this); + + // Compare and return + return result; +} + +function init () +{ + if (typeof importScripts !== 'function' && document !== undefined) + { + CanvasFeatures.supportNewBlendModes = checkBlendMode(); + CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); + } + + return CanvasFeatures; +} + +module.exports = init(); + + +/***/ }, + +/***/ 89357 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var OS = __webpack_require__(25892); +var Browser = __webpack_require__(84148); +var CanvasPool = __webpack_require__(27919); + +/** + * Determines the features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.features` from within any Scene. + * + * @typedef {object} Phaser.Device.Features + * @since 3.0.0 + * + * @property {boolean} canvas - Indicates whether the HTML5 Canvas API (CanvasRenderingContext2D) is available in this browser. Required for the Canvas renderer to function. + * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. This is used for fast pixel copy operations. Will be `null` if it could not be determined, `false` on iOS and Safari where it is known not to work. + * @property {boolean} file - Indicates whether the File, FileReader, FileList, and Blob APIs are all available, enabling file reading operations within the browser. + * @property {boolean} fileSystem - Indicates whether the FileSystem API (requestFileSystem) is available, allowing sandboxed local file storage access. + * @property {boolean} getUserMedia - Indicates whether the getUserMedia API is available and functional. Used for accessing camera and microphone input. Note: older versions of Firefox (below 21) may report support but not actually work correctly. + * @property {boolean} littleEndian - Indicates whether the device uses little-endian byte ordering. Only detected if the browser supports TypedArrays. Will be `null` if endianness could not be determined. + * @property {boolean} localStorage - Indicates whether the Web Storage localStorage API is available for persisting key-value data between browser sessions. + * @property {boolean} pointerLock - Indicates whether the Pointer Lock API is available, which allows the mouse cursor to be hidden and locked to the game canvas for first-person style input. + * @property {boolean} stableSort - Indicates whether the browser's Array.sort implementation is stable, meaning equal elements retain their original relative order after sorting. + * @property {boolean} support32bit - Indicates whether the device supports 32-bit pixel manipulation of canvas image data using ArrayBuffer and typed array views (Uint8ClampedArray / Int32Array). Requires little-endian byte ordering. + * @property {boolean} vibration - Indicates whether the Vibration API is available, enabling haptic feedback on supported mobile devices. + * @property {boolean} webGL - Indicates whether WebGL is available in this browser. Required for the WebGL renderer to function. + * @property {boolean} worker - Indicates whether Web Workers are available, enabling background JavaScript execution on a separate thread. + */ +var Features = { + + canvas: false, + canvasBitBltShift: null, + file: false, + fileSystem: false, + getUserMedia: true, + littleEndian: false, + localStorage: false, + pointerLock: false, + stableSort: false, + support32bit: false, + vibration: false, + webGL: false, + worker: false + +}; + +// Check Little or Big Endian system. +// @author Matt DesLauriers (@mattdesl) +function checkIsLittleEndian () +{ + var a = new ArrayBuffer(4); + var b = new Uint8Array(a); + var c = new Uint32Array(a); + + b[0] = 0xa1; + b[1] = 0xb2; + b[2] = 0xc3; + b[3] = 0xd4; + + if (c[0] === 0xd4c3b2a1) + { + return true; + } + + if (c[0] === 0xa1b2c3d4) + { + return false; + } + else + { + // Could not determine endianness + return null; + } +} + +function init () +{ + if (typeof importScripts === 'function') + { + return Features; + } + + Features.canvas = !!window['CanvasRenderingContext2D']; + + try + { + Features.localStorage = !!localStorage.getItem; + } + catch (error) + { + Features.localStorage = false; + } + + Features.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; + Features.fileSystem = !!window['requestFileSystem']; + + var isUint8 = false; + + var testWebGL = function () + { + if (window['WebGLRenderingContext']) + { + try + { + var canvas = CanvasPool.createWebGL(this); + + var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + + var canvas2D = CanvasPool.create2D(this); + + var ctx2D = canvas2D.getContext('2d', { willReadFrequently: true }); + + // Can't be done on a webgl context + var image = ctx2D.createImageData(1, 1); + + // Test to see if ImageData uses CanvasPixelArray or Uint8ClampedArray. + // @author Matt DesLauriers (@mattdesl) + isUint8 = image.data instanceof Uint8ClampedArray; + + CanvasPool.remove(canvas); + CanvasPool.remove(canvas2D); + + return !!ctx; + } + catch (e) + { + return false; + } + } + + return false; + }; + + Features.webGL = testWebGL(); + + Features.worker = !!window['Worker']; + + Features.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; + + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; + + window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; + + Features.getUserMedia = Features.getUserMedia && !!navigator.getUserMedia && !!window.URL; + + // Older versions of firefox (< 21) apparently claim support but user media does not actually work + if (Browser.firefox && Browser.firefoxVersion < 21) + { + Features.getUserMedia = false; + } + + // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it + // is safer to not try and use the fast copy-over method. + if (!OS.iOS && (Browser.ie || Browser.firefox || Browser.chrome)) + { + Features.canvasBitBltShift = true; + } + + // Known not to work + if (Browser.safari || Browser.mobileSafari) + { + Features.canvasBitBltShift = false; + } + + navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; + + if (navigator.vibrate) + { + Features.vibration = true; + } + + if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined') + { + Features.littleEndian = checkIsLittleEndian(); + } + + Features.support32bit = ( + typeof ArrayBuffer !== 'undefined' && + typeof Uint8ClampedArray !== 'undefined' && + typeof Int32Array !== 'undefined' && + Features.littleEndian !== null && + isUint8 + ); + + return Features; +} + +module.exports = init(); + + +/***/ }, + +/***/ 91639 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Determines the full screen support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.fullscreen` from within any Scene. + * + * @typedef {object} Phaser.Device.Fullscreen + * @since 3.0.0 + * + * @property {boolean} available - Does the browser support the Full Screen API? + * @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode? + * @property {boolean} active - Is the browser currently in fullscreen mode? This is a read-only getter that checks the various vendor-prefixed fullscreen element properties on the document. + * @property {string} cancel - If the browser supports the Full Screen API, this holds the name of the method to call on the document in order to exit fullscreen mode. + * @property {string} request - If the browser supports the Full Screen API, this holds the name of the method to call on a DOM element in order to request fullscreen mode. + */ +var Fullscreen = { + + available: false, + cancel: '', + keyboard: false, + request: '' + +}; + +function init () +{ + if (typeof importScripts === 'function') + { + return Fullscreen; + } + + var i; + + var suffix1 = 'Fullscreen'; + var suffix2 = 'FullScreen'; + + var fs = [ + 'request' + suffix1, + 'request' + suffix2, + 'webkitRequest' + suffix1, + 'webkitRequest' + suffix2, + 'msRequest' + suffix1, + 'msRequest' + suffix2, + 'mozRequest' + suffix2, + 'mozRequest' + suffix1 + ]; + + for (i = 0; i < fs.length; i++) + { + if (document.documentElement[fs[i]]) + { + Fullscreen.available = true; + Fullscreen.request = fs[i]; + break; + } + } + + var cfs = [ + 'cancel' + suffix2, + 'exit' + suffix1, + 'webkitCancel' + suffix2, + 'webkitExit' + suffix1, + 'msCancel' + suffix2, + 'msExit' + suffix1, + 'mozCancel' + suffix2, + 'mozExit' + suffix1 + ]; + + if (Fullscreen.available) + { + for (i = 0; i < cfs.length; i++) + { + if (document[cfs[i]]) + { + Fullscreen.cancel = cfs[i]; + break; + } + } + } + + // Keyboard Input? + // Safari 5.1 says it supports fullscreen keyboard, but is lying. + if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT'] && !(/ Version\/5\.1(?:\.\d+)? Safari\//).test(navigator.userAgent)) + { + Fullscreen.keyboard = true; + } + + Object.defineProperty(Fullscreen, 'active', { get: function () { return !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement); } }); + + return Fullscreen; +} + +module.exports = init(); + + +/***/ }, + +/***/ 31784 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Browser = __webpack_require__(84148); + +/** + * Determines the input support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.input` from within any Scene. + * + * @typedef {object} Phaser.Device.Input + * @since 3.0.0 + * + * @property {?string} wheelEvent - The most modern wheel/scroll event type supported by the browser: `'wheel'` (DOM3), `'mousewheel'` (legacy Chrome/IE/Safari), or `'DOMMouseScroll'` (legacy Firefox). `null` if no wheel event is supported. + * @property {boolean} gamepads - Whether the Gamepad API (`navigator.getGamepads`) is available in this browser, allowing gamepad input to be read. + * @property {boolean} mspointer - Whether the Microsoft Pointer API (`navigator.msPointerEnabled` or `navigator.pointerEnabled`) is available, used for pointer input on older IE/Edge browsers. + * @property {boolean} touch - Whether touch input is supported, detected via the `ontouchstart` event or `navigator.maxTouchPoints`. + */ +var Input = { + + gamepads: false, + mspointer: false, + touch: false, + wheelEvent: null + +}; + +function init () +{ + if (typeof importScripts === 'function') + { + return Input; + } + + if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1)) + { + Input.touch = true; + } + + if (navigator.msPointerEnabled || navigator.pointerEnabled) + { + Input.mspointer = true; + } + + if (navigator.getGamepads) + { + Input.gamepads = true; + } + + // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel + if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window)) + { + // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+ + Input.wheelEvent = 'wheel'; + } + else if ('onmousewheel' in window) + { + // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7. + Input.wheelEvent = 'mousewheel'; + } + else if (Browser.firefox && 'MouseScrollEvent' in window) + { + // FF prior to 17. This should probably be scrubbed. + Input.wheelEvent = 'DOMMouseScroll'; + } + + return Input; +} + +module.exports = init(); + + +/***/ }, + +/***/ 25892 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Determines the operating system of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.os` from within any Scene. + * + * @typedef {object} Phaser.Device.OS + * @since 3.0.0 + * + * @property {boolean} android - Is running on Android? + * @property {boolean} chromeOS - Is running on chromeOS? + * @property {boolean} cordova - Is the game running under Apache Cordova? + * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? + * @property {boolean} desktop - Is running on a desktop? + * @property {boolean} ejecta - Is the game running under Ejecta? + * @property {boolean} electron - Is the game running under GitHub Electron? + * @property {boolean} iOS - Is running on iOS? + * @property {boolean} iPad - Is running on iPad? + * @property {boolean} iPhone - Is running on iPhone? + * @property {boolean} kindle - Is running on an Amazon Kindle? + * @property {boolean} linux - Is running on Linux? + * @property {boolean} macOS - Is running on macOS? + * @property {boolean} node - Is the game running under Node.js? + * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? + * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView + * @property {boolean} windows - Is running on Windows? + * @property {boolean} windowsPhone - Is running on a Windows Phone? + * @property {number} iOSVersion - If running in iOS this will contain the major version number. + * @property {number} pixelRatio - The pixel ratio of the host device. + */ +var OS = { + + android: false, + chromeOS: false, + cordova: false, + crosswalk: false, + desktop: false, + ejecta: false, + electron: false, + iOS: false, + iOSVersion: 0, + iPad: false, + iPhone: false, + kindle: false, + linux: false, + macOS: false, + node: false, + nodeWebkit: false, + pixelRatio: 1, + webApp: false, + windows: false, + windowsPhone: false + +}; + +function init () +{ + if (typeof importScripts === 'function') + { + return OS; + } + + var ua = navigator.userAgent; + + if ((/Windows/).test(ua)) + { + OS.windows = true; + } + else if ((/Mac OS/).test(ua) && !((/like Mac OS/).test(ua))) + { + // Because iOS 13 identifies as Mac OS: + if (navigator.maxTouchPoints && navigator.maxTouchPoints > 2) + { + OS.iOS = true; + OS.iPad = true; + + (navigator.appVersion).match(/Version\/(\d+)/); + + OS.iOSVersion = parseInt(RegExp.$1, 10); + } + else + { + OS.macOS = true; + } + } + else if ((/Android/).test(ua)) + { + OS.android = true; + } + else if ((/Linux/).test(ua)) + { + OS.linux = true; + } + else if ((/iP[ao]d|iPhone/i).test(ua)) + { + OS.iOS = true; + + (navigator.appVersion).match(/OS (\d+)/); + + OS.iOSVersion = parseInt(RegExp.$1, 10); + + OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; + OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; + } + else if ((/Kindle/).test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) + { + OS.kindle = true; + + // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... + // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" + } + else if ((/CrOS/).test(ua)) + { + OS.chromeOS = true; + } + + if ((/Windows Phone/i).test(ua) || (/IEMobile/i).test(ua)) + { + OS.android = false; + OS.iOS = false; + OS.macOS = false; + OS.windows = true; + OS.windowsPhone = true; + } + + var silk = (/Silk/).test(ua); + + if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) + { + OS.desktop = true; + } + + // Windows Phone / Tablet reset + if (OS.windowsPhone || (((/Windows NT/i).test(ua)) && ((/Touch/i).test(ua)))) + { + OS.desktop = false; + } + + // WebApp mode in iOS + if (navigator.standalone) + { + OS.webApp = true; + } + + if (typeof importScripts !== 'function') + { + if (window.cordova !== undefined) + { + OS.cordova = true; + } + + if (window.ejecta !== undefined) + { + OS.ejecta = true; + } + } + + if (typeof process !== 'undefined' && process.versions && process.versions.node) + { + OS.node = true; + } + + if (OS.node && typeof process.versions === 'object') + { + OS.nodeWebkit = !!process.versions['node-webkit']; + + OS.electron = !!process.versions.electron; + } + + if ((/Crosswalk/).test(ua)) + { + OS.crosswalk = true; + } + + OS.pixelRatio = window['devicePixelRatio'] || 1; + + return OS; +} + +module.exports = init(); + + +/***/ }, + +/***/ 43267 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetFastValue = __webpack_require__(95540); + +/** + * Determines the video support of the browser running this Phaser Game instance. + * + * These values are read-only and populated during the boot sequence of the game. + * + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.video` from within any Scene. + * + * @typedef {object} Phaser.Device.Video + * @since 3.0.0 + * + * @property {boolean} h264 - Can this device play h264 mp4 video files? + * @property {boolean} hls - Can this device play hls video files? + * @property {boolean} mov - Can this device play mov video files? + * @property {boolean} mp4 - Can this device play h264 mp4 video files? + * @property {boolean} m4v - Can this device play m4v (typically mp4) video files? + * @property {boolean} ogg - Can this device play ogg video files? + * @property {boolean} vp9 - Can this device play vp9 video files? + * @property {boolean} webm - Can this device play webm video files? + * @property {boolean} hasRequestVideoFrame - Does this device support the `requestVideoFrameCallback` API? + * @property {function} getVideoURL - Given an array of video URLs (or a single URL string), returns an object with `url` and `type` properties for the first entry that can be played by this browser, or `null` if none of the provided formats are supported. + */ +var Video = { + + h264: false, + hls: false, + mov: false, + mp4: false, + m4v: false, + ogg: false, + vp9: false, + webm: false, + hasRequestVideoFrame: false + +}; + +function init () +{ + if (typeof importScripts === 'function') + { + return Video; + } + + var videoElement = document.createElement('video'); + var result = !!videoElement.canPlayType; + var no = /^no$/; + + try + { + if (result) + { + if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(no, '')) + { + Video.ogg = true; + } + + if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(no, '')) + { + // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 + Video.h264 = true; + Video.mp4 = true; + } + + if (videoElement.canPlayType('video/quicktime4; codecs="avc1.42E01E"').replace(no, '')) + { + Video.mov = true; + } + + if (videoElement.canPlayType('video/x-m4v').replace(no, '')) + { + Video.m4v = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(no, '')) + { + Video.webm = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(no, '')) + { + Video.vp9 = true; + } + + if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(no, '')) + { + Video.hls = true; + } + } + } + catch (e) + { + // Nothing to do + } + + if (videoElement.parentNode) + { + videoElement.parentNode.removeChild(videoElement); + } + + Video.getVideoURL = function (urls) + { + if (!Array.isArray(urls)) + { + urls = [ urls ]; + } + + for (var i = 0; i < urls.length; i++) + { + var url = GetFastValue(urls[i], 'url', urls[i]); + + if (url.indexOf('blob:') === 0) + { + return { + url: url, + type: '' + }; + } + + var videoType; + + if (url.indexOf('data:') === 0) + { + videoType = url.split(',')[0].match(/\/(.*?);/); + } + else + { + videoType = url.match(/\.([a-zA-Z0-9]+)($|\?)/); + } + + videoType = GetFastValue(urls[i], 'type', (videoType) ? videoType[1] : '').toLowerCase(); + + if (Video[videoType]) + { + return { + url: url, + type: videoType + }; + } + } + + return null; + }; + + return Video; +} + +module.exports = init(); + + +/***/ }, + +/***/ 82264 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Device class is a collection of properties and functions that describe the device on which the Phaser Game instance is running. + * + * These values are read-only and populated during the boot sequence of the game. They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device` from within any Scene. + * + * @namespace Phaser.Device + * @since 3.0.0 + */ + +/** + * @typedef {object} Phaser.DeviceConf + * + * @property {Phaser.Device.OS} os - The OS Device functions. + * @property {Phaser.Device.Browser} browser - The Browser Device functions. + * @property {Phaser.Device.Features} features - The Features Device functions. + * @property {Phaser.Device.Input} input - The Input Device functions. + * @property {Phaser.Device.Audio} audio - The Audio Device functions. + * @property {Phaser.Device.Video} video - The Video Device functions. + * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. + * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. + */ + +module.exports = { + + os: __webpack_require__(25892), + browser: __webpack_require__(84148), + features: __webpack_require__(89357), + input: __webpack_require__(31784), + audio: __webpack_require__(7098), + video: __webpack_require__(43267), + fullscreen: __webpack_require__(91639), + canvasFeatures: __webpack_require__(89289) + +}; + + +/***/ }, + +/***/ 34664 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circular = __webpack_require__(79980); +var Linear = __webpack_require__(28915); +var Class = __webpack_require__(83419); +var Color = __webpack_require__(40987); +var Interpolate = __webpack_require__(13699); + +/** + * @classdesc + * The ColorBand class represents a transition from one color to another. + * It is used in a {@see Phaser.Display.ColorRamp}, and forms the basis + * of a {@see Phaser.GameObjects.Gradient}. + * + * ColorBand can control the transition by setting a middle point, + * a color space for blending, and an interpolation style. + * + * This class also records `start` and `end` points for use in a ramp. + * These indicate its position within the ramp. + * + * Colors are handled unpremultiplied, so RGB values may be larger than alpha. + * + * @class ColorBand + * @memberof Phaser.Display + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Types.Display.ColorBandConfig} [config] - The configuration to use for the band. + */ +var ColorBand = new Class({ + initialize: function ColorBand (config) + { + if (!config) { config = {}; } + + /** + * Identifies this object as a ColorBand. + * This property is read-only and must not be modified. + * + * @name Phaser.Display.ColorBand#isColorBand + * @type {boolean} + * @since 4.0.0 + * @default true + * @readonly + */ + this.isColorBand = true; + + /** + * The color at the start of the color band. + * + * @name Phaser.Display.ColorBand#colorStart + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.colorStart = new Color(); + + /** + * The color at the end of the color band. + * + * @name Phaser.Display.ColorBand#colorEnd + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.colorEnd = new Color(); + + /** + * The start point of this band within a ColorRamp. + * This value should be normalized within the ramp, + * between 0 (ramp start) and 1 (ramp end). + * + * @name Phaser.Display.ColorBand#start + * @type {number} + * @since 4.0.0 + */ + this.start = config.start || 0; + + /** + * The middle point of this band within a ColorRamp. + * This value should be normalized within the band, + * between 0 (band start) and 1 (band end). + * Middle point alters the shape of the color interpolation. + * + * Mathematically, the gradient should be 0.5 at the middle. + * We use a gamma curve to adjust the gradient. + * Thus, `0.5 = middle^gamma`. + * By the properties of logarithms, therefore, + * `gamma = log base middle of 0.5`. + * + * @name Phaser.Display.ColorBand#middle + * @type {number} + * @since 4.0.0 + */ + this.middle = (config.middle === undefined) ? 0.5 : config.middle; + + /** + * The end point of this band within a ColorRamp. + * This value should be normalized within the ramp, + * between 0 (ramp start) and 1 (ramp end). + * + * @name Phaser.Display.ColorBand#end + * @type {number} + * @since 4.0.0 + */ + this.end = 1; + if (config.end !== undefined) { this.end = config.end; } + else if (config.size !== undefined) { this.end = this.start + config.size; } + + /** + * The color interpolation. + * This can be one of the following codes: + * + * - 0: LINEAR - a straight blend. + * - 1: CURVED - color changes quickly at start and end, + * flattening in the middle. Good for convex surfaces. + * - 2: SINUSOIDAL - color changes quickly in the middle, + * flattening at start and end. Good for smooth transitions. + * - 3: CURVE_START - color changes quickly at the start, + * flattening at the end. + * - 4: CURVE_END - color changes quickly at the end, + * flattening at the start. + * + * Modes 2, 3, and 4 use the circular easing function directly. + * Mode 1 uses a related custom formula based on the unit circle. + * + * @name Phaser.Display.ColorBand#interpolation + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.interpolation = config.interpolation || 0; + + /** + * The color space where interpolation should be done. + * This can be one of the following codes: + * + * - 0: RGBA - channels are blended directly. + * This can produce perceptually inaccurate results, as blending + * in RGB space does not account for how humans perceive color. + * - 1: HSVA_NEAREST - colors are blended in HSVA space, + * better preserving saturation and lightness. + * The hue is blended with the shortest angle, e.g. red and blue + * blend via purple, not green. + * - 2: HSVA_PLUS - as HSVA_NEAREST, but hue angle always increases. + * - 3: HSVA_MINUS - as HSVA_NEAREST, but hue angle always decreases. + * + * @name Phaser.Display.ColorBand#colorSpace + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.colorSpace = config.colorSpace || 0; + + this.setColors(config.colorStart, config.colorEnd); + }, + + /** + * Set the colors of the band, from a variety of color formats. + * + * - A number is expected to be a 24 or 32 bit RGB or ARGB value. + * - A string is expected to be a hex code. + * - An array of numbers is expected to be RGB or RGBA in the range 0-1. + * - A Color object can be used. + * + * @method Phaser.Display.ColorBand#setColors + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} [start=0x000000] - The color at the start of the band. + * @param {number | string | number[] | Phaser.Display.Color} [end] - The color at the end of the band. If not specified, equals `start`. + * @return {this} This ColorBand. + */ + setColors: function (start, end) + { + var alpha; + + if (start === undefined) + { + start = 0x000000; + } + if (end === undefined) + { + end = start; + } + + if (typeof start === 'number') + { + Color.IntegerToColor(start, this.colorStart); + } + else if (typeof start === 'string') + { + Color.HexStringToColor(start, this.colorStart); + } + else if (Array.isArray(start)) + { + alpha = (start[3] === undefined) ? 1 : start[3]; + this.colorStart.setGLTo(start[0], start[1], start[2], alpha); + } + else if (start instanceof Color) + { + this.colorStart.setTo(start.red, start.green, start.blue, start.alpha); + } + + if (typeof end === 'number') + { + Color.IntegerToColor(end, this.colorEnd); + } + else if (typeof end === 'string') + { + Color.HexStringToColor(end, this.colorEnd); + } + else if (Array.isArray(end)) + { + alpha = (end[3] === undefined) ? 1 : end[3]; + this.colorEnd.setGLTo(end[0], end[1], end[2], alpha); + } + else if (end instanceof Color) + { + this.colorEnd.setTo(end.red, end.green, end.blue, end.alpha); + } + + return this; + }, + + /** + * Returns the blended color at a normalized position within this band. + * The middle point gamma curve, interpolation mode, and color space are + * all applied before blending between `colorStart` and `colorEnd`. + * + * @method Phaser.Display.ColorBand#getColor + * @since 4.0.0 + * @param {number} index - The normalized position within the band, where 0 is the band start and 1 is the band end. + * @return {Phaser.Types.Display.ColorObject} The blended color at that position. + */ + getColor: function (index) + { + // Apply middle gamma curve. + var gamma = Math.log(0.5) / Math.log(this.middle); + index = Math.pow(index, gamma); + index = Math.min(Math.max(0, index), 1); + + // Apply interpolation mode. + switch (this.interpolation) + { + case 1: + { + // CURVED + if ((index *= 2) < 1) + { + index = 0.5 * Math.sqrt(1 - (--index * index)); + } + else + { + index = 1 - index; + index = 1 - 0.5 * Math.sqrt(1 - index * index); + } + break; + } + case 2: + { + // SINUSOIDAL or circular + index = Circular.InOut(index); + break; + } + case 3: + { + // CURVE_START + index = Circular.Out(index); + break; + } + case 4: + { + // CURVE_END + index = Circular.In(index); + break; + } + } + + var hsvSign = 0; + if (this.colorSpace === 2) { hsvSign = 1; } + else if (this.colorSpace === 3) { hsvSign = -1; } + var outColor = Interpolate.ColorWithColor( + this.colorStart, + this.colorEnd, + 1, + index, + this.colorSpace !== 0, // Use HSV? + hsvSign + ); + outColor.a = Linear(this.colorStart.alpha, this.colorEnd.alpha, index); + return outColor; + } +}); + +module.exports = ColorBand; + + +/***/ }, + +/***/ 89422 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +var tempMatrix = new Float32Array(20); + +/** + * @classdesc + * The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics + * operations. It provides methods required to modify the color values, such as adjusting + * the brightness, setting a sepia tone, hue rotation and more. + * + * The matrix rows (indices 0, 1, 2, 3, 4 form the first row) + * are summed to create the red, green, blue, and alpha channels in order. + * The matrix columns (indices 0, 5, 10, 15 form the first column) + * describe contributions from the initial channels, + * typically in the range -1 to 1. + * The last column (4, 9, 14, 19) contains an addition, + * expected to be in the range 0-255 (although other values are valid). + * For example, to set the red channel to the contents of the green channel, + * the first row would be [0, 1, 0, 0, 0]. + * To set the red channel to full, regardless of current channels, + * the first row would be [0, 0, 0, 0, 255]. + * + * These operations are the default use, + * but you can use ColorMatrix to conveniently store data for other purposes. + * + * Use the method `getData` to return a Float32Array containing the current color values. + * This shrinks the addition column from the range 0-255 to 0-1 + * (but does not clamp it). + * + * @class ColorMatrix + * @memberof Phaser.Display + * @constructor + * @since 3.50.0 + */ +var ColorMatrix = new Class({ + + initialize: + + function ColorMatrix () + { + /** + * Internal ColorMatrix array. + * + * @name Phaser.Display.ColorMatrix#_matrix + * @type {Float32Array} + * @private + * @since 3.50.0 + */ + this._matrix = new Float32Array(20); + + /** + * The value that determines how much of the original color is used + * when mixing the colors. A value between 0 (all original) and 1 (all final) + * + * @name Phaser.Display.ColorMatrix#alpha + * @type {number} + * @since 3.50.0 + */ + this.alpha = 1; + + /** + * Is the ColorMatrix array dirty? + * + * @name Phaser.Display.ColorMatrix#_dirty + * @type {boolean} + * @private + * @since 3.50.0 + */ + this._dirty = true; + + /** + * The matrix data as a Float32Array. + * + * Returned by the `getData` method. + * + * @name Phaser.Display.ColorMatrix#data + * @type {Float32Array} + * @private + * @since 3.50.0 + */ + this._data = new Float32Array(20); + + this.reset(); + }, + + /** + * Sets this ColorMatrix from the given array of color values. + * + * @method Phaser.Display.ColorMatrix#set + * @since 3.50.0 + * + * @param {(number[]|Float32Array)} value - The ColorMatrix values to set. Must have 20 elements. + * + * @return {this} This ColorMatrix instance. + */ + set: function (value) + { + this._matrix.set(value); + + this._dirty = true; + + return this; + }, + + /** + * Resets the ColorMatrix to default values and also resets + * the `alpha` property back to 1. + * + * @method Phaser.Display.ColorMatrix#reset + * @since 3.50.0 + * + * @return {this} This ColorMatrix instance. + */ + reset: function () + { + var m = this._matrix; + + m.fill(0); + + m[0] = 1; + m[6] = 1; + m[12] = 1; + m[18] = 1; + + this.alpha = 1; + + this._dirty = true; + + return this; + }, + + /** + * Gets the ColorMatrix as a Float32Array. + * + * Can be used directly as a 1fv shader uniform value. + * + * @method Phaser.Display.ColorMatrix#getData + * @since 3.50.0 + * + * @return {Float32Array} The ColorMatrix as a Float32Array. + */ + getData: function () + { + var data = this._data; + + if (this._dirty) + { + data.set(this._matrix); + + data[4] /= 255; + data[9] /= 255; + data[14] /= 255; + data[19] /= 255; + + this._dirty = false; + } + + return data; + }, + + /** + * Changes the brightness of this ColorMatrix by the given amount. + * + * @method Phaser.Display.ColorMatrix#brightness + * @since 3.50.0 + * + * @param {number} [value=0] - The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + brightness: function (value, multiply) + { + if (value === undefined) { value = 0; } + if (multiply === undefined) { multiply = false; } + + var b = value; + + return this.multiply([ + b, 0, 0, 0, 0, + 0, b, 0, 0, 0, + 0, 0, b, 0, 0, + 0, 0, 0, 1, 0 + ], multiply); + }, + + /** + * Changes the saturation of this ColorMatrix by the given amount. + * + * @method Phaser.Display.ColorMatrix#saturate + * @since 3.50.0 + * + * @param {number} [value=0] - The amount of saturation to apply to this ColorMatrix. + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + saturate: function (value, multiply) + { + if (value === undefined) { value = 0; } + if (multiply === undefined) { multiply = false; } + + var x = (value * 2 / 3) + 1; + var y = ((x - 1) * -0.5); + + return this.multiply([ + x, y, y, 0, 0, + y, x, y, 0, 0, + y, y, x, 0, 0, + 0, 0, 0, 1, 0 + ], multiply); + }, + + /** + * Desaturates this ColorMatrix (removes color from it). + * + * @method Phaser.Display.ColorMatrix#desaturate + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + desaturate: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.saturate(-1, multiply); + }, + + /** + * Rotates the hues of this ColorMatrix by the value given. + * + * @method Phaser.Display.ColorMatrix#hue + * @since 3.50.0 + * + * @param {number} [rotation=0] - The amount of hue rotation to apply to this ColorMatrix, in degrees. + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + hue: function (rotation, multiply) + { + if (rotation === undefined) { rotation = 0; } + if (multiply === undefined) { multiply = false; } + + rotation = rotation / 180 * Math.PI; + + var cos = Math.cos(rotation); + var sin = Math.sin(rotation); + var lumR = 0.213; + var lumG = 0.715; + var lumB = 0.072; + + return this.multiply([ + lumR + cos * (1 - lumR) + sin * (-lumR),lumG + cos * (-lumG) + sin * (-lumG),lumB + cos * (-lumB) + sin * (1 - lumB), 0, 0, + lumR + cos * (-lumR) + sin * (0.143),lumG + cos * (1 - lumG) + sin * (0.140),lumB + cos * (-lumB) + sin * (-0.283), 0, 0, + lumR + cos * (-lumR) + sin * (-(1 - lumR)),lumG + cos * (-lumG) + sin * (lumG),lumB + cos * (1 - lumB) + sin * (lumB), 0, 0, + 0, 0, 0, 1, 0 + ], multiply); + }, + + /** + * Sets this ColorMatrix to be grayscale. + * + * @method Phaser.Display.ColorMatrix#grayscale + * @since 3.50.0 + * + * @param {number} [value=1] - The grayscale scale (0 is black). + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + grayscale: function (value, multiply) + { + if (value === undefined) { value = 1; } + if (multiply === undefined) { multiply = false; } + + return this.saturate(-value, multiply); + }, + + /** + * Sets this ColorMatrix to be black and white. + * + * @method Phaser.Display.ColorMatrix#blackWhite + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + blackWhite: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.BLACK_WHITE, multiply); + }, + + /** + * Sets this ColorMatrix to be black, only preserving alpha. + * Useful for cases where you only want the alpha. + * + * @method Phaser.Display.ColorMatrix#black + * @since 4.0.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + black: function (multiply) + { + return this.multiply(ColorMatrix.BLACK, multiply); + }, + + /** + * Change the contrast of this ColorMatrix by the amount given. + * + * @method Phaser.Display.ColorMatrix#contrast + * @since 3.50.0 + * + * @param {number} [value=0] - The amount of contrast to apply to this ColorMatrix. + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + contrast: function (value, multiply) + { + if (value === undefined) { value = 0; } + if (multiply === undefined) { multiply = false; } + + var v = value + 1; + var o = -0.5 * (v - 1); + + return this.multiply([ + v, 0, 0, 0, o, + 0, v, 0, 0, o, + 0, 0, v, 0, o, + 0, 0, 0, 1, 0 + ], multiply); + }, + + /** + * Converts this ColorMatrix to have negative values. + * + * @method Phaser.Display.ColorMatrix#negative + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + negative: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.NEGATIVE, multiply); + }, + + /** + * Apply a desaturated luminance to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#desaturateLuminance + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + desaturateLuminance: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.DESATURATE_LUMINANCE, multiply); + }, + + /** + * Applies a sepia tone to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#sepia + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + sepia: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.SEPIA, multiply); + }, + + /** + * Applies a night vision tone to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#night + * @since 3.50.0 + * + * @param {number} [intensity=0.1] - The intensity of this effect. + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + night: function (intensity, multiply) + { + if (intensity === undefined) { intensity = 0.1; } + if (multiply === undefined) { multiply = false; } + + return this.multiply([ + intensity * (-2.0), -intensity, 0, 0, 0, + -intensity, 0, intensity, 0, 0, + 0, intensity, intensity * 2.0, 0, 0, + 0, 0, 0, 1, 0 + ], multiply); + }, + + /** + * Applies a trippy color tone to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#lsd + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + lsd: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.LSD, multiply); + }, + + /** + * Applies a brown tone to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#brown + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + brown: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.BROWN, multiply); + }, + + /** + * Applies a vintage pinhole color effect to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#vintagePinhole + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + vintagePinhole: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.VINTAGE, multiply); + }, + + /** + * Applies a kodachrome color effect to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#kodachrome + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + kodachrome: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.KODACHROME, multiply); + }, + + /** + * Applies a technicolor color effect to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#technicolor + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + technicolor: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.TECHNICOLOR, multiply); + }, + + /** + * Applies a polaroid color effect to this ColorMatrix. + * + * @method Phaser.Display.ColorMatrix#polaroid + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + polaroid: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.POLAROID, multiply); + }, + + /** + * Applies an alpha-to-brightness color effect to this ColorMatrix. + * This replaces the color with a grayscale depiction of the original alpha, + * where black represents transparency and white represents opacity, + * and sets the alpha to full. + * + * @method Phaser.Display.ColorMatrix#alphaToBrightness + * @since 4.0.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + alphaToBrightness: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.ALPHA_TO_BRIGHTNESS, multiply); + }, + + /** + * Applies an alpha-to-brightness color effect to this ColorMatrix. + * This replaces the color with a grayscale depiction of the original alpha, + * where white represents transparency and black represents opacity, + * and sets the alpha to full. + * + * @method Phaser.Display.ColorMatrix#alphaToBrightnessInverse + * @since 4.0.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + alphaToBrightnessInverse: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.ALPHA_TO_BRIGHTNESS_INVERSE, multiply); + }, + + /** + * Applies a brightness-to-alpha color effect to this ColorMatrix. + * This preserves RGB, but replaces the alpha with the brightness of the color. + * + * @method Phaser.Display.ColorMatrix#brightnessToAlpha + * @since 4.0.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + brightnessToAlpha: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.BRIGHTNESS_TO_ALPHA, multiply); + }, + + /** + * Applies a brightness-to-alpha color effect to this ColorMatrix. + * This preserves RGB, but replaces the alpha with the brightness of the color, + * inverted. + * + * @method Phaser.Display.ColorMatrix#brightnessToAlphaInverse + * @since 4.0.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + brightnessToAlphaInverse: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.BRIGHTNESS_TO_ALPHA_INVERSE, multiply); + }, + + /** + * Shifts the values of this ColorMatrix into BGR order. + * + * @method Phaser.Display.ColorMatrix#shiftToBGR + * @since 3.50.0 + * + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + shiftToBGR: function (multiply) + { + if (multiply === undefined) { multiply = false; } + + return this.multiply(ColorMatrix.SHIFT_BGR, multiply); + }, + + /** + * Multiplies the given matrix `a` against the current `_matrix`. + * + * @method Phaser.Display.ColorMatrix#multiply + * @since 3.50.0 + * + * @param {number[]} a - The 5x4 array to multiply with ColorMatrix._matrix. + * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? + * + * @return {this} This ColorMatrix instance. + */ + multiply: function (a, multiply) + { + if (multiply === undefined) { multiply = false; } + + // Duplicate _matrix into c + + if (!multiply) + { + this.reset(); + } + + var m = this._matrix; + var c = tempMatrix; + + // copy _matrix to tempMatrox + c.set(m); + + m.set([ + // R + (c[0] * a[0]) + (c[1] * a[5]) + (c[2] * a[10]) + (c[3] * a[15]), + (c[0] * a[1]) + (c[1] * a[6]) + (c[2] * a[11]) + (c[3] * a[16]), + (c[0] * a[2]) + (c[1] * a[7]) + (c[2] * a[12]) + (c[3] * a[17]), + (c[0] * a[3]) + (c[1] * a[8]) + (c[2] * a[13]) + (c[3] * a[18]), + (c[0] * a[4]) + (c[1] * a[9]) + (c[2] * a[14]) + (c[3] * a[19]) + c[4], + + // G + (c[5] * a[0]) + (c[6] * a[5]) + (c[7] * a[10]) + (c[8] * a[15]), + (c[5] * a[1]) + (c[6] * a[6]) + (c[7] * a[11]) + (c[8] * a[16]), + (c[5] * a[2]) + (c[6] * a[7]) + (c[7] * a[12]) + (c[8] * a[17]), + (c[5] * a[3]) + (c[6] * a[8]) + (c[7] * a[13]) + (c[8] * a[18]), + (c[5] * a[4]) + (c[6] * a[9]) + (c[7] * a[14]) + (c[8] * a[19]) + c[9], + + // B + (c[10] * a[0]) + (c[11] * a[5]) + (c[12] * a[10]) + (c[13] * a[15]), + (c[10] * a[1]) + (c[11] * a[6]) + (c[12] * a[11]) + (c[13] * a[16]), + (c[10] * a[2]) + (c[11] * a[7]) + (c[12] * a[12]) + (c[13] * a[17]), + (c[10] * a[3]) + (c[11] * a[8]) + (c[12] * a[13]) + (c[13] * a[18]), + (c[10] * a[4]) + (c[11] * a[9]) + (c[12] * a[14]) + (c[13] * a[19]) + c[14], + + // A + (c[15] * a[0]) + (c[16] * a[5]) + (c[17] * a[10]) + (c[18] * a[15]), + (c[15] * a[1]) + (c[16] * a[6]) + (c[17] * a[11]) + (c[18] * a[16]), + (c[15] * a[2]) + (c[16] * a[7]) + (c[17] * a[12]) + (c[18] * a[17]), + (c[15] * a[3]) + (c[16] * a[8]) + (c[17] * a[13]) + (c[18] * a[18]), + (c[15] * a[4]) + (c[16] * a[9]) + (c[17] * a[14]) + (c[18] * a[19]) + c[19] + + ]); + + this._dirty = true; + + return this; + } + +}); + +/** + * A constant array used by the ColorMatrix class for black operations. + * + * @name Phaser.Display.ColorMatrix.BLACK + * @const + * @type {number[]} + * @since 4.0.0 + */ +ColorMatrix.BLACK = [ + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0 +]; + +/** + * A constant array used by the ColorMatrix class for black_white operations. + * + * @name Phaser.Display.ColorMatrix.BLACK_WHITE + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.BLACK_WHITE = [ 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for negative operations. + * + * @name Phaser.Display.ColorMatrix.NEGATIVE + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.NEGATIVE = [ -1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for desaturated luminance operations. + * + * @name Phaser.Display.ColorMatrix.DESATURATE_LUMINANCE + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.DESATURATE_LUMINANCE = [ 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for sepia operations. + * + * @name Phaser.Display.ColorMatrix.SEPIA + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.SEPIA = [ 0.393, 0.7689999, 0.18899999, 0, 0, 0.349, 0.6859999, 0.16799999, 0, 0, 0.272, 0.5339999, 0.13099999, 0, 0, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for lsd operations. + * + * @name Phaser.Display.ColorMatrix.LSD + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.LSD = [ 2, -0.4, 0.5, 0, 0, -0.5, 2, -0.4, 0, 0, -0.4, -0.5, 3, 0, 0, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for brown operations. + * + * @name Phaser.Display.ColorMatrix.BROWN + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.BROWN = [ 0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873, -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127, 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for vintage pinhole operations. + * + * @name Phaser.Display.ColorMatrix.VINTAGE + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.VINTAGE = [ 0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123, 0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591, 0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for kodachrome operations. + * + * @name Phaser.Display.ColorMatrix.KODACHROME + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.KODACHROME = [ 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502, -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203, -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for technicolor operations. + * + * @name Phaser.Display.ColorMatrix.TECHNICOLOR + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.TECHNICOLOR = [ 1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337, -0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398, -0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for polaroid shift operations. + * + * @name Phaser.Display.ColorMatrix.POLAROID + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.POLAROID = [ 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016, 1.483, 0, 0, 0, 0, 0, 1, 0 ]; + +/** + * A constant array used by the ColorMatrix class for alpha-to-brightness operations. + * + * @name Phaser.Display.ColorMatrix.ALPHA_TO_BRIGHTNESS + * @const + * @type {number[]} + * @since 4.0.0 + */ +ColorMatrix.ALPHA_TO_BRIGHTNESS = [ + 0, 0, 0, 1, 0, + 0, 0, 0, 1, 0, + 0, 0, 0, 1, 0, + 0, 0, 0, 0, 255 +]; + +/** + * A constant array used by the ColorMatrix class for inverse alpha-to-brightness operations. + * + * @name Phaser.Display.ColorMatrix.ALPHA_TO_BRIGHTNESS_INVERSE + * @const + * @type {number[]} + * @since 4.0.0 + */ +ColorMatrix.ALPHA_TO_BRIGHTNESS_INVERSE = [ + 0, 0, 0, -1, 255, + 0, 0, 0, -1, 255, + 0, 0, 0, -1, 255, + 0, 0, 0, 0, 255 +]; + +/** + * A constant array used by the ColorMatrix class for brightness-to-alpha operations. + * + * @name Phaser.Display.ColorMatrix.BRIGHTNESS_TO_ALPHA + * @const + * @type {number[]} + * @since 4.0.0 + */ +ColorMatrix.BRIGHTNESS_TO_ALPHA = [ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0.3, 0.6, 0.1, 0, 0 +]; + +/** + * A constant array used by the ColorMatrix class for inverse brightness-to-alpha operations. + * + * @name Phaser.Display.ColorMatrix.BRIGHTNESS_TO_ALPHA_INVERSE + * @const + * @type {number[]} + * @since 4.0.0 + */ +ColorMatrix.BRIGHTNESS_TO_ALPHA_INVERSE = [ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + -0.3, -0.6, -0.1, 0, 255 +]; + +/** + * A constant array used by the ColorMatrix class for shift BGR operations. + * + * @name Phaser.Display.ColorMatrix.SHIFT_BGR + * @const + * @type {number[]} + * @since 3.60.0 + */ +ColorMatrix.SHIFT_BGR = [ 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]; + +module.exports = ColorMatrix; + + +/***/ }, + +/***/ 73043 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Linear = __webpack_require__(28915); +var Utils = __webpack_require__(70554); +var Class = __webpack_require__(83419); +var UUID = __webpack_require__(45650); +var ColorBand = __webpack_require__(34664); + +var getTint = Utils.getTintFromFloats; + +/** + * @classdesc + * The ColorRamp class represents a series of color transitions. + * It is intended for use in a {@see Phaser.GameObjects.Gradient}. + * + * You should make sure that your bands are arranged end-to-end, + * with no gaps. The Gradient shader assumes this is so. + * You may leave gaps at the start and end. + * Overlaps and gaps may not act as expected. + * + * By default, ColorRamp stores its data for use on the GPU + * in a data texture. This is updated automatically on creation + * and when you run `setBands()`, but if you edit the bands manually, + * you should run `encode()` to rebuild the texture. + * We don't update it automatically because we don't want to waste cycles + * on rebuilds that you're about to overwrite. + * + * @class ColorRamp + * @memberof Phaser.Display + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The current scene. + * @param {Phaser.Types.Display.ColorBandConfig | Phaser.Display.ColorBand | Array} bands - The bands which make up this ramp. This can be one entry or an array, and can be configs or existing instances. A band count over 1048576 may be unsafe. + * @param {boolean} [gpuEncode=true] - Whether to create a data texture to use this ramp in shaders. + */ +var ColorRamp = new Class({ + initialize: function ColorRamp (scene, bands, gpuEncode) + { + if (gpuEncode === undefined) { gpuEncode = true; } + + /** + * The scene where the ColorRamp was created. + * + * @name Phaser.Display.ColorRamp#scene + * @type {Phaser.Scene} + * @since 4.0.0 + * @readonly + */ + this.scene = scene; + + /** + * The color bands that make up this ramp. + * + * @name Phaser.Display.ColorRamp#bands + * @type {Phaser.Display.ColorBand[]} + * @since 4.0.0 + */ + this.bands = []; + + /** + * Whether to encode the ramp for shaders to use on the GPU. + * An encoded ramp is stored as a texture. + * + * @name Phaser.Display.ColorRamp#gpuEncode + * @type {boolean} + * @since 4.0.0 + * @default true + */ + this.gpuEncode = gpuEncode; + + /** + * The Phaser Texture wrapping the GPU data texture for this ramp. + * This is registered with the Scene's Texture Manager under a unique key + * so it can be referenced elsewhere. It is not intended for display. + * + * @name Phaser.Display.ColorRamp#dataTexture + * @type {?Phaser.Textures.Texture} + * @since 4.0.0 + * @readonly + */ + this.dataTexture = null; + + /** + * The texture containing the ramp encoded for the GPU. + * This is used internally by effects such as the Gradient game object + * to read complex ramp data. + * + * @name Phaser.Display.ColorRamp#glTexture + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + * @readonly + */ + this.glTexture = null; + + /** + * The texel index which contains the first band data + * in `glTexture` if it has been encoded. + * This is used internally. + * + * @name Phaser.Display.ColorRamp#dataTextureFirstBand + * @type {number} + * @since 4.0.0 + * @readonly + */ + this.dataTextureFirstBand = 0; + + /** + * The number of levels in the band tree. + * This is used internally to decode the data texture. + * + * @name Phaser.Display.ColorRamp#bandTreeDepth + * @type {number} + * @since 4.0.0 + * @readonly + */ + this.bandTreeDepth = 0; + + /** + * The resolution of the data texture, if it has been encoded. + * This is used internally. + * + * @name Phaser.Display.ColorRamp#dataTextureResolution + * @type {number[]} + * @since 4.0.0 + * @readonly + */ + this.dataTextureResolution = [ 0, 0 ]; + + this.setBands(bands); + }, + + /** + * Set or replace the color bands in this ramp. + * Use this after creation to update the bands. + * + * This will re-encode the data texture if `gpuEncode` is set + * and `encode` is not `false`. + * + * @method Phaser.Display.ColorRamp#setBands + * @since 4.0.0 + * + * @param {Phaser.Types.Display.ColorBandConfig | Phaser.Display.ColorBand | Array} bands - The bands to make up this ramp. This can be one entry or an array, and can be configs or existing instances. + * @param {boolean} [encode=true] - Whether to encode the new ramp data to a data texture for use in shaders. + * + * @return {this} - This ColorRamp instance. + */ + setBands: function (bands, encode) + { + this.bands.length = 0; + + if (!Array.isArray(bands)) + { + bands = [ bands ]; + } + + var lastEnd = 0; + + for (var i = 0; i < bands.length; i++) + { + var band = bands[i]; + if (band.isColorBand) + { + this.bands.push(band); + lastEnd = band.end; + continue; + } + + // `band` must be a config object. + if (band.start === undefined) + { + band = Object.assign({ start: lastEnd }, band); + } + var newBand = new ColorBand(band); + this.bands.push(newBand); + lastEnd = newBand.end; + } + + if ((encode !== false) && this.gpuEncode) + { + this.encode(); + } + + return this; + }, + + /** + * Encode a data texture from the color ramp bands. + * + * This process runs automatically when `gpuEncode` is enabled + * and the bands are set or updated with `setBands`. + * If you modify the bands directly, you must call `encode` yourself. + * + * The data is encoded in texels as follows: + * + * Numbers are encoded in "RG.BA" form. + * The number equals R * 255 + G + B / 255 + A / 255 / 255. + * + * - First 2 texels: start and end. + * - Start is the start of the first band. + * - End is the end of the last band. + * - Next block of texels: binary symmetrical tree of band ranges, + * represented as the end value of the midpoint band. + * - Final block of texels, starting at `dataTextureFirstBand`: + * the band data, in blocks of 3: + * - colorStart + * - colorEnd + * - colorSpace * 255 + interpolation + (middle / 2) + * + * The binary symmetrical tree breaks the bands list in half + * with every node. It is intended to quickly find the band corresponding + * to a given progress along the ramp. + * For example, a ramp with 10 bands would store the ends in this order: + * + * `[ 7, 3, 11, 1, 5, 9, 13, 0, 2, 4, 6, 8, 10, 12, 14 ]` + * + * But because it doesn't have bands from index 10 and up, it's actually: + * + * `[ 7, 3, 9, 1, 5, 9, 9, 0, 2, 4, 6, 8, 9, 9, 9 ]` + * + * Note that, if you change the number of bands in the ramp, + * `dataTexture` may no longer have the correct resolution. + * It is not intended for display. + * + * @method Phaser.Display.ColorRamp#encode + * @since 4.0.0 + */ + encode: function () + { + var bandCount = this.bands.length; + var bandTreeDepth = Math.ceil(Math.log2(bandCount)); + this.bandTreeDepth = bandTreeDepth; + + // Binary tree nodes necessary to hold all bands symmetrically + var bandTreeSize = Math.pow(2, bandTreeDepth) - 1; + var BYTES_FOR_START_END = 8; // Start, end + var BYTES_PER_BRANCH = 4; // Split point + var BYTES_PER_BAND = 12; // Color start, color end, interpolation mode + color mode + middle + + var dataSize = + BYTES_FOR_START_END + + BYTES_PER_BRANCH * bandTreeSize + + BYTES_PER_BAND * bandCount; + + var width = dataSize / 4; + var height = 1; + if (width > 4096) + { + height = Math.ceil(width / 4096); + width = 4096; + } + this.dataTextureResolution[0] = width; + this.dataTextureResolution[1] = height; + + var data = new ArrayBuffer(width * height * 4); + var u32 = new Uint32Array(data); + var u8 = new Uint8Array(data); + var index32 = 0; + var FLOAT_FACTOR = 256 * 256; // Encode floating point numbers as integers. + + // Encode start and end as RG.BA + u32[index32++] = Math.round(this.bands[0].start * FLOAT_FACTOR); + u32[index32++] = Math.round(this.bands[this.bands.length - 1].end * FLOAT_FACTOR); + + // Encode tree nodes. + // Each tree node is a split point in RG.BA form. + for (var depth = 0; depth <= bandTreeDepth; depth++) + { + var maxBreadth = Math.pow(2, depth); + for (var breadth = 1; breadth < maxBreadth; breadth += 2) + { + var bandIndex = Math.floor(bandTreeSize * breadth / maxBreadth); + var band = this.bands[Math.min(bandIndex, bandCount - 1)]; + u32[index32++] = Math.round(band.end * FLOAT_FACTOR); + } + } + + // We are beginning the band encoding region. + this.dataTextureFirstBand = index32; + + // Each band is encoded as colorStart, colorEnd, + // and a composite value of colorMode, interpolationMode, middle. + for (var i = 0; i < bandCount; i++) + { + band = this.bands[i]; + + // Encode colors so they'll appear correct in the texture. + var a = band.colorStart; + var b = band.colorEnd; + u32[index32++] = getTint(a.blueGL, a.greenGL, a.redGL, a.alphaGL); + u32[index32++] = getTint(b.blueGL, b.greenGL, b.redGL, b.alphaGL); + + // Encode other data as a composite in RG.BA form. + var colorSpace = band.colorSpace * 255; + var interpolation = band.interpolation; + var middle = band.middle / 2; + u32[index32++] = FLOAT_FACTOR * (colorSpace + interpolation + middle); + } + + if (!this.glTexture) + { + var textureWrapper = this.scene.renderer.createUint8ArrayTexture(u8, width, height, false, false); + this.glTexture = textureWrapper; + + var textureKey = UUID(); + while (this.scene.textures.exists(textureKey)) + { + textureKey = UUID(); + } + + this.dataTexture = this.scene.textures.addGLTexture(textureKey, textureWrapper); + } + else + { + var d = this.glTexture; + d.update(u8, width, height, d.flipY, d.wrapS, d.wrapT, d.minFilter, d.magFilter, d.format); + } + }, + + /** + * Fix the fit of bands within this ColorRamp. + * + * This sets the start of each band to the end of the previous band, + * ensuring that there are no gaps. + * + * Optionally, you can define start and end values to stretch the ramp + * to some specific range, e.g. 0-1. + * + * By default, any band that is now 0 length will be removed. + * + * @method Phaser.Display.ColorRamp#fixFit + * @since 4.0.0 + * @param {number} start - Override the start of the first band. + * @param {number} end - Override the end of the last band. + * @param {boolean} purgeZeroLength - Whether to discard bands that now have 0 size. + * @param {boolean} encode - Whether to reencode the data texture. + * @return {this} - This ColorRamp instance. + */ + fixFit: function (start, end, purgeZeroLength, encode) + { + var bands = this.bands; + if (bands.length === 0) { return this; } + + if (purgeZeroLength === undefined) { purgeZeroLength = true; } + if (encode === undefined) { encode = true; } + + if (start !== undefined) + { + bands[0].start = start; + } + if (end !== undefined) + { + bands[bands.length - 1].end = end; + } + + for (var i = 0; i < bands.length - 1; i++) + { + var band = bands[i]; + var bandNext = bands[i + 1]; + bandNext.start = band.end; + if (bandNext.start > bandNext.end) + { + bandNext.end = bandNext.start; + } + } + + if (purgeZeroLength) + { + this.bands = bands.filter(function (band) + { + return band.start < band.end; + }); + } + + if (encode) + { + this.encode(); + } + + return this; + }, + + /** + * Split a band from this ramp into several bands, and insert them into the ramp. + * + * You can choose whether to "quantize" the bands, where each of them has + * a flat color. + * + * @method Phaser.Display.ColorRamp#splitBand + * @since 4.0.0 + * @param {number | Phaser.Display.ColorBand} band - The band to split, either an index on this ramp or the band instance. The band must be on this ramp. + * @param {number} steps - The number of bands to create. + * @param {boolean} [quantize=false] - Whether to quantize the bands to a single color. + * @param {boolean} [encode=true] - Whether to rebuild the data texture. + * @return {this} This ColorRamp instance. + */ + splitBand: function (band, steps, quantize, encode) + { + if (steps === 0) { return this; } + if (steps === undefined) { steps = 2; } + if (encode === undefined) { encode = true; } + var index = 0; + if (typeof band === 'number') + { + index = band; + band = this.bands[band]; + } + else + { + index = this.bands.indexOf(band); + if (index === -1) { return this; } + } + if (!band) { return this; } + + this.bands.splice(index, 1); + + for (var i = 0; i < steps; i++) + { + var low = i / steps; + var high = (i + 1) / steps; + if (quantize) + { + low = i / (steps - 1); + high = (i + 1) / (steps - 1); + } + + var newColorStart = band.getColor(low); + var newColorEnd = band.getColor(high); + if (quantize) { newColorEnd = newColorStart; } + + var newBand = new ColorBand({ + colorStart: [ + newColorStart.r / 255, + newColorStart.g / 255, + newColorStart.b / 255, + newColorStart.a / 255 + ], + colorEnd: [ + newColorEnd.r / 255, + newColorEnd.g / 255, + newColorEnd.b / 255, + newColorEnd.a / 255 + ], + start: Linear(band.start, band.end, low), + end: Linear(band.start, band.end, high), + middle: band.middle, + interpolation: band.interpolation, + colorSpace: band.colorSpace + }); + this.bands.splice(index++, 0, newBand); + } + + if (encode) { this.encode(); } + + return this; + }, + + /** + * Get the color value at the given index within this ramp. + * + * If there is no band at that location, the color is transparent. + * + * @method Phaser.Display.ColorRamp#getColor + * @param {number} index - Index of the color to get, from 0 (start) to 1 (end). + * @return {Phaser.Types.Display.ColorObject} The color at that index. + */ + getColor: function (index) + { + var band; + for (var i = 0; i < this.bands.length; i++) + { + var b = this.bands[i]; + if (b.start <= index && b.end >= index) + { + band = b; + break; + } + } + if (!band) + { + return { + r: 0, + g: 0, + b: 0, + a: 0, + color: 0x000000 + }; + } + index = (index - band.start) / (band.end - band.start); + return band.getColor(index); + }, + + /** + * Destroy this ColorRamp. + * If it has a data texture, destroy it. + * + * @method Phaser.Display.ColorRamp#destroy + * @since 4.0.0 + */ + destroy: function () + { + this.scene = null; + if (this.dataTexture) + { + this.dataTexture.destroy(); + } + } +}); + +module.exports = ColorRamp; + + +/***/ }, + +/***/ 51767 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var NOOP = __webpack_require__(29747); + +/** + * @classdesc + * The RGB class holds a single color value expressed as normalized red, green, and blue + * components, each in the range 0 to 1. It is used internally by WebGL pipelines and other + * Phaser systems that need to track color state efficiently. Changes to any component + * automatically set the `dirty` flag and invoke an optional `onChangeCallback`, making it + * straightforward to react to color mutations without manual polling. + * + * @class RGB + * @memberof Phaser.Display + * @constructor + * @since 3.50.0 + * + * @param {number} [red=0] - The red color value. A number between 0 and 1. + * @param {number} [green=0] - The green color value. A number between 0 and 1. + * @param {number} [blue=0] - The blue color value. A number between 0 and 1. + */ +var RGB = new Class({ + + initialize: + + function RGB (red, green, blue) + { + /** + * Cached RGB values. + * + * @name Phaser.Display.RGB#_rgb + * @type {number[]} + * @private + * @since 3.50.0 + */ + this._rgb = [ 0, 0, 0 ]; + + /** + * This callback will be invoked each time one of the RGB color values change. + * + * The callback receives the red, green, and blue values as three separate numeric + * arguments, each in the range 0 to 1. + * + * @name Phaser.Display.RGB#onChangeCallback + * @type {function} + * @since 3.50.0 + */ + this.onChangeCallback = NOOP; + + /** + * Is this color dirty? + * + * @name Phaser.Display.RGB#dirty + * @type {boolean} + * @since 3.50.0 + */ + this.dirty = false; + + this.set(red, green, blue); + }, + + /** + * Sets the red, green and blue values of this RGB object, flags it as being + * dirty and then invokes the `onChangeCallback`, if set. + * + * @method Phaser.Display.RGB#set + * @since 3.50.0 + * + * @param {number} [red=0] - The red color value. A number between 0 and 1. + * @param {number} [green=0] - The green color value. A number between 0 and 1. + * @param {number} [blue=0] - The blue color value. A number between 0 and 1. + * + * @return {this} This RGB instance. + */ + set: function (red, green, blue) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + + this._rgb = [ red, green, blue ]; + + this.onChange(); + + return this; + }, + + /** + * Compares the given rgb parameters with those in this object and returns + * a boolean `true` value if they are equal, otherwise it returns `false`. + * + * @method Phaser.Display.RGB#equals + * @since 3.50.0 + * + * @param {number} red - The red value to compare with this object. + * @param {number} green - The green value to compare with this object. + * @param {number} blue - The blue value to compare with this object. + * + * @return {boolean} `true` if the given values match those in this object, otherwise `false`. + */ + equals: function (red, green, blue) + { + var rgb = this._rgb; + + return (rgb[0] === red && rgb[1] === green && rgb[2] === blue); + }, + + /** + * Internal on change handler. Sets this object as being dirty and + * then invokes the `onChangeCallback`, if set, passing in the + * new RGB values. + * + * @method Phaser.Display.RGB#onChange + * @since 3.50.0 + */ + onChange: function () + { + this.dirty = true; + + var rgb = this._rgb; + + this.onChangeCallback.call(this, rgb[0], rgb[1], rgb[2]); + }, + + /** + * The red color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback`, if set. + * + * @name Phaser.Display.RGB#r + * @type {number} + * @since 3.50.0 + */ + r: { + + get: function () + { + return this._rgb[0]; + }, + + set: function (value) + { + this._rgb[0] = value; + this.onChange(); + } + + }, + + /** + * The green color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback`, if set. + * + * @name Phaser.Display.RGB#g + * @type {number} + * @since 3.50.0 + */ + g: { + + get: function () + { + return this._rgb[1]; + }, + + set: function (value) + { + this._rgb[1] = value; + this.onChange(); + } + + }, + + /** + * The blue color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback`, if set. + * + * @name Phaser.Display.RGB#b + * @type {number} + * @since 3.50.0 + */ + b: { + + get: function () + { + return this._rgb[2]; + }, + + set: function (value) + { + this._rgb[2] = value; + this.onChange(); + } + + }, + + /** + * Destroys this RGB instance by nulling the `onChangeCallback` reference, + * releasing any external listener held by this object. + * + * @method Phaser.Display.RGB#destroy + * @since 3.50.0 + */ + destroy: function () + { + this.onChangeCallback = null; + } + +}); + +module.exports = RGB; + + +/***/ }, + +/***/ 60461 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ALIGN_CONST = { + + /** + * A constant representing a top-left alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_LEFT + * @since 3.0.0 + * @type {number} + */ + TOP_LEFT: 0, + + /** + * A constant representing a top-center alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_CENTER + * @since 3.0.0 + * @type {number} + */ + TOP_CENTER: 1, + + /** + * A constant representing a top-right alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_RIGHT + * @since 3.0.0 + * @type {number} + */ + TOP_RIGHT: 2, + + /** + * A constant representing a left-top alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_TOP + * @since 3.0.0 + * @type {number} + */ + LEFT_TOP: 3, + + /** + * A constant representing a left-center alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_CENTER + * @since 3.0.0 + * @type {number} + */ + LEFT_CENTER: 4, + + /** + * A constant representing a left-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_BOTTOM + * @since 3.0.0 + * @type {number} + */ + LEFT_BOTTOM: 5, + + /** + * A constant representing a center alignment or position. + * @constant + * @name Phaser.Display.Align.CENTER + * @since 3.0.0 + * @type {number} + */ + CENTER: 6, + + /** + * A constant representing a right-top alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_TOP + * @since 3.0.0 + * @type {number} + */ + RIGHT_TOP: 7, + + /** + * A constant representing a right-center alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_CENTER + * @since 3.0.0 + * @type {number} + */ + RIGHT_CENTER: 8, + + /** + * A constant representing a right-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_BOTTOM + * @since 3.0.0 + * @type {number} + */ + RIGHT_BOTTOM: 9, + + /** + * A constant representing a bottom-left alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_LEFT + * @since 3.0.0 + * @type {number} + */ + BOTTOM_LEFT: 10, + + /** + * A constant representing a bottom-center alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_CENTER + * @since 3.0.0 + * @type {number} + */ + BOTTOM_CENTER: 11, + + /** + * A constant representing a bottom-right alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_RIGHT + * @since 3.0.0 + * @type {number} + */ + BOTTOM_RIGHT: 12 + +}; + +module.exports = ALIGN_CONST; + + +/***/ }, + +/***/ 54312 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetCenterX = __webpack_require__(35893); +var SetBottom = __webpack_require__(86327); +var SetCenterX = __webpack_require__(88417); + +/** + * Takes a given Game Object and aligns it so that its bottom edge matches the bottom edge of the `alignIn` Game Object, with its horizontal center aligned to the horizontal center of `alignIn`. + * + * @function Phaser.Display.Align.In.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }, + +/***/ 46768 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var SetBottom = __webpack_require__(86327); +var SetLeft = __webpack_require__(385); + +/** + * Takes a given Game Object and aligns it so that it is positioned in the bottom-left of the other. + * + * @function Phaser.Display.Align.In.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }, + +/***/ 35827 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetRight = __webpack_require__(54380); +var SetBottom = __webpack_require__(86327); +var SetRight = __webpack_require__(40136); + +/** + * Takes a given Game Object and aligns it so that it is positioned inside the bottom-right corner of the `alignIn` Game Object. The right edge of `gameObject` is matched to the right edge of `alignIn`, and the bottom edge of `gameObject` is matched to the bottom edge of `alignIn`. + * + * @function Phaser.Display.Align.In.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }, + +/***/ 46871 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CenterOn = __webpack_require__(66786); +var GetCenterX = __webpack_require__(35893); +var GetCenterY = __webpack_require__(7702); + +/** + * Takes a given Game Object and aligns it so that it is positioned in the center of the other. + * + * @function Phaser.Display.Align.In.Center + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var Center = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = Center; + + +/***/ }, + +/***/ 5198 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCenterY = __webpack_require__(7702); +var GetLeft = __webpack_require__(26541); +var SetCenterY = __webpack_require__(20786); +var SetLeft = __webpack_require__(385); + +/** + * Takes a given Game Object and aligns it so that its left edge is flush with the left edge of the `alignIn` + * Game Object, and its vertical center matches the vertical center of `alignIn`. This places the Game Object + * at the left-center interior position of the reference object. An optional offset can be applied to adjust + * the final position along either axis. + * + * @function Phaser.Display.Align.In.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }, + +/***/ 11879 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ALIGN_CONST = __webpack_require__(60461); + +var AlignInMap = []; + +AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(54312); +AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(46768); +AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(35827); +AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(46871); +AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(5198); +AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(80503); +AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(89698); +AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(922); +AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(21373); +AlignInMap[ALIGN_CONST.LEFT_BOTTOM] = AlignInMap[ALIGN_CONST.BOTTOM_LEFT]; +AlignInMap[ALIGN_CONST.LEFT_TOP] = AlignInMap[ALIGN_CONST.TOP_LEFT]; +AlignInMap[ALIGN_CONST.RIGHT_BOTTOM] = AlignInMap[ALIGN_CONST.BOTTOM_RIGHT]; +AlignInMap[ALIGN_CONST.RIGHT_TOP] = AlignInMap[ALIGN_CONST.TOP_RIGHT]; + +/** + * Takes a given Game Object and aligns it so that it is positioned relative to another Game Object. + * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. + * + * @function Phaser.Display.Align.In.QuickSet + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [child,$return] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var QuickSet = function (child, alignIn, position, offsetX, offsetY) +{ + return AlignInMap[position](child, alignIn, offsetX, offsetY); +}; + +module.exports = QuickSet; + + +/***/ }, + +/***/ 80503 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCenterY = __webpack_require__(7702); +var GetRight = __webpack_require__(54380); +var SetCenterY = __webpack_require__(20786); +var SetRight = __webpack_require__(40136); + +/** + * Takes a given Game Object and aligns it so that its right edge is flush with the right edge of the `alignIn` Game Object, and its vertical center is aligned with the vertical center of the `alignIn` Game Object. + * + * @function Phaser.Display.Align.In.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }, + +/***/ 89698 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCenterX = __webpack_require__(35893); +var GetTop = __webpack_require__(17717); +var SetCenterX = __webpack_require__(88417); +var SetTop = __webpack_require__(66737); + +/** + * Takes a given Game Object and aligns it so that its top edge is flush with the top edge of the `alignIn` Game Object, centered horizontally. + * + * @function Phaser.Display.Align.In.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }, + +/***/ 922 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetLeft = __webpack_require__(26541); +var GetTop = __webpack_require__(17717); +var SetLeft = __webpack_require__(385); +var SetTop = __webpack_require__(66737); + +/** + * Takes the given Game Object and aligns it so that it is positioned in the top-left of the `alignIn` Game Object. + * + * @function Phaser.Display.Align.In.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }, + +/***/ 21373 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var SetRight = __webpack_require__(40136); +var SetTop = __webpack_require__(66737); + +/** + * Takes a given Game Object and aligns it so that it is positioned in the top-right of the `alignIn` Game Object. + * + * @function Phaser.Display.Align.In.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }, + +/***/ 91660 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.In + */ + +module.exports = { + + BottomCenter: __webpack_require__(54312), + BottomLeft: __webpack_require__(46768), + BottomRight: __webpack_require__(35827), + Center: __webpack_require__(46871), + LeftCenter: __webpack_require__(5198), + QuickSet: __webpack_require__(11879), + RightCenter: __webpack_require__(80503), + TopCenter: __webpack_require__(89698), + TopLeft: __webpack_require__(922), + TopRight: __webpack_require__(21373) + +}; + + +/***/ }, + +/***/ 71926 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(60461); +var Extend = __webpack_require__(79291); + +/** + * @namespace Phaser.Display.Align + */ + +var Align = { + + In: __webpack_require__(91660), + To: __webpack_require__(16694) + +}; + +// Merge in the consts +Align = Extend(false, Align, CONST); + +module.exports = Align; + + +/***/ }, + +/***/ 21578 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetCenterX = __webpack_require__(35893); +var SetCenterX = __webpack_require__(88417); +var SetTop = __webpack_require__(66737); + +/** + * Takes a given Game Object and aligns it so that its top edge is flush with the bottom of the `alignTo` Game Object, centered horizontally on it. + * + * @function Phaser.Display.Align.To.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }, + +/***/ 10210 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var SetLeft = __webpack_require__(385); +var SetTop = __webpack_require__(66737); + +/** + * Takes a given Game Object and aligns it so that it is placed directly below the `alignTo` Game Object, with its left edge aligned to the left edge of `alignTo`. + * + * @function Phaser.Display.Align.To.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }, + +/***/ 82341 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetRight = __webpack_require__(54380); +var SetRight = __webpack_require__(40136); +var SetTop = __webpack_require__(66737); + +/** + * Takes a given Game Object and aligns it so that it is placed directly below and flush with the right edge of the other Game Object. The right edge of `gameObject` is aligned to the right edge of `alignTo`, and the top edge of `gameObject` is placed at the bottom edge of `alignTo`. + * + * @function Phaser.Display.Align.To.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }, + +/***/ 87958 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var SetBottom = __webpack_require__(86327); +var SetRight = __webpack_require__(40136); + +/** + * Takes a given Game Object and aligns it so that its right edge touches the left edge of the `alignTo` Game Object, with its bottom edge aligned to the bottom edge of `alignTo`. + * + * @function Phaser.Display.Align.To.LeftBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftBottom; + + +/***/ }, + +/***/ 40080 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCenterY = __webpack_require__(7702); +var GetLeft = __webpack_require__(26541); +var SetCenterY = __webpack_require__(20786); +var SetRight = __webpack_require__(40136); + +/** + * Takes a given Game Object and aligns it so that its right edge touches the left edge of the `alignTo` Game Object, with their vertical centers matched. + * + * @function Phaser.Display.Align.To.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }, + +/***/ 88466 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetLeft = __webpack_require__(26541); +var GetTop = __webpack_require__(17717); +var SetRight = __webpack_require__(40136); +var SetTop = __webpack_require__(66737); + +/** + * Takes a given Game Object and aligns it so that its right edge touches the left edge of the `alignTo` Game Object, with its top edge aligned to the top of `alignTo`. + * + * @function Phaser.Display.Align.To.LeftTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = LeftTop; + + +/***/ }, + +/***/ 38829 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author samme + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ALIGN_CONST = __webpack_require__(60461); + +var AlignToMap = []; + +AlignToMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(21578); +AlignToMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(10210); +AlignToMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(82341); +AlignToMap[ALIGN_CONST.LEFT_BOTTOM] = __webpack_require__(87958); +AlignToMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(40080); +AlignToMap[ALIGN_CONST.LEFT_TOP] = __webpack_require__(88466); +AlignToMap[ALIGN_CONST.RIGHT_BOTTOM] = __webpack_require__(19211); +AlignToMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(34609); +AlignToMap[ALIGN_CONST.RIGHT_TOP] = __webpack_require__(48741); +AlignToMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(49440); +AlignToMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(81288); +AlignToMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(61323); + +/** + * Takes a Game Object and aligns it next to another, at the given position. + * The alignment used is based on the `position` argument, which is a `Phaser.Display.Align` property such as `LEFT_CENTER` or `TOP_RIGHT`. + * + * @function Phaser.Display.Align.To.QuickSet + * @since 3.22.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [child,$return] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} position - The position to align the Game Object with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position, in pixels. + * @param {number} [offsetY=0] - Optional vertical offset from the position, in pixels. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var QuickSet = function (child, alignTo, position, offsetX, offsetY) +{ + return AlignToMap[position](child, alignTo, offsetX, offsetY); +}; + +module.exports = QuickSet; + + +/***/ }, + +/***/ 19211 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetRight = __webpack_require__(54380); +var SetBottom = __webpack_require__(86327); +var SetLeft = __webpack_require__(385); + +/** + * Takes a given Game Object and aligns it so that it is placed immediately to the right of the `alignTo` Game Object, with their bottom edges aligned. + * + * @function Phaser.Display.Align.To.RightBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightBottom; + + +/***/ }, + +/***/ 34609 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCenterY = __webpack_require__(7702); +var GetRight = __webpack_require__(54380); +var SetCenterY = __webpack_require__(20786); +var SetLeft = __webpack_require__(385); + +/** + * Takes a given Game Object and aligns it so that its left edge is flush with the right edge of the `alignTo` Game Object, with their vertical centers matching. + * + * @function Phaser.Display.Align.To.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }, + +/***/ 48741 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var SetLeft = __webpack_require__(385); +var SetTop = __webpack_require__(66737); + +/** + * Takes a given Game Object and aligns it so that its left edge is flush with the right edge of the `alignTo` Game Object, with its top edge matching the top edge of `alignTo`. + * + * @function Phaser.Display.Align.To.RightTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = RightTop; + + +/***/ }, + +/***/ 49440 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCenterX = __webpack_require__(35893); +var GetTop = __webpack_require__(17717); +var SetBottom = __webpack_require__(86327); +var SetCenterX = __webpack_require__(88417); + +/** + * Takes a given Game Object and aligns it so that it is placed directly above the `alignTo` Game Object, centered horizontally on it. The bottom edge of `gameObject` is positioned flush with the top edge of `alignTo`, and their center X coordinates are matched. + * + * @function Phaser.Display.Align.To.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }, + +/***/ 81288 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetLeft = __webpack_require__(26541); +var GetTop = __webpack_require__(17717); +var SetBottom = __webpack_require__(86327); +var SetLeft = __webpack_require__(385); + +/** + * Takes a given Game Object and aligns it so that its bottom edge sits flush with the top edge of the `alignTo` Game Object, with their left edges aligned. The result is that `gameObject` appears directly above `alignTo`, anchored to its left side. + * + * @function Phaser.Display.Align.To.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }, + +/***/ 61323 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var SetBottom = __webpack_require__(86327); +var SetRight = __webpack_require__(40136); + +/** + * Takes a given Game Object and aligns it so that it is positioned directly above the `alignTo` Game Object, with their right edges aligned. + * + * @function Phaser.Display.Align.To.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }, + +/***/ 16694 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.To + */ + +module.exports = { + + BottomCenter: __webpack_require__(21578), + BottomLeft: __webpack_require__(10210), + BottomRight: __webpack_require__(82341), + LeftBottom: __webpack_require__(87958), + LeftCenter: __webpack_require__(40080), + LeftTop: __webpack_require__(88466), + QuickSet: __webpack_require__(38829), + RightBottom: __webpack_require__(19211), + RightCenter: __webpack_require__(34609), + RightTop: __webpack_require__(48741), + TopCenter: __webpack_require__(49440), + TopLeft: __webpack_require__(81288), + TopRight: __webpack_require__(61323) + +}; + + +/***/ }, + +/***/ 66786 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var SetCenterX = __webpack_require__(88417); +var SetCenterY = __webpack_require__(20786); + +/** + * Positions the Game Object so that it is centered on the given coordinates. + * + * @function Phaser.Display.Bounds.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The horizontal coordinate to position the Game Object on. + * @param {number} y - The vertical coordinate to position the Game Object on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var CenterOn = function (gameObject, x, y) +{ + SetCenterX(gameObject, x); + + return SetCenterY(gameObject, y); +}; + +module.exports = CenterOn; + + +/***/ }, + +/***/ 62235 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the bottom coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The bottom coordinate of the bounds of the Game Object. + */ +var GetBottom = function (gameObject) +{ + return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); +}; + +module.exports = GetBottom; + + +/***/ }, + +/***/ 72873 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author samme + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var Rectangle = __webpack_require__(87841); + +/** + * Returns the unrotated bounds of the Game Object as a rectangle. + * + * @function Phaser.Display.Bounds.GetBounds + * @since 3.24.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} - The bounds of the Game Object. + */ +var GetBounds = function (gameObject, output) +{ + if (output === undefined) { output = new Rectangle(); } + + var left = GetLeft(gameObject); + var top = GetTop(gameObject); + + output.x = left; + output.y = top; + output.width = GetRight(gameObject) - left; + output.height = GetBottom(gameObject) - top; + + return output; +}; + +module.exports = GetBounds; + + +/***/ }, + +/***/ 35893 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the center x coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetCenterX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The center x coordinate of the bounds of the Game Object. + */ +var GetCenterX = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX) + (gameObject.width * 0.5); +}; + +module.exports = GetCenterX; + + +/***/ }, + +/***/ 7702 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the center y coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetCenterY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The center y coordinate of the bounds of the Game Object. + */ +var GetCenterY = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY) + (gameObject.height * 0.5); +}; + +module.exports = GetCenterY; + + +/***/ }, + +/***/ 26541 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the left coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The left coordinate of the bounds of the Game Object. + */ +var GetLeft = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX); +}; + +module.exports = GetLeft; + + +/***/ }, + +/***/ 87431 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * origin.x`. + * This value will only be > 0 if `origin.x` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The horizontal offset of the Game Object. + */ +var GetOffsetX = function (gameObject) +{ + return gameObject.width * gameObject.originX; +}; + +module.exports = GetOffsetX; + + +/***/ }, + +/***/ 46928 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its y coordinate. + * This is the same as `height * origin.y`. + * This value will only be > 0 if `origin.y` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The vertical offset of the Game Object. + */ +var GetOffsetY = function (gameObject) +{ + return gameObject.height * gameObject.originY; +}; + +module.exports = GetOffsetY; + + +/***/ }, + +/***/ 54380 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the right coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The right coordinate of the bounds of the Game Object. + */ +var GetRight = function (gameObject) +{ + return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); +}; + +module.exports = GetRight; + + +/***/ }, + +/***/ 17717 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the top coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The top coordinate of the bounds of the Game Object. + */ +var GetTop = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY); +}; + +module.exports = GetTop; + + +/***/ }, + +/***/ 86327 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetBottom = function (gameObject, value) +{ + gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetBottom; + + +/***/ }, + +/***/ 88417 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Positions the Game Object so that the horizontal center of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterX = function (gameObject, x) +{ + var offsetX = gameObject.width * gameObject.originX; + + gameObject.x = (x + offsetX) - (gameObject.width * 0.5); + + return gameObject; +}; + +module.exports = SetCenterX; + + +/***/ }, + +/***/ 20786 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Positions the Game Object so that the vertical center of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} y - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterY = function (gameObject, y) +{ + var offsetY = gameObject.height * gameObject.originY; + + gameObject.y = (y + offsetY) - (gameObject.height * 0.5); + + return gameObject; +}; + +module.exports = SetCenterY; + + +/***/ }, + +/***/ 385 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetLeft = function (gameObject, value) +{ + gameObject.x = value + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetLeft; + + +/***/ }, + +/***/ 40136 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Positions the Game Object so that the right of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetRight = function (gameObject, value) +{ + gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetRight; + + +/***/ }, + +/***/ 66737 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Positions the Game Object so that the top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetTop = function (gameObject, value) +{ + gameObject.y = value + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetTop; + + +/***/ }, + +/***/ 58724 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Display.Bounds + */ + +module.exports = { + + CenterOn: __webpack_require__(66786), + GetBottom: __webpack_require__(62235), + GetBounds: __webpack_require__(72873), + GetCenterX: __webpack_require__(35893), + GetCenterY: __webpack_require__(7702), + GetLeft: __webpack_require__(26541), + GetOffsetX: __webpack_require__(87431), + GetOffsetY: __webpack_require__(46928), + GetRight: __webpack_require__(54380), + GetTop: __webpack_require__(17717), + SetBottom: __webpack_require__(86327), + SetCenterX: __webpack_require__(88417), + SetCenterY: __webpack_require__(20786), + SetLeft: __webpack_require__(385), + SetRight: __webpack_require__(40136), + SetTop: __webpack_require__(66737) + +}; + + +/***/ }, + +/***/ 20623 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Canvas Interpolation namespace contains helper functions for setting the CSS `image-rendering` + * property on a canvas element. This controls how the browser scales the canvas when it is + * displayed at a size different from its native resolution. + * + * Use `setCrisp` for pixel art games where you want sharp, nearest-neighbor scaling with no + * anti-aliasing. Use `setBicubic` to restore the default browser behavior, which applies smooth + * interpolation when scaling up the canvas. + * + * @namespace Phaser.Display.Canvas.CanvasInterpolation + * @since 3.0.0 + */ +var CanvasInterpolation = { + + /** + * Sets the CSS `image-rendering` property on the given canvas to use nearest-neighbor (crisp) scaling. + * This disables anti-aliasing so that each pixel is rendered as a hard-edged block, which is ideal + * for pixel art games. Multiple vendor-prefixed values are applied in sequence to ensure + * cross-browser compatibility, including Firefox (`-moz-crisp-edges`), Opera (`-o-crisp-edges`), + * WebKit (`-webkit-optimize-contrast`), and Internet Explorer (`msInterpolationMode: nearest-neighbor`). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setCrisp: function (canvas) + { + var types = [ 'optimizeSpeed', '-moz-crisp-edges', '-o-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'crisp-edges', 'pixelated' ]; + + types.forEach(function (type) + { + canvas.style['image-rendering'] = type; + }); + + canvas.style.msInterpolationMode = 'nearest-neighbor'; + + return canvas; + }, + + /** + * Sets the CSS `image-rendering` property on the given canvas to `auto`, restoring the default + * browser behavior. This allows the browser to apply smooth (typically bicubic) interpolation + * when scaling the canvas, which produces softer edges and is better suited to high-resolution + * textures or non-pixel-art content. Also sets the IE-specific `msInterpolationMode` to `bicubic`. + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setBicubic: function (canvas) + { + canvas.style['image-rendering'] = 'auto'; + canvas.style.msInterpolationMode = 'bicubic'; + + return canvas; + } + +}; + +module.exports = CanvasInterpolation; + + +/***/ }, + +/***/ 27919 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(8054); +var Smoothing = __webpack_require__(68703); + +// The pool into which the canvas elements are placed. +var pool = []; + +// Automatically apply smoothing(false) to created Canvas elements +var _disableContextSmoothing = false; + +/** + * The CanvasPool is a global static object, that allows Phaser to recycle and pool 2D Context Canvas DOM elements. + * It does not pool WebGL Contexts, because once the context options are set they cannot be modified again, + * which is useless for the Phaser renderer. + * + * This singleton is instantiated as soon as Phaser loads, before a Phaser.Game instance has even been created. + * Which means all instances of Phaser Games on the same page can share the one single pool. + * + * @namespace Phaser.Display.Canvas.CanvasPool + * @since 3.0.0 + */ +var CanvasPool = function () +{ + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * + * @function Phaser.Display.Canvas.CanvasPool.create + * @since 3.0.0 + * + * @param {*} parent - The parent of the Canvas object. + * @param {number} [width=1] - The width of the Canvas. + * @param {number} [height=1] - The height of the Canvas. + * @param {number} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent? + * + * @return {HTMLCanvasElement} The canvas element that was created or pulled from the pool. + */ + var create = function (parent, width, height, canvasType, selfParent) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = 1; } + if (canvasType === undefined) { canvasType = CONST.CANVAS; } + if (selfParent === undefined) { selfParent = false; } + + var canvas; + var container = first(canvasType); + + if (container === null) + { + container = { + parent: parent, + canvas: document.createElement('canvas'), + type: canvasType + }; + + if (canvasType === CONST.CANVAS) + { + pool.push(container); + } + + canvas = container.canvas; + } + else + { + container.parent = parent; + + canvas = container.canvas; + } + + if (selfParent) + { + container.parent = canvas; + } + + canvas.width = width; + canvas.height = height; + + if (_disableContextSmoothing && canvasType === CONST.CANVAS) + { + Smoothing.disable(canvas.getContext('2d', { willReadFrequently: false })); + } + + return canvas; + }; + + /** + * Creates a new 2D Canvas DOM element, or pulls one from the pool if free. + * + * This is a convenience wrapper around `create` that forces `canvasType` to `Phaser.CANVAS`, + * ensuring the returned canvas is always intended for use with a 2D rendering context. + * + * @function Phaser.Display.Canvas.CanvasPool.create2D + * @since 3.0.0 + * + * @param {*} parent - The parent of the Canvas object. + * @param {number} [width=1] - The width of the Canvas. + * @param {number} [height=1] - The height of the Canvas. + * + * @return {HTMLCanvasElement} The canvas element that was created or pulled from the pool. + */ + var create2D = function (parent, width, height) + { + return create(parent, width, height, CONST.CANVAS); + }; + + /** + * Creates a new WebGL Canvas DOM element. + * + * This is a convenience wrapper around `create` that forces `canvasType` to `Phaser.WEBGL`. + * WebGL canvases are never added to the pool, because once a WebGL context's options are set + * they cannot be changed, making pooling unsuitable for them. + * + * @function Phaser.Display.Canvas.CanvasPool.createWebGL + * @since 3.0.0 + * + * @param {*} parent - The parent of the Canvas object. + * @param {number} [width=1] - The width of the Canvas. + * @param {number} [height=1] - The height of the Canvas. + * + * @return {HTMLCanvasElement} The created WebGL canvas. + */ + var createWebGL = function (parent, width, height) + { + return create(parent, width, height, CONST.WEBGL); + }; + + /** + * Gets the first free canvas container from the pool. + * + * @function Phaser.Display.Canvas.CanvasPool.first + * @since 3.0.0 + * + * @param {number} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * + * @return {HTMLCanvasElement} The first free canvas, or `null` if a WebGL canvas was requested or if the pool doesn't have free canvases. + */ + var first = function (canvasType) + { + if (canvasType === undefined) { canvasType = CONST.CANVAS; } + + if (canvasType === CONST.WEBGL) + { + return null; + } + + for (var i = 0; i < pool.length; i++) + { + var container = pool[i]; + + if (!container.parent && container.type === canvasType) + { + return container; + } + } + + return null; + }; + + /** + * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. + * The canvas has its width and height set to 1, and its parent attribute nulled. + * + * @function Phaser.Display.Canvas.CanvasPool.remove + * @since 3.0.0 + * + * @param {*} parent - The canvas or the parent of the canvas to free. + */ + var remove = function (parent) + { + // Check to see if the parent is a canvas object + var isCanvas = parent instanceof HTMLCanvasElement; + + pool.forEach(function (container) + { + if ((isCanvas && container.canvas === parent) || (!isCanvas && container.parent === parent)) + { + container.parent = null; + container.canvas.width = 1; + container.canvas.height = 1; + } + }); + }; + + /** + * Gets the total number of used canvas elements in the pool. + * + * @function Phaser.Display.Canvas.CanvasPool.total + * @since 3.0.0 + * + * @return {number} The number of used canvases. + */ + var total = function () + { + var c = 0; + + pool.forEach(function (container) + { + if (container.parent) + { + c++; + } + }); + + return c; + }; + + /** + * Gets the total number of free canvas elements in the pool. + * + * @function Phaser.Display.Canvas.CanvasPool.free + * @since 3.0.0 + * + * @return {number} The number of free canvases. + */ + var free = function () + { + return pool.length - total(); + }; + + /** + * Disable context smoothing on any new Canvas element created. + * + * @function Phaser.Display.Canvas.CanvasPool.disableSmoothing + * @since 3.0.0 + */ + var disableSmoothing = function () + { + _disableContextSmoothing = true; + }; + + /** + * Enable context smoothing on any new Canvas element created. + * + * @function Phaser.Display.Canvas.CanvasPool.enableSmoothing + * @since 3.0.0 + */ + var enableSmoothing = function () + { + _disableContextSmoothing = false; + }; + + return { + create2D: create2D, + create: create, + createWebGL: createWebGL, + disableSmoothing: disableSmoothing, + enableSmoothing: enableSmoothing, + first: first, + free: free, + pool: pool, + remove: remove, + total: total + }; +}; + +// If we export the called function here, it'll only be invoked once (not every time it's required). +module.exports = CanvasPool(); + + +/***/ }, + +/***/ 68703 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Browser specific prefix, so not going to change between contexts, only between browsers +var prefix = ''; + +/** + * The Smoothing namespace contains functions for controlling the image smoothing (anti-aliasing) + * setting on a canvas rendering context. Image smoothing affects how the browser scales images: + * when enabled, scaled images are blurred to reduce jagged edges; when disabled, pixels are + * rendered sharply without interpolation. Disabling smoothing is commonly used in games that + * rely on pixel art, where blurring would distort the intended aesthetic. The functions in this + * namespace automatically detect and apply the correct vendor-prefixed property for the current + * browser, supporting `imageSmoothingEnabled` as well as the `webkit`, `ms`, `moz`, and `o` prefixed variants. + * + * @namespace Phaser.Display.Canvas.Smoothing + * @since 3.0.0 + */ +var Smoothing = function () +{ + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * + * @function Phaser.Display.Canvas.Smoothing.getPrefix + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The canvas context to check. + * + * @return {string} The name of the property on the context which controls image smoothing (either `imageSmoothingEnabled` or a vendor-prefixed version thereof), or `null` if not supported. + */ + var getPrefix = function (context) + { + var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; + + for (var i = 0; i < vendors.length; i++) + { + var s = vendors[i] + 'mageSmoothingEnabled'; + + if (s in context) + { + return s; + } + } + + return null; + }; + + /** + * Enables the Image Smoothing property on the given context. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.enable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The context on which to enable smoothing. + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} The provided context. + */ + var enable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = true; + } + + return context; + }; + + /** + * Disables the Image Smoothing property on the given context. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.disable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The context on which to disable smoothing. + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} The provided context. + */ + var disable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = false; + } + + return context; + }; + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * Returns null if no smoothing prefix is available. + * + * @function Phaser.Display.Canvas.Smoothing.isEnabled + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The context to check. + * + * @return {?boolean} `true` if smoothing is enabled on the context, otherwise `false`. `null` if not supported. + */ + var isEnabled = function (context) + { + return (prefix !== null) ? context[prefix] : null; + }; + + return { + disable: disable, + enable: enable, + getPrefix: getPrefix, + isEnabled: isEnabled + }; + +}; + +module.exports = Smoothing(); + + +/***/ }, + +/***/ 65208 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. + * + * @function Phaser.Display.Canvas.TouchAction + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var TouchAction = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + canvas.style['msTouchAction'] = value; + canvas.style['ms-touch-action'] = value; + canvas.style['touch-action'] = value; + + return canvas; +}; + +module.exports = TouchAction; + + +/***/ }, + +/***/ 91610 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. + * + * @function Phaser.Display.Canvas.UserSelect + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The user-select value to set on the canvas. Set to `none` to disable default browser text selection and touch callouts. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var UserSelect = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + var vendors = [ + '-webkit-', + '-khtml-', + '-moz-', + '-ms-', + '' + ]; + + vendors.forEach(function (vendor) + { + canvas.style[vendor + 'user-select'] = value; + }); + + canvas.style['-webkit-touch-callout'] = value; + canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; + + return canvas; +}; + +module.exports = UserSelect; + + +/***/ }, + +/***/ 26253 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas + */ + +module.exports = { + + CanvasInterpolation: __webpack_require__(20623), + CanvasPool: __webpack_require__(27919), + Smoothing: __webpack_require__(68703), + TouchAction: __webpack_require__(65208), + UserSelect: __webpack_require__(91610) + +}; + + +/***/ }, + +/***/ 40987 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var GetColor = __webpack_require__(37589); +var GetColor32 = __webpack_require__(1000); +var HSVToRGB = __webpack_require__(7537); +var RGBToHSV = __webpack_require__(87837); + +/** + * @namespace Phaser.Display.Color + */ + +/** + * @classdesc + * A mutable color representation that stores RGBA values (0-255 range) with automatic conversion + * to WebGL-compatible normalized floats (0-1), HSV color space, CSS rgba strings, and packed + * 24/32-bit integer formats. Provides methods for color manipulation including saturation, + * lightness, brightness adjustments, grayscale, and randomization. Supports construction from + * RGB integers, hex strings, HSV values, or color objects. Used throughout Phaser for tinting, + * effects, and rendering. + * + * @class Color + * @memberof Phaser.Display + * @constructor + * @since 3.0.0 + * + * @param {number} [red=0] - The red color value. A number between 0 and 255. + * @param {number} [green=0] - The green color value. A number between 0 and 255. + * @param {number} [blue=0] - The blue color value. A number between 0 and 255. + * @param {number} [alpha=255] - The alpha value. A number between 0 and 255. + */ +var Color = new Class({ + + initialize: + + function Color (red, green, blue, alpha) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (alpha === undefined) { alpha = 255; } + + /** + * The internal red color value. + * + * @name Phaser.Display.Color#r + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.r = 0; + + /** + * The internal green color value. + * + * @name Phaser.Display.Color#g + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.g = 0; + + /** + * The internal blue color value. + * + * @name Phaser.Display.Color#b + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.b = 0; + + /** + * The internal alpha color value. + * + * @name Phaser.Display.Color#a + * @type {number} + * @private + * @default 255 + * @since 3.0.0 + */ + this.a = 255; + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#_h + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._h = 0; + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#_s + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._s = 0; + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#_v + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._v = 0; + + /** + * Is this color update locked? + * + * @name Phaser.Display.Color#_locked + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._locked = false; + + /** + * An array containing the RGBA color components in WebGL-compatible normalized float format, + * stored as `[red, green, blue, alpha]` with each value in the range 0 to 1. + * + * @name Phaser.Display.Color#gl + * @type {number[]} + * @since 3.0.0 + */ + this.gl = [ 0, 0, 0, 1 ]; + + /** + * Pre-calculated internal color value. + * + * @name Phaser.Display.Color#_color + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color = 0; + + /** + * Pre-calculated internal color32 value. + * + * @name Phaser.Display.Color#_color32 + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color32 = 0; + + /** + * Pre-calculated internal color rgb string value. + * + * @name Phaser.Display.Color#_rgba + * @type {string} + * @private + * @default '' + * @since 3.0.0 + */ + this._rgba = ''; + + this.setTo(red, green, blue, alpha); + }, + + /** + * Sets this color to be transparent. Sets all values to zero. + * + * @method Phaser.Display.Color#transparent + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + transparent: function () + { + this._locked = true; + + this.red = 0; + this.green = 0; + this.blue = 0; + this.alpha = 0; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color of this Color component. + * + * @method Phaser.Display.Color#setTo + * @since 3.0.0 + * + * @param {number} red - The red color value. A number between 0 and 255. + * @param {number} green - The green color value. A number between 0 and 255. + * @param {number} blue - The blue color value. A number between 0 and 255. + * @param {number} [alpha=255] - The alpha value. A number between 0 and 255. + * @param {boolean} [updateHSV=true] - Update the HSV values after setting the RGB values? + * + * @return {Phaser.Display.Color} This Color object. + */ + setTo: function (red, green, blue, alpha, updateHSV) + { + if (alpha === undefined) { alpha = 255; } + if (updateHSV === undefined) { updateHSV = true; } + + this._locked = true; + + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = alpha; + + this._locked = false; + + return this.update(updateHSV); + }, + + /** + * Sets the red, green, blue and alpha GL values of this Color component. + * + * @method Phaser.Display.Color#setGLTo + * @since 3.0.0 + * + * @param {number} red - The red color value. A number between 0 and 1. + * @param {number} green - The green color value. A number between 0 and 1. + * @param {number} blue - The blue color value. A number between 0 and 1. + * @param {number} [alpha=1] - The alpha value. A number between 0 and 1. + * + * @return {Phaser.Display.Color} This Color object. + */ + setGLTo: function (red, green, blue, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this._locked = true; + + this.redGL = red; + this.greenGL = green; + this.blueGL = blue; + this.alphaGL = alpha; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the color object given. + * + * @method Phaser.Display.Color#setFromRGB + * @since 3.0.0 + * + * @param {Phaser.Types.Display.InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromRGB: function (color) + { + this._locked = true; + + this.red = color.r; + this.green = color.g; + this.blue = color.b; + + if (color.hasOwnProperty('a')) + { + this.alpha = color.a; + } + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the hue, saturation and value (HSV) components given. + * + * @method Phaser.Display.Color#setFromHSV + * @since 3.13.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromHSV: function (h, s, v) + { + return HSVToRGB(h, s, v, this); + }, + + /** + * Updates the internal cache values. + * + * @method Phaser.Display.Color#update + * @private + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + update: function (updateHSV) + { + if (updateHSV === undefined) { updateHSV = false; } + + if (this._locked) + { + return this; + } + + var r = this.r; + var g = this.g; + var b = this.b; + var a = this.a; + + this._color = GetColor(r, g, b); + this._color32 = GetColor32(r, g, b, a); + this._rgba = 'rgba(' + r + ',' + g + ',' + b + ',' + (a / 255) + ')'; + + if (updateHSV) + { + RGBToHSV(r, g, b, this); + } + + return this; + }, + + /** + * Updates the internal hsv cache values. + * + * @method Phaser.Display.Color#updateHSV + * @private + * @since 3.13.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + updateHSV: function () + { + var r = this.r; + var g = this.g; + var b = this.b; + + RGBToHSV(r, g, b, this); + + return this; + }, + + /** + * Returns a new Color component using the values from this one. + * + * @method Phaser.Display.Color#clone + * @since 3.0.0 + * + * @return {Phaser.Display.Color} A new Color object. + */ + clone: function () + { + return new Color(this.r, this.g, this.b, this.a); + }, + + /** + * Sets this Color object to be grayscaled based on the shade value given. + * + * @method Phaser.Display.Color#gray + * @since 3.13.0 + * + * @param {number} shade - A value between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + gray: function (shade) + { + return this.setTo(shade, shade, shade); + }, + + /** + * Sets this Color object to be a random color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#random + * @since 3.13.0 + * + * @param {number} [min=0] - The minimum random color value. Between 0 and 255. + * @param {number} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + random: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var r = Math.floor(min + Math.random() * (max - min)); + var g = Math.floor(min + Math.random() * (max - min)); + var b = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(r, g, b); + }, + + /** + * Sets this Color object to be a random grayscale color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#randomGray + * @since 3.13.0 + * + * @param {number} [min=0] - The minimum random color value. Between 0 and 255. + * @param {number} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + randomGray: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var s = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(s, s, s); + }, + + /** + * Increase the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#saturate + * @since 3.13.0 + * + * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + saturate: function (amount) + { + this.s += amount / 100; + + return this; + }, + + /** + * Decrease the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#desaturate + * @since 3.13.0 + * + * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + desaturate: function (amount) + { + this.s -= amount / 100; + + return this; + }, + + /** + * Increase the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#lighten + * @since 3.13.0 + * + * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + lighten: function (amount) + { + this.v += amount / 100; + + return this; + }, + + /** + * Decrease the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#darken + * @since 3.13.0 + * + * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + darken: function (amount) + { + this.v -= amount / 100; + + return this; + }, + + /** + * Brighten this Color by the percentage amount given. + * + * @method Phaser.Display.Color#brighten + * @since 3.13.0 + * + * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + brighten: function (amount) + { + var r = this.r; + var g = this.g; + var b = this.b; + + r = Math.max(0, Math.min(255, r - Math.round(255 * - (amount / 100)))); + g = Math.max(0, Math.min(255, g - Math.round(255 * - (amount / 100)))); + b = Math.max(0, Math.min(255, b - Math.round(255 * - (amount / 100)))); + + return this.setTo(r, g, b); + }, + + /** + * The packed 24-bit RGB integer representation of this color, not including the alpha channel. + * + * @name Phaser.Display.Color#color + * @type {number} + * @readonly + * @since 3.0.0 + */ + color: { + + get: function () + { + return this._color; + } + + }, + + /** + * The packed 32-bit RGBA integer representation of this color, including the alpha channel. + * + * @name Phaser.Display.Color#color32 + * @type {number} + * @readonly + * @since 3.0.0 + */ + color32: { + + get: function () + { + return this._color32; + } + + }, + + /** + * The color of this Color object as a CSS-compatible `rgba()` string, suitable for use with Canvas 2D or HTML elements. + * + * @name Phaser.Display.Color#rgba + * @type {string} + * @readonly + * @since 3.0.0 + */ + rgba: { + + get: function () + { + return this._rgba; + } + + }, + + /** + * The red color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#redGL + * @type {number} + * @since 3.0.0 + */ + redGL: { + + get: function () + { + return this.gl[0]; + }, + + set: function (value) + { + this.gl[0] = Math.min(Math.abs(value), 1); + + this.r = Math.floor(this.gl[0] * 255); + + this.update(true); + } + + }, + + /** + * The green color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#greenGL + * @type {number} + * @since 3.0.0 + */ + greenGL: { + + get: function () + { + return this.gl[1]; + }, + + set: function (value) + { + this.gl[1] = Math.min(Math.abs(value), 1); + + this.g = Math.floor(this.gl[1] * 255); + + this.update(true); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#blueGL + * @type {number} + * @since 3.0.0 + */ + blueGL: { + + get: function () + { + return this.gl[2]; + }, + + set: function (value) + { + this.gl[2] = Math.min(Math.abs(value), 1); + + this.b = Math.floor(this.gl[2] * 255); + + this.update(true); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#alphaGL + * @type {number} + * @since 3.0.0 + */ + alphaGL: { + + get: function () + { + return this.gl[3]; + }, + + set: function (value) + { + this.gl[3] = Math.min(Math.abs(value), 1); + + this.a = Math.floor(this.gl[3] * 255); + + this.update(); + } + + }, + + /** + * The red color value, in the range 0 to 255. + * + * @name Phaser.Display.Color#red + * @type {number} + * @since 3.0.0 + */ + red: { + + get: function () + { + return this.r; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.r = Math.min(value, 255); + + this.gl[0] = value / 255; + + this.update(true); + } + + }, + + /** + * The green color value, in the range 0 to 255. + * + * @name Phaser.Display.Color#green + * @type {number} + * @since 3.0.0 + */ + green: { + + get: function () + { + return this.g; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.g = Math.min(value, 255); + + this.gl[1] = value / 255; + + this.update(true); + } + + }, + + /** + * The blue color value, in the range 0 to 255. + * + * @name Phaser.Display.Color#blue + * @type {number} + * @since 3.0.0 + */ + blue: { + + get: function () + { + return this.b; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.b = Math.min(value, 255); + + this.gl[2] = value / 255; + + this.update(true); + } + + }, + + /** + * The alpha color value, in the range 0 to 255. + * + * @name Phaser.Display.Color#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this.a; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.a = Math.min(value, 255); + + this.gl[3] = value / 255; + + this.update(); + } + + }, + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#h + * @type {number} + * @since 3.13.0 + */ + h: { + + get: function () + { + return this._h; + }, + + set: function (value) + { + this._h = value; + + HSVToRGB(value, this._s, this._v, this); + } + + }, + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#s + * @type {number} + * @since 3.13.0 + */ + s: { + + get: function () + { + return this._s; + }, + + set: function (value) + { + this._s = value; + + HSVToRGB(this._h, value, this._v, this); + } + + }, + + /** + * The value (brightness) component of this color in the HSV color space. A number between 0 and 1, + * where 1 is fully bright and 0 is black. + * + * @name Phaser.Display.Color#v + * @type {number} + * @since 3.13.0 + */ + v: { + + get: function () + { + return this._v; + }, + + set: function (value) + { + this._v = value; + + HSVToRGB(this._h, this._s, value, this); + } + + } + +}); + +module.exports = Color; + + +/***/ }, + +/***/ 92728 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetColor = __webpack_require__(37589); + +/** + * Returns an array of Color Objects representing a full color spectrum. + * + * The spectrum colors cycle through the hue wheel in the order: red, yellow, green, cyan, blue, violet, and back to red. + * + * By default this function will return an array with 1024 elements. + * + * However, you can reduce this to a smaller quantity if needed, by specifying the `limit` parameter. + * When a limit smaller than 1024 is given, the colors are sampled evenly across the full spectrum so + * the hue distribution remains uniform regardless of the array size. + * + * @function Phaser.Display.Color.ColorSpectrum + * @since 3.50.0 + * + * @param {number} [limit=1024] - How many colors should be returned? The maximum is 1024 but you can set a smaller quantity if required. + * + * @return {Phaser.Types.Display.ColorObject[]} An array containing `limit` parameter number of elements, where each contains a Color Object. + */ +var ColorSpectrum = function (limit) +{ + if (limit === undefined) { limit = 1024; } + + var colors = []; + + var range = 255; + + var i; + var r = 255; + var g = 0; + var b = 0; + + // Red to Yellow + for (i = 0; i <= range; i++) + { + colors.push({ r: r, g: i, b: b, color: GetColor(r, i, b) }); + } + + g = 255; + + // Yellow to Green + for (i = range; i >= 0; i--) + { + colors.push({ r: i, g: g, b: b, color: GetColor(i, g, b) }); + } + + r = 0; + + // Green to Blue + for (i = 0; i <= range; i++, g--) + { + colors.push({ r: r, g: g, b: i, color: GetColor(r, g, i) }); + } + + g = 0; + b = 255; + + // Blue to Red + for (i = 0; i <= range; i++, b--, r++) + { + colors.push({ r: r, g: g, b: b, color: GetColor(r, g, b) }); + } + + if (limit === 1024) + { + return colors; + } + else + { + var out = []; + + var t = 0; + var inc = 1024 / limit; + + for (i = 0; i < limit; i++) + { + out.push(colors[Math.floor(t)]); + + t += inc; + } + + return out; + } +}; + +module.exports = ColorSpectrum; + + +/***/ }, + +/***/ 91588 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Converts the given color value into an object containing r, g, b and a properties. + * + * The color value can be a 24-bit RGB integer (e.g. `0xRRGGBB`) or a 32-bit ARGB integer + * (e.g. `0xAARRGGBB`). If the value is 24-bit (i.e. does not exceed `0xFFFFFF`), the alpha + * component of the returned object defaults to 255 (fully opaque). Otherwise, the alpha is + * extracted from the upper 8 bits of the value. + * + * @function Phaser.Display.Color.ColorToRGBA + * @since 3.0.0 + * + * @param {number} color - A 24-bit RGB or 32-bit ARGB color integer, optionally including an alpha component in the most-significant byte. + * + * @return {Phaser.Types.Display.ColorObject} An object containing the parsed color values. + */ +var ColorToRGBA = function (color) +{ + var output = { + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF, + a: 255 + }; + + if (color > 16777215) + { + output.a = color >>> 24; + } + + return output; +}; + +module.exports = ColorToRGBA; + + +/***/ }, + +/***/ 62957 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns a string containing a hex representation of the given color component. + * + * @function Phaser.Display.Color.ComponentToHex + * @since 3.0.0 + * + * @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255. + * + * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + */ +var ComponentToHex = function (color) +{ + var hex = color.toString(16); + + return (hex.length === 1) ? '0' + hex : hex; +}; + +module.exports = ComponentToHex; + + +/***/ }, + +/***/ 37589 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Packs three separate red, green, and blue color component values into a single 24-bit integer in the format 0xRRGGBB. + * + * @function Phaser.Display.Color.GetColor + * @since 3.0.0 + * + * @param {number} red - The red color value. A number between 0 and 255. + * @param {number} green - The green color value. A number between 0 and 255. + * @param {number} blue - The blue color value. A number between 0 and 255. + * + * @return {number} The packed color value as a 24-bit integer in the format 0xRRGGBB. + */ +var GetColor = function (red, green, blue) +{ + return red << 16 | green << 8 | blue; +}; + +module.exports = GetColor; + + +/***/ }, + +/***/ 1000 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Packs four ARGB component values (red, green, blue, and alpha) into a single 32-bit integer in ARGB format. + * + * @function Phaser.Display.Color.GetColor32 + * @since 3.0.0 + * + * @param {number} red - The red color value. A number between 0 and 255. + * @param {number} green - The green color value. A number between 0 and 255. + * @param {number} blue - The blue color value. A number between 0 and 255. + * @param {number} alpha - The alpha color value. A number between 0 and 255. + * + * @return {number} The packed 32-bit ARGB color value. + */ +var GetColor32 = function (red, green, blue, alpha) +{ + return alpha << 24 | red << 16 | green << 8 | blue; +}; + +module.exports = GetColor32; + + +/***/ }, + +/***/ 62183 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Color = __webpack_require__(40987); +var HueToComponent = __webpack_require__(89528); + +/** + * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. + * + * All three input values should be in the range 0 to 1. If the saturation is 0 + * the color is treated as achromatic (greyscale). Otherwise the standard HSL-to-RGB + * algorithm is applied, using the lightness value to derive the intermediate q and p + * coefficients before delegating each channel to `HueToComponent`. + * + * @function Phaser.Display.Color.HSLToColor + * @since 3.0.0 + * + * @param {number} h - The hue value in the range 0 to 1. + * @param {number} s - The saturation value in the range 0 to 1. + * @param {number} l - The lightness value in the range 0 to 1. + * @param {Phaser.Display.Color} [color] - An optional Color object to populate with the converted values. If not provided, a new Color object is created and returned. + * + * @return {Phaser.Display.Color} The Color object populated with the RGB values derived from the given h, s and l inputs. This is either the `color` argument (if provided) or a newly created Color object. + */ +var HSLToColor = function (h, s, l, color) +{ + if (!color) { color = new Color(); } + + // achromatic by default + var r = l; + var g = l; + var b = l; + + if (s !== 0) + { + var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + + r = HueToComponent(p, q, h + 1 / 3); + g = HueToComponent(p, q, h); + b = HueToComponent(p, q, h - 1 / 3); + } + + return color.setGLTo(r, g, b, 1); +}; + +module.exports = HSLToColor; + + +/***/ }, + +/***/ 27939 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var HSVToRGB = __webpack_require__(7537); + +/** + * Generates an HSV color wheel as an array of 360 ColorObject entries, one for each degree of hue from 0 to 359. + * + * @function Phaser.Display.Color.HSVColorWheel + * @since 3.0.0 + * + * @param {number} [s=1] - The saturation, in the range 0 - 1. + * @param {number} [v=1] - The value, in the range 0 - 1. + * + * @return {Phaser.Types.Display.ColorObject[]} An array of 360 ColorObject elements, each representing the RGB color at that hue step of the HSV color wheel. + */ +var HSVColorWheel = function (s, v) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var colors = []; + + for (var c = 0; c <= 359; c++) + { + colors.push(HSVToRGB(c / 359, s, v)); + } + + return colors; +}; + +module.exports = HSVColorWheel; + + +/***/ }, + +/***/ 7537 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetColor = __webpack_require__(37589); + +/** + * RGB space conversion. + * + * @ignore + * + * @param {number} n - The value to convert. + * @param {number} h - The h value. + * @param {number} s - The s value. + * @param {number} v - The v value. + * + * @return {number} The converted value. + */ +function ConvertValue (n, h, s, v) +{ + var k = (n + h * 6) % 6; + + var min = Math.min(k, 4 - k, 1); + + return Math.round(255 * (v - v * s * Math.max(0, min))); +} + +/** + * Converts a HSV (hue, saturation and value) color set to RGB. + * + * Conversion formula from https://en.wikipedia.org/wiki/HSL_and_HSV + * + * Assumes HSV values are contained in the set [0, 1]. + * + * @function Phaser.Display.Color.HSVToRGB + * @since 3.0.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you a greyscale color. + * @param {number} v - The value, in the range 0 - 1. This controls how bright the color is, where 1 is as bright as possible and 0 is black. + * @param {(Phaser.Types.Display.ColorObject|Phaser.Display.Color)} [out] - A Color object to store the results in. If not given a new ColorObject will be created. + * + * @return {(Phaser.Types.Display.ColorObject|Phaser.Display.Color)} An object with the red, green and blue values set in the r, g and b properties. + */ +var HSVToRGB = function (h, s, v, out) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var r = ConvertValue(5, h, s, v); + var g = ConvertValue(3, h, s, v); + var b = ConvertValue(1, h, s, v); + + if (!out) + { + return { r: r, g: g, b: b, color: GetColor(r, g, b) }; + } + else if (out.setTo) + { + return out.setTo(r, g, b, out.alpha, true); + } + else + { + out.r = r; + out.g = g; + out.b = b; + out.color = GetColor(r, g, b); + + return out; + } +}; + +module.exports = HSVToRGB; + + +/***/ }, + +/***/ 70238 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Color = __webpack_require__(40987); + +/** + * Converts a hex string into a Phaser Color object. + * + * The hex string can be supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * + * @function Phaser.Display.Color.HexStringToColor + * @since 3.0.0 + * + * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + * @param {Phaser.Display.Color} [color] - The color where the new color will be stored. If not defined, a new color object is returned. + * + * @return {Phaser.Display.Color} A Color object populated by the values of the given string. + */ +var HexStringToColor = function (hex, color) +{ + if (!color) { color = new Color(); } + + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) + { + return r + r + g + g + b + b; + }); + + var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); + + if (result) + { + var r = parseInt(result[1], 16); + var g = parseInt(result[2], 16); + var b = parseInt(result[3], 16); + + color.setTo(r, g, b); + } + + return color; +}; + +module.exports = HexStringToColor; + + +/***/ }, + +/***/ 89528 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates a single RGB channel value from a hue offset and the two intermediate + * lightness values used during HSL to RGB conversion. Call this function once for each + * channel (red, green, and blue), passing the appropriate hue offset each time. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HueToComponent + * @since 3.0.0 + * + * @param {number} p - The first intermediate value derived from the lightness during HSL to RGB conversion. + * @param {number} q - The second intermediate value derived from the lightness and saturation during HSL to RGB conversion. + * @param {number} t - The hue offset for the color channel being calculated (red, green, or blue). + * + * @return {number} The RGB channel value for the given hue offset, in the range 0 to 1. + */ +var HueToComponent = function (p, q, t) +{ + if (t < 0) + { + t += 1; + } + + if (t > 1) + { + t -= 1; + } + + if (t < 1 / 6) + { + return p + (q - p) * 6 * t; + } + + if (t < 1 / 2) + { + return q; + } + + if (t < 2 / 3) + { + return p + (q - p) * (2 / 3 - t) * 6; + } + + return p; +}; + +module.exports = HueToComponent; + + +/***/ }, + +/***/ 30100 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Color = __webpack_require__(40987); +var IntegerToRGB = __webpack_require__(90664); + +/** + * Converts the given color value into an instance of a Color object. + * + * @function Phaser.Display.Color.IntegerToColor + * @since 3.0.0 + * + * @param {number} input - The 32-bit integer color value to convert, such as a hex value like `0xff0000` for red. + * @param {Phaser.Display.Color} [color] - An optional Color object to store the result in. If not provided, a new Color object is created and returned. + * + * @return {Phaser.Display.Color} A Color object containing the red, green, blue, and alpha components extracted from the given integer. + */ +var IntegerToColor = function (input, color) +{ + var rgb = IntegerToRGB(input); + + if (!color) { return new Color(rgb.r, rgb.g, rgb.b, rgb.a); } + + return color.setTo(rgb.r, rgb.g, rgb.b, rgb.a); +}; + +module.exports = IntegerToColor; + + +/***/ }, + +/***/ 90664 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * If the color value includes an alpha component (0xAARRGGBB), it is extracted and set in the `a` property. + * Otherwise, alpha defaults to 255 (fully opaque). + * + * @function Phaser.Display.Color.IntegerToRGB + * @since 3.0.0 + * + * @param {number} color - The color value to convert into a Color object. + * + * @return {Phaser.Types.Display.ColorObject} An object with the alpha, red, green, and blue values set in the a, r, g, and b properties. + */ +var IntegerToRGB = function (color) +{ + if (color > 16777215) + { + // The color value has an alpha component + return { + a: color >>> 24, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } + else + { + return { + a: 255, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } +}; + +module.exports = IntegerToRGB; + + +/***/ }, + +/***/ 13699 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Linear = __webpack_require__(28915); +var GetColor = __webpack_require__(37589); +var HSVToRGB = __webpack_require__(7537); + +/** + * @namespace Phaser.Display.Color.Interpolate + * @memberof Phaser.Display.Color + * @since 3.0.0 + */ + +/** + * Interpolates between the two given RGB color values over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.RGBWithRGB + * @memberof Phaser.Display.Color.Interpolate + * @static + * @since 3.0.0 + * + * @param {number} r1 - Red value. + * @param {number} g1 - Green value. + * @param {number} b1 - Blue value. + * @param {number} r2 - Red value. + * @param {number} g2 - Green value. + * @param {number} b2 - Blue value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {Phaser.Types.Display.ColorObject} An object containing the interpolated color values. + */ +var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + var t = index / length; + var r = Linear(r1, r2, t); + var g = Linear(g1, g2, t); + var b = Linear(b1, b2, t); + + return { + r: r, + g: g, + b: b, + a: 255, + color: GetColor(r, g, b) + }; +}; + +/** + * Interpolates between the two given HSV color ranges over the length supplied. + * The `sign` parameter controls the direction of hue interpolation: 0 finds the + * nearest path, a positive value always increases hue, and a negative value always + * decreases hue. + * + * @function Phaser.Display.Color.Interpolate.HSVWithHSV + * @memberof Phaser.Display.Color.Interpolate + * @static + * @since 4.0.0 + * + * @param {number} h1 - Hue of the first color (0 to 1). + * @param {number} s1 - Saturation of the first color (0 to 1). + * @param {number} v1 - Value (brightness) of the first color (0 to 1). + * @param {number} h2 - Hue of the second color (0 to 1). + * @param {number} s2 - Saturation of the second color (0 to 1). + * @param {number} v2 - Value (brightness) of the second color (0 to 1). + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * @param {number} [sign=0] - Hue interpolation direction. 0 = nearest, positive = always increase, negative = always decrease. + * + * @return {Phaser.Types.Display.ColorObject} An object containing the interpolated color values. + */ +var HSVWithHSV = function (h1, s1, v1, h2, s2, v2, length, index, sign) +{ + if (sign === undefined) { sign = 0; } + if (sign === 0) + { + // Nearest hue. + var dH = h1 - h2; + if (dH > 0.5) { h1 -= 1; } + else if (dH < -0.5) { h1 += 1; } + } + else if (sign > 0) + { + // Strictly increase hue. + if (h1 > h2) { h1 -= 1; } + } + else if (h1 < h2) { h1 += 1; } // Strictly decrease hue. + + var t = index / length; + var h = Linear(h1, h2, t); + var s = Linear(s1, s2, t); + var v = Linear(v1, v2, t); + return HSVToRGB(h, s, v); +}; + +/** + * Interpolates between the two given color objects over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithColor + * @memberof Phaser.Display.Color.Interpolate + * @static + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {Phaser.Display.Color} color2 - The second Color object. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * @param {boolean} [hsv=false] - Whether to interpolate in HSV. + * @param {number} [hsvSign=0] - Preferred direction for HSV interpolation. 0 is nearest, negative always decreases hue, positive always increases hue. + * + * @return {Phaser.Types.Display.ColorObject} An object containing the interpolated color values. + */ +var ColorWithColor = function (color1, color2, length, index, hsv, hsvSign) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + if (hsv) + { + return HSVWithHSV(color1.h, color1.s, color1.v, color2.h, color2.s, color2.v, length, index, hsvSign); + } + + return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); +}; + +/** + * Interpolates between the Color object and color values over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithRGB + * @memberof Phaser.Display.Color.Interpolate + * @static + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color - The Color object. + * @param {number} r - Red value. + * @param {number} g - Green value. + * @param {number} b - Blue value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {Phaser.Types.Display.ColorObject} An object containing the interpolated color values. + */ +var ColorWithRGB = function (color, r, g, b, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); +}; + +module.exports = { + + RGBWithRGB: RGBWithRGB, + HSVWithHSV: HSVWithHSV, + ColorWithRGB: ColorWithRGB, + ColorWithColor: ColorWithColor + +}; + + +/***/ }, + +/***/ 68957 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Color = __webpack_require__(40987); + +/** + * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * + * @function Phaser.Display.Color.ObjectToColor + * @since 3.0.0 + * + * @param {Phaser.Types.Display.InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * @param {Phaser.Display.Color} [color] - The color where the new color will be stored. If not defined, a new color object is returned. + * + * @return {Phaser.Display.Color} A Color object. + */ +var ObjectToColor = function (input, color) +{ + if (!color) { return new Color(input.r, input.g, input.b, input.a); } + + return color.setTo(input.r, input.g, input.b, input.a); +}; + +module.exports = ObjectToColor; + + +/***/ }, + +/***/ 87388 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Color = __webpack_require__(40987); + +/** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * + * @function Phaser.Display.Color.RGBStringToColor + * @since 3.0.0 + * + * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. + * @param {Phaser.Display.Color} [color] - An optional Color object to populate with the parsed values. If not provided, a new Color object is created and returned. + * + * @return {Phaser.Display.Color} The Color object populated with the parsed RGB or RGBA values. + */ +var RGBStringToColor = function (rgb, color) +{ + if (!color) { color = new Color(); } + + var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + + if (result) + { + var r = parseInt(result[1], 10); + var g = parseInt(result[2], 10); + var b = parseInt(result[3], 10); + var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + + color.setTo(r, g, b, a * 255); + } + + return color; +}; + +module.exports = RGBStringToColor; + + +/***/ }, + +/***/ 87837 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.RGBToHSV + * @since 3.0.0 + * + * @param {number} r - The red color value. A number between 0 and 255. + * @param {number} g - The green color value. A number between 0 and 255. + * @param {number} b - The blue color value. A number between 0 and 255. + * @param {(Phaser.Types.Display.HSVColorObject|Phaser.Display.Color)} [out] - An object to store the color values in. If not given an HSV Color Object will be created. + * + * @return {(Phaser.Types.Display.HSVColorObject|Phaser.Display.Color)} An object with the properties `h`, `s` and `v` set. + */ +var RGBToHSV = function (r, g, b, out) +{ + if (out === undefined) { out = { h: 0, s: 0, v: 0 }; } + + r /= 255; + g /= 255; + b /= 255; + + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var d = max - min; + + // achromatic by default + var h = 0; + var s = (max === 0) ? 0 : d / max; + var v = max; + + if (max !== min) + { + if (max === r) + { + h = (g - b) / d + ((g < b) ? 6 : 0); + } + else if (max === g) + { + h = (b - r) / d + 2; + } + else if (max === b) + { + h = (r - g) / d + 4; + } + + h /= 6; + } + + if (out.hasOwnProperty('_h')) + { + out._h = h; + out._s = s; + out._v = v; + } + else + { + out.h = h; + out.s = s; + out.v = v; + } + + return out; +}; + +module.exports = RGBToHSV; + + +/***/ }, + +/***/ 75723 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ComponentToHex = __webpack_require__(62957); + +/** + * Converts the given red, green, blue, and alpha color component values into a hex color string. + * + * When using the `#` prefix the result is a 6-character CSS-compatible hex string in `#rrggbb` format. + * The alpha value is not included in this format. + * + * When using the `0x` prefix the result is an 8-character ARGB hex string in `0xaarrggbb` format, + * which includes the alpha component as the most significant byte. + * + * @function Phaser.Display.Color.RGBToString + * @since 3.0.0 + * + * @param {number} r - The red color value. A number between 0 and 255. + * @param {number} g - The green color value. A number between 0 and 255. + * @param {number} b - The blue color value. A number between 0 and 255. + * @param {number} [a=255] - The alpha value. A number between 0 and 255. + * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. + * + * @return {string} A hex color string in either `#rrggbb` or `0xaarrggbb` format, depending on the prefix. + */ +var RGBToString = function (r, g, b, a, prefix) +{ + if (a === undefined) { a = 255; } + if (prefix === undefined) { prefix = '#'; } + + if (prefix === '#') + { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1, 7); + } + else + { + return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); + } +}; + +module.exports = RGBToString; + + +/***/ }, + +/***/ 85386 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Between = __webpack_require__(30976); +var Color = __webpack_require__(40987); + +/** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * + * @function Phaser.Display.Color.RandomRGB + * @since 3.0.0 + * + * @param {number} [min=0] - The minimum value to set the random range from (between 0 and 255) + * @param {number} [max=255] - The maximum value to set the random range from (between 0 and 255) + * + * @return {Phaser.Display.Color} A Color object. + */ +var RandomRGB = function (min, max) +{ + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + return new Color(Between(min, max), Between(min, max), Between(min, max)); +}; + +module.exports = RandomRGB; + + +/***/ }, + +/***/ 80333 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var HexStringToColor = __webpack_require__(70238); +var IntegerToColor = __webpack_require__(30100); +var ObjectToColor = __webpack_require__(68957); +var RGBStringToColor = __webpack_require__(87388); + +/** + * Converts the given source color value into an instance of a Color class. + * The value can be a string (either prefixed with `rgb` for an RGB color string, or a hex color string), + * a number representing a packed RGB integer, or a plain object with `r`, `g`, and `b` properties. + * + * @function Phaser.Display.Color.ValueToColor + * @since 3.0.0 + * + * @param {(string|number|Phaser.Types.Display.InputColorObject)} input - The source color value to convert. + * @param {Phaser.Display.Color} [color] - An existing Color object to store the result in. If not provided, a new Color object is created and returned. + * + * @return {Phaser.Display.Color} A Color object containing the converted color value. + */ +var ValueToColor = function (input, color) +{ + var t = typeof input; + + switch (t) + { + case 'string': + + if (input.substr(0, 3).toLowerCase() === 'rgb') + { + return RGBStringToColor(input, color); + } + else + { + return HexStringToColor(input, color); + } + + case 'number': + + return IntegerToColor(input, color); + + case 'object': + + return ObjectToColor(input, color); + } +}; + +module.exports = ValueToColor; + + +/***/ }, + +/***/ 3956 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Color = __webpack_require__(40987); + +Color.ColorSpectrum = __webpack_require__(92728); +Color.ColorToRGBA = __webpack_require__(91588); +Color.ComponentToHex = __webpack_require__(62957); +Color.GetColor = __webpack_require__(37589); +Color.GetColor32 = __webpack_require__(1000); +Color.HexStringToColor = __webpack_require__(70238); +Color.HSLToColor = __webpack_require__(62183); +Color.HSVColorWheel = __webpack_require__(27939); +Color.HSVToRGB = __webpack_require__(7537); +Color.HueToComponent = __webpack_require__(89528); +Color.IntegerToColor = __webpack_require__(30100); +Color.IntegerToRGB = __webpack_require__(90664); +Color.Interpolate = __webpack_require__(13699); +Color.ObjectToColor = __webpack_require__(68957); +Color.RandomRGB = __webpack_require__(85386); +Color.RGBStringToColor = __webpack_require__(87388); +Color.RGBToHSV = __webpack_require__(87837); +Color.RGBToString = __webpack_require__(75723); +Color.ValueToColor = __webpack_require__(80333); + +module.exports = Color; + + +/***/ }, + +/***/ 27460 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Display + */ + +module.exports = { + + Align: __webpack_require__(71926), + BaseShader: __webpack_require__(73894), + Bounds: __webpack_require__(58724), + Canvas: __webpack_require__(26253), + Color: __webpack_require__(3956), + ColorBand: __webpack_require__(34664), + ColorMatrix: __webpack_require__(89422), + ColorRamp: __webpack_require__(73043), + Masks: __webpack_require__(69781), + RGB: __webpack_require__(51767) + +}; + + +/***/ }, + +/***/ 80661 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect + * a visible pixel from the geometry mask. The mask is essentially a clipping path which can only + * make a masked pixel fully visible or fully invisible without changing its alpha (opacity). + * + * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) + * should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed + * if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and + * alpha of the pixel from the Geometry Mask do not matter. + * + * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. + * Moving or transforming the underlying Graphics object will change the mask (and affect the visibility + * of any masked objects), whereas moving or transforming a masked object will not affect the mask. + * You can think of the Geometry Mask (or rather, of its Graphics object) as an invisible curtain placed + * in front of all masked objects which has its own visual properties and, naturally, respects the camera's + * visual properties, but isn't affected by and doesn't follow the masked objects by itself. + * + * GeometryMask is only supported in the Canvas Renderer. + * If you want to use geometry to mask objects in WebGL, + * see {@link Phaser.GameObjects.Components.FilterList#addMask}. + * + * @class GeometryMask + * @memberof Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - This parameter is not used. + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. + */ +var GeometryMask = new Class({ + + initialize: + + function GeometryMask (scene, graphicsGeometry) + { + /** + * The Graphics object which describes the Geometry Mask. + * + * @name Phaser.Display.Masks.GeometryMask#geometryMask + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.geometryMask = graphicsGeometry; + }, + + /** + * Sets a new Graphics object for the Geometry Mask. + * + * @method Phaser.Display.Masks.GeometryMask#setShape + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics object which will be used for the Geometry Mask. + * + * @return {this} This Geometry Mask + */ + setShape: function (graphicsGeometry) + { + this.geometryMask = graphicsGeometry; + + return this; + }, + + /** + * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. + * + * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas + * @since 3.0.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance to set the clipping path on. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. + */ + preRenderCanvas: function (renderer, mask, camera) + { + var geometryMask = this.geometryMask; + + renderer.currentContext.save(); + + geometryMask.renderCanvas(renderer, geometryMask, camera, null, null, true); + + renderer.currentContext.clip(); + }, + + /** + * Restores the canvas context's previous clipping path, thus turning off the mask for it. + * + * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas + * @since 3.0.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance being restored. + */ + postRenderCanvas: function (renderer) + { + renderer.currentContext.restore(); + }, + + /** + * Destroys this GeometryMask and nulls any references it holds. + * + * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, + * so be sure to call `clearMask` on any Game Object using it, before destroying it. + * + * @method Phaser.Display.Masks.GeometryMask#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.geometryMask = null; + } + +}); + +module.exports = GeometryMask; + + +/***/ }, + +/***/ 69781 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Display.Masks + */ + +module.exports = { + + GeometryMask: __webpack_require__(80661) + +}; + + +/***/ }, + +/***/ 73894 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * A BaseShader is a small resource class that contains GLSL code for a shader. + * + * It contains the key of the shader, the source code, and optional metadata. + * Phaser does not enforce a specific shader type: the source could be a + * fragment shader, a vertex shader, or even an incomplete snippet of GLSL. + * It is stored as raw source code and may be retrieved and compiled as you wish. + * These keys can be used by `Phaser.GameObjects.Shader` and + * `Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader`. + * + * BaseShaders are stored in the Shader Cache, available in a Scene via `this.cache.shaders` and are referenced + * by a unique key-based string. Retrieve them via `this.cache.shaders.get(key)`. + * + * BaseShaders are created automatically by the GLSL File Loader when loading an external shader resource. + * They can also be created at runtime, allowing you to use dynamically generated shader source code. + * + * @class BaseShader + * @memberof Phaser.Display + * @constructor + * @since 4.0.0 + * + * @param {string} key - The key of this shader. Must be unique within the shader cache. + * @param {string} glsl - The GLSL source code for the shader. + * @param {object} [metadata] - Additional metadata for this shader code. + */ +var BaseShader = new Class({ + initialize: function BaseShader (key, glsl, metadata) + { + if (metadata === undefined) { metadata = {}; } + + /** + * The key of this shader code, + * unique within the shader cache of this Phaser game instance. + * + * @name Phaser.Display.BaseShader#key + * @type {string} + * @since 3.17.0 + */ + this.key = key; + + /** + * GLSL source code for a shader. + * The use of this code is not specified by Phaser. + * You can add metadata to further describe its purpose. + * + * @name Phaser.Display.BaseShader#glsl + * @type {string} + * @since 4.0.0 + */ + this.glsl = glsl; + + /** + * Additional metadata for this shader. This is not used by Phaser, + * but it may be used by your game code or external tools. + * For example, you could add properties that describe + * the shader's purpose, author, version, etc. + * + * @name Phaser.Display.BaseShader#metadata + * @type {object} + * @since 4.0.0 + */ + this.metadata = metadata; + } +}); + +module.exports = BaseShader; + + +/***/ }, + +/***/ 40366 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Adds the given element to the DOM. If a parent is provided, the element is added as a child of the parent element, resolved either by + * passing a string ID to `getElementById` or by using the HTMLElement directly. If no parent is given and the element already has an + * existing `parentElement`, or if `parent` is explicitly `null`, the element is returned immediately without modification. If no valid + * target parent can be resolved, the element is appended to `document.body` as a fallback. + * + * @function Phaser.DOM.AddToDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The element to be added to the DOM. Usually a Canvas object. + * @param {(string|HTMLElement)} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. + * + * @return {HTMLElement} The element that was passed to this function. + */ +var AddToDOM = function (element, parent) +{ + var target; + + if (parent) + { + if (typeof parent === 'string') + { + // Hopefully an element ID + target = document.getElementById(parent); + } + else if (typeof parent === 'object' && parent.nodeType === 1) + { + // Quick test for a HTMLElement + target = parent; + } + } + else if (element.parentElement || parent === null) + { + return element; + } + + // Fallback, covers an invalid ID and a non HTMLElement object + if (!target) + { + target = document.body; + } + + target.appendChild(element); + + return element; +}; + +module.exports = AddToDOM; + + +/***/ }, + +/***/ 83719 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AddToDOM = __webpack_require__(40366); + +/** + * Creates a DOM container div element for use with DOM Game Objects. + * + * The container is an absolutely positioned div that overlays the game canvas, + * matching its dimensions, and is added to the game's parent element. + * It has pointer events set according to the game configuration and + * serves as the parent for any DOM Element Game Objects added to a Scene. + * + * This function is called automatically during game boot if the game config + * has both a `parent` element and `domCreateContainer` set to `true`. + * + * @function Phaser.DOM.CreateDOMContainer + * @since 3.12.0 + * + * @param {Phaser.Game} game - The Phaser Game instance to create the DOM container for. + */ +var CreateDOMContainer = function (game) +{ + var config = game.config; + + if (!config.parent || !config.domCreateContainer) + { + return; + } + + // DOM Element Container + var div = document.createElement('div'); + + div.style.cssText = [ + 'display: block;', + 'width: ' + game.scale.width + 'px;', + 'height: ' + game.scale.height + 'px;', + 'padding: 0; margin: 0;', + 'position: absolute;', + 'overflow: hidden;', + 'pointer-events: ' + config.domPointerEvents + ';', + 'transform: scale(1);', + 'transform-origin: left top;' + ].join(' '); + + game.domContainer = div; + + AddToDOM(div, config.parent); +}; + +module.exports = CreateDOMContainer; + + +/***/ }, + +/***/ 57264 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var OS = __webpack_require__(25892); + +/** + * A callback function to be invoked once the DOM content is fully loaded and the device is ready. + * + * @callback ContentLoadedCallback + */ + +/** + * Inspects the readyState of the document. If the document is already complete or interactive, it invokes the given + * callback immediately. If not, it registers event listeners to detect when the document becomes ready. On Cordova + * environments it listens for the `deviceready` event; otherwise it listens for `DOMContentLoaded` and the window + * `load` event, invoking the callback whichever fires first. If the document body is not yet available, it falls + * back to a short timeout before invoking the callback. + * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. + * + * @function Phaser.DOM.DOMContentLoaded + * @since 3.0.0 + * + * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. + */ +var DOMContentLoaded = function (callback) +{ + if (document.readyState === 'complete' || document.readyState === 'interactive') + { + callback(); + + return; + } + + var check = function () + { + document.removeEventListener('deviceready', check, true); + document.removeEventListener('DOMContentLoaded', check, true); + window.removeEventListener('load', check, true); + + callback(); + }; + + if (!document.body) + { + window.setTimeout(check, 20); + } + else if (OS.cordova) + { + // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready + document.addEventListener('deviceready', check, false); + } + else + { + document.addEventListener('DOMContentLoaded', check, true); + window.addEventListener('load', check, true); + } +}; + +module.exports = DOMContentLoaded; + + +/***/ }, + +/***/ 57811 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Attempts to determine the document inner height across iOS and standard devices. + * On non-iOS devices this simply returns `window.innerHeight`. On iOS, Safari's dynamic + * browser chrome (such as the address bar appearing or hiding on scroll) can cause + * `window.innerHeight` to report an inaccurate value. To work around this, a temporary + * fixed-position element sized to `100vh` is injected into the DOM, its measured height + * is used instead, and the element is immediately removed. The result is also adjusted + * for landscape orientation using `window.orientation`. + * Based on code by @tylerjpeterson + * + * @function Phaser.DOM.GetInnerHeight + * @since 3.16.0 + * + * @param {boolean} iOS - Is this running on iOS? + * + * @return {number} The inner height of the viewport, in pixels. + */ +var GetInnerHeight = function (iOS) +{ + + if (!iOS) + { + return window.innerHeight; + } + + var axis = Math.abs(window.orientation); + + var size = { w: 0, h: 0 }; + + var ruler = document.createElement('div'); + + ruler.setAttribute('style', 'position: fixed; height: 100vh; width: 0; top: 0'); + + document.documentElement.appendChild(ruler); + + size.w = (axis === 90) ? ruler.offsetHeight : window.innerWidth; + size.h = (axis === 90) ? window.innerWidth : ruler.offsetHeight; + + document.documentElement.removeChild(ruler); + + ruler = null; + + if (Math.abs(window.orientation) !== 90) + { + return size.h; + } + else + { + return size.w; + } +}; + +module.exports = GetInnerHeight; + + +/***/ }, + +/***/ 45818 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(13560); + +/** + * Attempts to determine the screen orientation using a series of browser APIs, + * falling back to comparing the viewport dimensions if none are available. + * + * It checks, in order: the Screen Orientation API (`screen.orientation`, + * `screen.mozOrientation`, `screen.msOrientation`), the legacy `window.orientation` + * property (used on iOS), the `window.matchMedia` API, and finally a simple + * width-versus-height comparison as a last resort. + * + * @function Phaser.DOM.GetScreenOrientation + * @since 3.16.0 + * + * @param {number} width - The width of the viewport. + * @param {number} height - The height of the viewport. + * + * @return {string} Either a `Phaser.Scale.PORTRAIT` or `Phaser.Scale.LANDSCAPE` string constant, or the raw orientation type string returned by the Screen Orientation API. + */ +var GetScreenOrientation = function (width, height) +{ + var screen = window.screen; + var orientation = (screen) ? screen.orientation || screen.mozOrientation || screen.msOrientation : false; + + if (orientation && typeof orientation.type === 'string') + { + // Screen Orientation API specification + return orientation.type; + } + else if (typeof orientation === 'string') + { + // moz / ms-orientation are strings + return orientation; + } + + if (typeof window.orientation === 'number') + { + // Do this check first, as iOS supports this, but also has an incomplete window.screen implementation + // This may change by device based on "natural" orientation. + return (window.orientation === 0 || window.orientation === 180) ? CONST.ORIENTATION.PORTRAIT : CONST.ORIENTATION.LANDSCAPE; + } + else if (window.matchMedia) + { + if (window.matchMedia('(orientation: portrait)').matches) + { + return CONST.ORIENTATION.PORTRAIT; + } + else if (window.matchMedia('(orientation: landscape)').matches) + { + return CONST.ORIENTATION.LANDSCAPE; + } + } + else + { + return (height > width) ? CONST.ORIENTATION.PORTRAIT : CONST.ORIENTATION.LANDSCAPE; + } +}; + +module.exports = GetScreenOrientation; + + +/***/ }, + +/***/ 74403 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Attempts to get the target DOM element based on the given value, which can be either + * a string, in which case it will be looked-up by ID, or an element node. If nothing + * can be found it will return a reference to the document.body. + * + * @function Phaser.DOM.GetTarget + * @since 3.16.0 + * + * @param {HTMLElement} element - The DOM element to look-up. Can be either a string, in which case it is used as an element ID to look up via `document.getElementById`, or a direct reference to an existing HTMLElement node. + * + * @return {HTMLElement} The DOM element matching the given ID or node reference, or `document.body` if no valid target was found. + */ +var GetTarget = function (element) +{ + var target; + + if (element !== '') + { + if (typeof element === 'string') + { + // Hopefully an element ID + target = document.getElementById(element); + } + else if (element && element.nodeType === 1) + { + // Quick test for a HTMLElement + target = element; + } + } + + // Fallback to the document body. Covers an invalid ID and a non HTMLElement object. + if (!target) + { + // Use the full window + target = document.body; + } + + return target; +}; + +module.exports = GetTarget; + + +/***/ }, + +/***/ 56836 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Takes the given data string and parses it as XML. + * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. + * The parsed XML object is returned, or `null` if there was an error while parsing the data. + * + * @function Phaser.DOM.ParseXML + * @since 3.0.0 + * + * @param {string} data - The XML source stored in a string. + * + * @return {?XMLDocument} The parsed XML data, or `null` if the data could not be parsed. + */ +var ParseXML = function (data) +{ + var xml = ''; + + try + { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(data, 'text/xml'); + } + else + { + xml = new ActiveXObject('Microsoft.XMLDOM'); + xml.loadXML(data); + } + } + catch (e) + { + xml = null; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) + { + return null; + } + else + { + return xml; + } +}; + +module.exports = ParseXML; + + +/***/ }, + +/***/ 35846 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Attempts to remove the element from its parentNode in the DOM. + * + * @function Phaser.DOM.RemoveFromDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The DOM element to remove from its parent node. + */ +var RemoveFromDOM = function (element) +{ + if (element.parentNode) + { + element.parentNode.removeChild(element); + } +}; + +module.exports = RemoveFromDOM; + + +/***/ }, + +/***/ 43092 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var NOOP = __webpack_require__(29747); + +/** + * @classdesc + * Abstracts away the use of `requestAnimationFrame` or `setTimeout` for the core game update loop, + * providing a unified interface regardless of which mechanism is in use. + * + * When `requestAnimationFrame` is available and not overridden, it is used to drive the game loop, + * which ties updates to the display refresh rate and pauses automatically when the tab is hidden. + * If `forceSetTimeOut` is enabled in the Game Config, `setTimeout` is used instead, which runs + * at a fixed interval regardless of visibility or display sync. + * + * This class is instantiated and managed automatically by the Phaser.Game instance. + * + * @class RequestAnimationFrame + * @memberof Phaser.DOM + * @constructor + * @since 3.0.0 + */ +var RequestAnimationFrame = new Class({ + + initialize: + + function RequestAnimationFrame () + { + /** + * True if RequestAnimationFrame is running, otherwise false. + * + * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * The callback to be invoked each step. + * + * @name Phaser.DOM.RequestAnimationFrame#callback + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * True if the step is using setTimeout instead of RAF. + * + * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isSetTimeOut = false; + + /** + * The setTimeout or RAF callback ID used when canceling them. + * + * @name Phaser.DOM.RequestAnimationFrame#timeOutID + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.timeOutID = null; + + /** + * The delay, in milliseconds, between each step when using setTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#delay + * @type {number} + * @default 0 + * @since 3.60.0 + */ + this.delay = 0; + + var _this = this; + + /** + * The RAF step function. + * + * Invokes the callback and schedules another call to requestAnimationFrame. + * + * @name Phaser.DOM.RequestAnimationFrame#step + * @type {FrameRequestCallback} + * @since 3.0.0 + * + * @param {number} time - The timestamp passed in from RequestAnimationFrame. + */ + this.step = function step (time) + { + _this.callback(time); + + if (_this.isRunning) + { + _this.timeOutID = window.requestAnimationFrame(step); + } + }; + + /** + * The SetTimeout step function. + * + * Invokes the callback and schedules another call to setTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#stepTimeout + * @type {function} + * @since 3.0.0 + */ + this.stepTimeout = function stepTimeout () + { + if (_this.isRunning) + { + // Make the next request before the callback, so that timing is maintained + _this.timeOutID = window.setTimeout(stepTimeout, _this.delay); + } + + _this.callback(window.performance.now()); + }; + }, + + /** + * Starts the requestAnimationFrame or setTimeout process running. + * + * @method Phaser.DOM.RequestAnimationFrame#start + * @since 3.0.0 + * + * @param {FrameRequestCallback} callback - The callback to invoke each step. + * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? + * @param {number} delay - The delay, in milliseconds, between each step when using setTimeout. + */ + start: function (callback, forceSetTimeOut, delay) + { + if (this.isRunning) + { + return; + } + + this.callback = callback; + + this.isSetTimeOut = forceSetTimeOut; + + this.delay = delay; + + this.isRunning = true; + + this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); + }, + + /** + * Stops the requestAnimationFrame or setTimeout from running. + * + * @method Phaser.DOM.RequestAnimationFrame#stop + * @since 3.0.0 + */ + stop: function () + { + this.isRunning = false; + + if (this.isSetTimeOut) + { + clearTimeout(this.timeOutID); + } + else + { + window.cancelAnimationFrame(this.timeOutID); + } + }, + + /** + * Stops the step from running and clears the callback reference. + * + * @method Phaser.DOM.RequestAnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + } + +}); + +module.exports = RequestAnimationFrame; + + +/***/ }, + +/***/ 84902 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.DOM + */ + +var Dom = { + + AddToDOM: __webpack_require__(40366), + DOMContentLoaded: __webpack_require__(57264), + GetInnerHeight: __webpack_require__(57811), + GetScreenOrientation: __webpack_require__(45818), + GetTarget: __webpack_require__(74403), + ParseXML: __webpack_require__(56836), + RemoveFromDOM: __webpack_require__(35846), + RequestAnimationFrame: __webpack_require__(43092) + +}; + +module.exports = Dom; + + +/***/ }, + +/***/ 47565 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var EE = __webpack_require__(50792); +var PluginCache = __webpack_require__(37277); + +/** + * @classdesc + * EventEmitter is a Scene Systems plugin compatible wrapper around the `eventemitter3` library, + * providing a full-featured event emitter used throughout Phaser for event-driven communication + * between game objects, scenes, and systems. + * + * Every Scene has an instance of this class available via `scene.events`, and many Phaser objects + * extend or embed it to dispatch and receive events. It supports persistent listeners via `on` / + * `addListener`, one-time listeners that auto-remove after firing via `once`, and listener removal + * via `off` / `removeListener`. + * + * You can also instantiate it directly when you need a standalone event bus within your own code. + * + * @class EventEmitter + * @memberof Phaser.Events + * @constructor + * @since 3.0.0 + */ +var EventEmitter = new Class({ + + Extends: EE, + + initialize: + + function EventEmitter () + { + EE.call(this); + }, + + /** + * Removes all listeners from this EventEmitter. This method is called automatically + * by the Scene Systems when the parent Scene shuts down, ensuring that all event + * bindings are cleared and no stale references remain. + * + * @method Phaser.Events.EventEmitter#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * Removes all listeners from this EventEmitter and prepares it for garbage collection. + * This method is called automatically when the parent object is destroyed and should + * not be called directly unless you are tearing down the emitter manually. + * + * @method Phaser.Events.EventEmitter#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + } + +}); + +/** + * Return an array listing the events for which the emitter has registered listeners. + * + * @method Phaser.Events.EventEmitter#eventNames + * @since 3.0.0 + * + * @return {Array.} + */ + +/** + * Return the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#listeners + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {Function[]} The registered listeners. + */ + +/** + * Return the number of listeners listening to a given event. + * + * @method Phaser.Events.EventEmitter#listenerCount + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {number} The number of listeners. + */ + +/** + * Calls each of the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#emit + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {...*} [args] - Additional arguments that will be passed to the event handler. + * + * @return {boolean} `true` if the event had listeners, else `false`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#on + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {this} `this`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#addListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {this} `this`. + */ + +/** + * Add a one-time listener for a given event. The listener is automatically removed + * the first time the event is emitted, so it will never be called more than once. + * + * @method Phaser.Events.EventEmitter#once + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {this} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#removeListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} [fn] - Only remove the listeners that match this function. + * @param {*} [context] - Only remove the listeners that have this context. + * @param {boolean} [once] - Only remove one-time listeners. + * + * @return {this} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#off + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} [fn] - Only remove the listeners that match this function. + * @param {*} [context] - Only remove the listeners that have this context. + * @param {boolean} [once] - Only remove one-time listeners. + * + * @return {this} `this`. + */ + +/** + * Remove all listeners, or those of the specified event. + * + * @method Phaser.Events.EventEmitter#removeAllListeners + * @since 3.0.0 + * + * @param {(string|symbol)} [event] - The event name. + * + * @return {this} `this`. + */ + +PluginCache.register('EventEmitter', EventEmitter, 'events'); + +module.exports = EventEmitter; + + +/***/ }, + +/***/ 93055 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Events + */ + +module.exports = { EventEmitter: __webpack_require__(47565) }; + + +/***/ }, + +/***/ 10189 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Barrel Filter Controller. + * + * This filter controller manages the barrel distortion effect for a Camera. + * A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to + * the view. The amount of the effect can be modified in real-time. + * + * A Barrel effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addBarrel(); + * camera.filters.external.addBarrel(); + * ``` + * + * @class Barrel + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {number} [amount=1] - The amount of distortion applied to the barrel effect. A value of 1 is no distortion. Typically keep this within +- 1. + */ +var Barrel = new Class({ + Extends: Controller, + + initialize: function Barrel (camera, amount) + { + if (amount === undefined) { amount = 1; } + + Controller.call(this, camera, 'FilterBarrel'); + + /** + * The amount of distortion applied to the barrel effect. + * + * A value of 1 applies no distortion. Values above 1 expand the view outward + * (barrel distortion), while values below 1 pinch the view inward (pincushion + * distortion). Typically keep this within ±1 of the default value of 1. + * + * @name Phaser.Filters.Barrel#amount + * @type {number} + * @since 4.0.0 + */ + this.amount = amount; + } +}); + +module.exports = Barrel; + + +/***/ }, + +/***/ 16762 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Blend Filter Controller. + * + * This filter controller manages the blend effect for a Camera. + * A blend effect allows you to apply another texture to the view + * using a specific blend mode. + * This supports blend modes not otherwise available in WebGL. + * + * A Blend effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addBlend(); + * camera.filters.external.addBlend(); + * ``` + * + * @class Blend + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {string} [texture='__WHITE'] - The texture to apply to the view. + * @param {Phaser.BlendModes} [blendMode=Phaser.BlendModes.NORMAL] - The blend mode to apply to the view. + * @param {number} [amount=1] - The amount of the blend effect to apply to the view. At 0, the original image is preserved. At 1, the blend texture is fully applied. The expected range is 0 to 1, but you can go outside that range for different effects. + * @param {number[]} [color=[1, 1, 1, 1]] - The color to apply to the blend texture. Each value corresponds to a color channel in RGBA. The expected range is 0 to 1, but you can go outside that range for different effects. + */ +var Blend = new Class({ + Extends: Controller, + + initialize: function Blend (camera, texture, blendMode, amount, color) + { + if (texture === undefined) { texture = '__WHITE'; } + if (blendMode === undefined) { blendMode = 0; } + if (amount === undefined) { amount = 1; } + if (color === undefined) { color = [ 1, 1, 1, 1 ]; } + + Controller.call(this, camera, 'FilterBlend'); + + /** + * The underlying texture used for the blend. + * + * @name Phaser.Filters.Blend#glTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + */ + this.glTexture; + + /** + * The blend mode to apply to the view. + * This supports blend modes not otherwise available in WebGL. + * + * @name Phaser.Filters.Blend#blendMode + * @type {Phaser.BlendModes} + * @since 4.0.0 + * @default Phaser.BlendModes.NORMAL + */ + this.blendMode = blendMode; + + /** + * The amount of the blend effect to apply to the view. + * At 0, the original image is preserved. At 1, the blend texture is fully applied. + * + * @name Phaser.Filters.Blend#amount + * @type {number} + * @since 4.0.0 + * @default 1 + */ + this.amount = amount; + + /** + * The color to apply to the blend texture. + * Each value corresponds to a color channel in RGBA. + * The expected range is 0 to 1, but you can go outside that range for different effects. + * + * @name Phaser.Filters.Blend#color + * @type {number[]} + * @since 4.0.0 + * @default [1, 1, 1, 1] + */ + this.color = color; + + this.setTexture(texture); + }, + + /** + * Sets the texture used for the blend. + * + * @method Phaser.Filters.Blend#setTexture + * @since 4.0.0 + * @param {string} [texture='__WHITE'] - The unique string-based key of the texture to use for the blend, which must exist in the Texture Manager. + * @return {this} This Filter Controller. + */ + setTexture: function (texture) + { + var phaserTexture = this.camera.scene.sys.textures.getFrame(texture); + + if (phaserTexture) + { + this.glTexture = phaserTexture.glTexture; + } + + return this; + } +}); + +module.exports = Blend; + + +/***/ }, + +/***/ 37597 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Blocky Filter Controller. + * + * This filter controller manages a blocky effect. + * + * The blocky effect works by taking the central pixel of a block of pixels + * and using it to fill the entire block, creating a pixelated effect. + * + * It reduces the resolution of an image, + * creating a pixelated or blocky appearance. + * This is often used for stylistic purposes, such as pixel art. + * One technique is to render the game at a higher resolution, + * scaled up by a factor of N, + * and then apply the blocky effect at size N. + * This creates large, visible pixels, suitable for further stylization. + * The effect can also be used to obscure certain elements within the game, + * such as during a transition or to censor specific content. + * + * Blocky works best on games with no anti-aliasing, + * so it can read unfiltered pixel colors from the original image. + * It preserves the colors of the original art, instead of blending them + * like the Pixelate filter. + * + * A Blocky effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addBlocky({ size: 4 }); + * camera.filters.external.addBlocky({ size: { x: 2, y: 4 }, offset: { x: 1, y: 2 } }); + * ``` + * + * @class Blocky + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {Phaser.Types.Filters.BlockyConfig} [config] - The configuration object for the Blocky effect. + */ +var Blocky = new Class({ + Extends: Controller, + + initialize: function Blocky (camera, config) + { + Controller.call(this, camera, 'FilterBlocky'); + + /** + * The size of the blocks. + * You can set the x and y values to any numbers, + * but the filter will limit them to a minimum of 1. + * + * @name Phaser.Filters.Blocky#size + * @type {Phaser.Types.Math.Vector2Like} + * @default { x: 4, y: 4 } + * @since 4.0.0 + */ + this.size = { + x: 4, + y: 4 + }; + + /** + * The offset of the blocks from the top left corner of the image. + * + * @name Phaser.Filters.Blocky#offset + * @type {Phaser.Types.Math.Vector2Like} + * @default { x: 0, y: 0 } + * @since 4.0.0 + */ + this.offset = { + x: 0, + y: 0 + }; + + if (config) + { + if (config.size !== undefined) + { + if (typeof config.size === 'number') + { + this.size.x = config.size; + this.size.y = config.size; + } + else + { + this.size.x = config.size.x; + this.size.y = config.size.y; + } + } + + if (config.offset !== undefined) + { + if (typeof config.offset === 'number') + { + this.offset.x = config.offset; + this.offset.y = config.offset; + } + else + { + this.offset.x = config.offset.x; + this.offset.y = config.offset.y; + } + } + } + } + +}); + +module.exports = Blocky; + + +/***/ }, + +/***/ 88344 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Blur Filter Controller. + * + * This filter controller manages a blur effect. + * + * A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect, + * typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a + * smooth blur resembling that of viewing the image through a translucent screen, distinctly different + * from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination. + * + * This effect samples across an area. To avoid missing data at the edges, + * use `controller.setPaddingOverride(null)` to automatically pad game objects, + * or `camera.getPaddingWrapper(x)` to enlarge a camera. + * + * A Blur effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addBlur(); + * camera.filters.external.addBlur(); + * ``` + * + * @class Blur + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {number} [quality=0] - The quality of the blur effect. Can be either 0 for Low Quality, 1 for Medium Quality or 2 for High Quality. + * @param {number} [x=2] - The horizontal offset of the blur effect. + * @param {number} [y=2] - The vertical offset of the blur effect. + * @param {number} [strength=1] - The strength of the blur effect. + * @param {number} [color=0xffffff] - The color of the blur, as a hex value. + * @param {number} [steps=4] - The number of steps to run the blur effect for. This value should always be an integer. + */ +var Blur = new Class({ + Extends: Controller, + + initialize: function Blur (camera, quality, x, y, strength, color, steps) + { + if (quality === undefined) { quality = 0; } + if (x === undefined) { x = 2; } + if (y === undefined) { y = 2; } + if (strength === undefined) { strength = 1; } + if (steps === undefined) { steps = 4; } + + Controller.call(this, camera, 'FilterBlur'); + + /** + * The quality of the blur effect. + * + * This can be: + * + * 0 for Low Quality + * 1 for Medium Quality + * 2 for High Quality + * + * The higher the quality, the more complex the shader used, + * and the more processing time is spent on the GPU calculating + * the final blur. This value is used in conjunction with the + * `steps` value, as one has a direct impact on the other. + * + * Keep this value as low as you can, while still achieving the + * desired effect you need for your game. + * + * @name Phaser.Filters.Blur#quality + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.quality = quality; + + /** + * The horizontal offset of the blur effect. This controls the distance + * between blur sample points along the x axis. A larger value increases + * the spread of the blur horizontally. + * + * @name Phaser.Filters.Blur#x + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.x = x; + + /** + * The vertical offset of the blur effect. This controls the distance + * between blur sample points along the y axis. A larger value increases + * the spread of the blur vertically. + * + * @name Phaser.Filters.Blur#y + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.y = y; + + /** + * The strength of the blur effect. This value is multiplied with the + * x and y offsets and the number of steps to determine the total blur + * radius. Increase this to make the blur more pronounced without + * changing the quality or step count. + * + * @name Phaser.Filters.Blur#strength + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.strength = strength; + + /** + * The internal gl color array. + * + * @name Phaser.Filters.Blur#glcolor + * @type {number[]} + * @since 4.0.0 + */ + this.glcolor = [ 1, 1, 1 ]; + + if (color !== undefined && color !== null) + { + this.color = color; + } + + /** + * The number of steps to run the Blur effect for. + * + * This value should always be an integer. + * + * The higher the value, the smoother the blur, + * but at the cost of exponentially more gl operations. + * + * Keep this to the lowest possible number you can have it, while + * still looking correct for your game. + * + * @name Phaser.Filters.Blur#steps + * @type {number} + * @default 4 + * @since 4.0.0 + */ + this.steps = steps; + }, + + /** + * The color of the blur effect, as a packed RGB hex integer (e.g. `0xff0000` + * for red). This tints the blur samples, allowing colored bloom-style effects. + * Defaults to white (`0xffffff`), which produces a neutral blur with no tint. + * + * @name Phaser.Filters.Blur#color + * @type {number} + * @since 4.0.0 + */ + color: { + + get: function () + { + var color = this.glcolor; + + return (((color[0] * 255) << 16) + ((color[1] * 255) << 8) + (color[2] * 255 | 0)); + }, + + set: function (value) + { + var color = this.glcolor; + + color[0] = ((value >> 16) & 0xFF) / 255; + color[1] = ((value >> 8) & 0xFF) / 255; + color[2] = (value & 0xFF) / 255; + } + + }, + + /** + * Returns the amount of extra padding, in pixels, that this filter requires when rendering. + * This accounts for the blur radius extending beyond the original bounds of the + * filtered Game Object. + * + * @method Phaser.Filters.Blur#getPadding + * @since 4.0.0 + * + * @return {Phaser.Geom.Rectangle} The padding Rectangle. + */ + getPadding: function () + { + var override = this.paddingOverride; + if (override) + { + this.currentPadding.setTo(override.x, override.y, override.width, override.height); + return override; + } + + var quality = this.quality; + var offsetConstant = quality === 0 ? 1.333 + : quality === 1 ? 3.2307692308 + : 5.176470588235294; + var offset = this.steps * this.strength * offsetConstant; + var x = Math.ceil(this.x * offset); + var y = Math.ceil(this.y * offset); + + this.currentPadding.setTo(-x, -y, x * 2, y * 2); + + return this.currentPadding; + } +}); + +module.exports = Blur; + + +/***/ }, + +/***/ 47564 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Bokeh Filter Controller. + * + * This filter controller manages the bokeh effect for a Camera. + * + * Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field. + * This effect is used to emphasize the game's main subject or action, by blurring the background or foreground + * elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering + * techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics. + * + * This effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature + * effect by blurring everything except a small area of the image. This effect is achieved by blurring the + * top and bottom elements, while keeping the center area in focus. + * + * This effect samples across an area. To avoid missing data at the edges, + * use `controller.setPaddingOverride(null)` to automatically pad game objects, + * or `camera.getPaddingWrapper(x)` to enlarge a camera. + * + * A Bokeh effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addBokeh(); + * camera.filters.external.addBokeh(); + * ``` + * + * @class Bokeh + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {number} [radius=0.5] - The radius of the bokeh effect. + * @param {number} [amount=1] - The amount of the bokeh effect. + * @param {number} [contrast=0.2] - The color contrast of the bokeh effect. + * @param {boolean} [isTiltShift=false] - Is this a bokeh or Tilt Shift effect? + * @param {number} [blurX=1] - If Tilt Shift, the amount of horizontal blur. + * @param {number} [blurY=1] - If Tilt Shift, the amount of vertical blur. + * @param {number} [strength=1] - If Tilt Shift, the strength of the blur. + * */ +var Bokeh = new Class({ + + Extends: Controller, + + initialize: function Bokeh (camera, radius, amount, contrast, isTiltShift, blurX, blurY, strength) + { + if (radius === undefined) { radius = 0.5; } + if (amount === undefined) { amount = 1; } + if (contrast === undefined) { contrast = 0.2; } + if (isTiltShift === undefined) { isTiltShift = false; } + if (blurX === undefined) { blurX = 1; } + if (blurY === undefined) { blurY = 1; } + if (strength === undefined) { strength = 1; } + + Controller.call(this, camera, 'FilterBokeh'); + + /** + * The radius of the bokeh effect. + * + * This is a float value, where a radius of 0 will result in no effect being applied, + * and a radius of 1 will result in a strong bokeh. However, you can exceed this value + * for even stronger effects. + * + * @name Phaser.Filters.Bokeh#radius + * @type {number} + * @default 0.5 + * @since 4.0.0 + */ + this.radius = radius; + + /** + * The amount of the bokeh effect. This controls how many samples are taken + * during the blur pass. Higher values produce a denser, more pronounced bokeh + * at the cost of additional GPU work. This property applies to the standard + * bokeh effect only; use `strength` to adjust the intensity of a Tilt Shift effect. + * + * @name Phaser.Filters.Bokeh#amount + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.amount = amount; + + /** + * The color contrast of the bokeh effect. This controls how strongly the + * out-of-focus areas differ in luminance from the in-focus areas. Higher values + * increase the brightness contrast between the bokeh highlights and their surroundings, + * making the effect more visually distinct. + * + * @name Phaser.Filters.Bokeh#contrast + * @type {number} + * @default 0.2 + * @since 4.0.0 + */ + this.contrast = contrast; + + /** + * Is this a Tilt Shift effect or a standard bokeh effect? + * + * @name Phaser.Filters.Bokeh#isTiltShift + * @type {boolean} + * @since 4.0.0 + */ + this.isTiltShift = isTiltShift; + + /** + * If a Tilt Shift effect this controls the amount of horizontal blur. + * + * Setting this value on a non-Tilt Shift effect will have no effect. + * + * @name Phaser.Filters.Bokeh#blurX + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.blurX = blurX; + + /** + * If a Tilt Shift effect this controls the amount of vertical blur. + * + * Setting this value on a non-Tilt Shift effect will have no effect. + * + * @name Phaser.Filters.Bokeh#blurY + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.blurY = blurY; + + /** + * If a Tilt Shift effect this controls the strength of the blur. + * + * Setting this value on a non-Tilt Shift effect will have no effect. + * + * @name Phaser.Filters.Bokeh#strength + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.strength = strength; + }, + + /** + * Returns the amount of extra padding, in pixels, that this filter requires when rendering. + * The padding accounts for the bokeh effect extending beyond the original bounds + * of the filtered Camera. + * + * @method Phaser.Filters.Bokeh#getPadding + * @since 4.0.0 + * + * @return {Phaser.Geom.Rectangle} The padding Rectangle. + */ + getPadding: function () + { + var override = this.paddingOverride; + if (override) + { + this.currentPadding.setTo(override.x, override.y, override.width, override.height); + return override; + } + + /* + The padding is calculated based on the camera height and the radius of the bokeh effect. + The constant value is derived from the shader. + The shader samples based on a complicated formula, + but it is based on camera height and radius, + multiplied by various constants including 0.025 and 0.06, + and an iteration which sums to 14.284061040284603 after 100 iterations. + Together, these multiply to the constant 0.021426096060426905. + This is the maximum padding required for the bokeh effect. + */ + + var padding = Math.ceil(this.camera.height * this.radius * 0.021426096060426905); + + this.currentPadding.setTo(-padding, -padding, padding * 2, padding * 2); + + return this.currentPadding; + } +}); + +module.exports = Bokeh; + + +/***/ }, + +/***/ 77011 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var DisplayColorMatrix = __webpack_require__(89422); + +/** + * @classdesc + * The ColorMatrix Filter Controller. + * + * This filter controller manages the color matrix effect for a Camera. + * + * The color matrix effect is a visual technique that involves manipulating the colors of an image + * or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, + * allowing developers to create various stylistic appearances or mood settings within the game. + * Common applications include simulating different lighting conditions, applying color filters, + * or achieving a specific visual style. + * + * A ColorMatrix effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * const cmFilter = camera.filters.internal.addColorMatrix(); + * camera.filters.external.addColorMatrix(); + * + * // To set the matrix values: + * cmFilter.colorMatrix.sepia(); + * ``` + * + * @class ColorMatrix + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + */ +var ColorMatrix = new Class({ + Extends: Controller, + + initialize: function ColorMatrix (camera) + { + Controller.call(this, camera, 'FilterColorMatrix'); + + /** + * The color matrix instance for this effect. Use this to apply + * preset or custom color transformations such as sepia, grayscale, + * saturation, brightness, hue rotation, and more. + * + * @name Phaser.Filters.ColorMatrix#colorMatrix + * @type {Phaser.Display.ColorMatrix} + * @since 4.0.0 + */ + this.colorMatrix = new DisplayColorMatrix(); + }, + + /** + * Destroys this filter, releasing all references and resources. + * + * @method Phaser.Filters.ColorMatrix#destroy + * @since 4.0.0 + */ + destroy: function () + { + this.colorMatrix = null; + + Controller.prototype.destroy.call(this); + } +}); + +module.exports = ColorMatrix; + + +/***/ }, + +/***/ 95200 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var ColorMatrix = __webpack_require__(89422); +var Texture = __webpack_require__(79237); + +/** + * @classdesc + * The CombineColorMatrix Filter controller. + * + * This filter combines color channels from two textures: a base input and a + * secondary transfer texture. Each source is transformed independently by its + * own `ColorMatrix` (`colorMatrixSelf` and `colorMatrixTransfer`), and the + * results are then blended per-channel using configurable addition weights + * (`additions`) and multiplication weights (`multiplications`). This makes it + * suitable for a wide range of compositing effects, though its primary use is + * alpha channel manipulation — for example, using a greyscale transfer texture + * as a soft mask or applying a brightness-derived alpha to the base image. + * Use `setupAlphaTransfer` to configure the matrices and weights for common + * alpha-transfer patterns, or set the `colorMatrixSelf`, `colorMatrixTransfer`, + * `additions`, and `multiplications` properties directly for custom effects. + * + * A CombineColorMatrix filter is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addCombineColorMatrix(); + * camera.filters.external.addCombineColorMatrix(); + * ``` + * + * @class CombineColorMatrix + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {string | Phaser.Textures.Texture} [texture='__WHITE'] - The texture or texture key to use for the transfer texture. + */ +var CombineColorMatrix = new Class({ + Extends: Controller, + + initialize: function CombineColorMatrix (camera, texture) + { + Controller.call(this, camera, 'FilterCombineColorMatrix'); + + /** + * The transfer texture used to provide extra channels. + * + * @name Phaser.Filters.CombineColorMatrix#glTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + */ + this.glTexture; + + /** + * The color matrix which contributes values from the base input. + * + * @name Phaser.Filters.CombineColorMatrix#colorMatrixSelf + * @type {Phaser.Display.ColorMatrix} + * @since 4.0.0 + */ + this.colorMatrixSelf = new ColorMatrix(); + + /** + * The color matrix which contributes values from the transfer texture. + * + * @name Phaser.Filters.CombineColorMatrix#colorMatrixTransfer + * @type {Phaser.Display.ColorMatrix} + * @since 4.0.0 + */ + this.colorMatrixTransfer = new ColorMatrix(); + + /** + * Weight of addition for each channel (R, G, B, A). + * The final output includes values from the self and transfer matrices + * added together; those values are multiplied by this array. + * So values of 1 are kept, while values of 0 are discarded. + * + * By default, RGB values are added together in the final output. + * + * @name Phaser.Filters.CombineColorMatrix#additions + * @type {number[]} + * @since 4.0.0 + * @default [ 1, 1, 1, 0 ] + */ + this.additions = [ 1, 1, 1, 0 ]; + + /** + * Weight of multiplication for each channel (R, G, B, A). + * The final output includes values from the self and transfer matrices + * multiplied together; those values are multiplied by this array. + * So values of 1 are kept, while values of 0 are discarded. + * + * By default, alpha values are multiplied together in the final output. + * + * @name Phaser.Filters.CombineColorMatrix#multiplications + * @type {number[]} + * @since 4.0.0 + * @default [ 0, 0, 0, 1 ] + */ + this.multiplications = [ 0, 0, 0, 1 ]; + + this.setTexture(texture || '__WHITE'); + }, + + /** + * Set the transfer texture. This is used as an extra channel source, + * transferring its data into the filtered image. + * + * @method Phaser.Filters.CombineColorMatrix#setTexture + * @since 4.0.0 + * @param {string | Phaser.Textures.Texture} texture - The texture or texture key to use for the transfer texture. + * + * @return {this} This filter instance. + */ + setTexture: function (texture) + { + var phaserTexture = texture instanceof Texture ? texture : this.camera.scene.sys.textures.getFrame(texture); + + if (phaserTexture) + { + this.glTexture = phaserTexture.glTexture; + } + + return this; + }, + + /** + * Resets both color matrices and the `additions` and `multiplications` + * weighting arrays, then applies a preset configuration for alpha transfer + * — a common use case for this filter. In the preset, RGB channels are + * combined by addition and the alpha channel is combined by multiplication. + * The boolean parameters control which color and brightness-to-alpha + * transformations are applied to each source before blending. + * + * @example + * // Use just the base image, with unified alpha, like Mask. + * myFilter.setupAlphaTransfer(true, false); + * + * @example + * // Use just the transfer image, with unified alpha, + * // where the base alpha is derived from inverted base brightness. + * myFilter.setupAlphaTransfer(false, true, false, false, true); + * + * @method Phaser.Filters.CombineColorMatrix#setupAlphaTransfer + * @since 4.0.0 + * @param {boolean} [colorSelf] - Whether to keep color from the base image. + * @param {boolean} [colorTransfer] - Whether to keep color from the transfer texture. + * @param {boolean} [brightnessToAlphaSelf] - Whether to determine the base alpha from the base brightness. + * @param {boolean} [brightnessToAlphaTransfer] - Whether to determine the transfer alpha from the transfer brightness. + * @param {boolean} [brightnessToAlphaInverseSelf] - Whether to determine the base alpha from the base brightness, inverted. This overrides `brightnessToAlphaSelf`. + * @param {boolean} [brightnessToAlphaInverseTransfer] - Whether to determine the transfer alpha from the transfer brightness, inverted. This overrides `brightnessToAlphaTransfer`. + * + * @return {this} This filter instance. + */ + setupAlphaTransfer: function (colorSelf, colorTransfer, brightnessToAlphaSelf, brightnessToAlphaTransfer, brightnessToAlphaInverseSelf, brightnessToAlphaInverseTransfer) + { + var s = this.colorMatrixSelf; + var t = this.colorMatrixTransfer; + s.reset(); + t.reset(); + + this.additions = [ 1, 1, 1, 0 ]; + this.multiplications = [ 0, 0, 0, 1 ]; + + if (!colorSelf) { s.black(); } + if (!colorTransfer) { t.black(); } + if (brightnessToAlphaInverseSelf) { s.brightnessToAlphaInverse(true); } + else if (brightnessToAlphaSelf) { s.brightnessToAlpha(true); } + if (brightnessToAlphaInverseTransfer) { t.brightnessToAlphaInverse(true); } + else if (brightnessToAlphaTransfer) { t.brightnessToAlpha(true); } + }, + + /** + * Destroys this filter, releasing all references and resources. + * + * @method Phaser.Filters.CombineColorMatrix#destroy + * @since 4.0.0 + */ + destroy: function () + { + this.colorMatrixSelf = null; + this.colorMatrixTransfer = null; + + Controller.prototype.destroy.call(this); + } +}); + +module.exports = CombineColorMatrix; + + +/***/ }, + +/***/ 13045 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Rectangle = __webpack_require__(87841); + +/** + * @classdesc + * The base class for a post-processing filter effect applied to a Camera. + * + * Filters are visual effects rendered on top of a Camera's output, such as blur, glow, or color grading. + * Each filter is managed by a Controller, which holds its configuration and provides padding information to the renderer. + * + * You should not normally create an instance of this class directly, but instead use one of the built-in filters that extend it, + * such as those found in the `Phaser.Filters` namespace. + * + * You should not use a Controller for more than one Camera. + * Create a new instance for each Camera that you wish to apply the filter to. + * If you share Controllers, and destroy one owner, the Controller will be destroyed. + * + * @class Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {string} renderNode - The ID of the RenderNode that this filter uses. + */ +var Controller = new Class({ + initialize: function Controller (camera, renderNode) + { + /** + * Toggle this boolean to enable or disable this filter, + * without removing it from and re-adding it to the Camera's filter list. + * + * @name Phaser.Filters.Controller#active + * @type {boolean} + * @since 4.0.0 + */ + this.active = true; + + /** + * A reference to the Camera that owns this filter. + * + * @name Phaser.Filters.Controller#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 4.0.0 + */ + this.camera = camera; + + /** + * The ID of the RenderNode that this filter uses. + * + * @name Phaser.Filters.Controller#renderNode + * @type {string} + * @since 4.0.0 + */ + this.renderNode = renderNode; + + /** + * Padding override. This is on by default. If this is set, + * the filter will use this padding instead of calculating it. + * Prefer using `setPaddingOverride` instead of modifying this directly. + * + * @name Phaser.Filters.Controller#paddingOverride + * @type {Phaser.Geom.Rectangle} + * @since 4.0.0 + */ + this.paddingOverride = new Rectangle(); + + /** + * The padding currently being used by this filter. + * This is read during rendering via `getPadding`, and may be updated by subclass implementations. + * It is necessary for filters being used in an external list. + * You should not modify this value directly. + * + * @name Phaser.Filters.Controller#currentPadding + * @type {Phaser.Geom.Rectangle} + * @since 4.0.0 + */ + this.currentPadding = new Rectangle(); + + /** + * If `true`, this filter will be permitted to draw to the base texture. + * This can be unwanted if, for example, the filter doesn't actually + * draw anything. + * + * This is an internal flag used by the renderer. + * You should not modify this value directly. + * + * @name Phaser.Filters.Controller#allowBaseDraw + * @type {boolean} + * @since 4.0.0 + * @default true + * @readonly + */ + this.allowBaseDraw = true; + + /** + * Whether this filter controller will be destroyed when the FilterList + * that owns it is destroyed. If you enable this, you must ensure that + * you clean up the filter controller at an appropriate time. + * This allows you to reuse a controller for multiple objects; + * this is not recommended unless you know what you're doing. + * It tends to work best with external filters. + * + * @name Phaser.Filters.Controller#ignoreDestroy + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.ignoreDestroy = false; + }, + + /** + * Returns the raw padding required for this filter. + * This is typically not what you want to call; use `getPaddingCeil` instead. + * Values from this method are not rounded, which can cause quality loss. + * + * Override this method when creating a Filter that requires extra room, + * e.g. a blur or glow effect. + * + * @method Phaser.Filters.Controller#getPadding + * @since 4.0.0 + * @return {Phaser.Geom.Rectangle} The padding required by this filter. + */ + getPadding: function () + { + return this.paddingOverride || this.currentPadding; + }, + + /** + * Returns the rounded padding required for this filter. + * + * Most filters don't need extra padding, + * but some may sample beyond the texture boundaries, such as a blur or glow effect. + * + * The bounds are encoded as a Rectangle. + * To enlarge the bounds, the top and left values should be negative, + * and the bottom and right values should be positive. + * + * This method calls `getPadding()` to get the raw padding values, + * and uses `Math.ceil()` to set the values of `paddingOverride` + * and `currentPadding`. + * + * @method Phaser.Filters.Controller#getPaddingCeil + * @since 4.1.0 + * @returns {Phaser.Geom.Rectangle} The rounded padding required by this filter. + */ + getPaddingCeil: function () + { + var padding = this.getPadding(); + var paddingCeil = new Rectangle( + Math.ceil(padding.x), + Math.ceil(padding.y), + Math.ceil(padding.width), + Math.ceil(padding.height) + ); + this.currentPadding.setTo( + paddingCeil.x, + paddingCeil.y, + paddingCeil.width, + paddingCeil.height + ); + return paddingCeil; + }, + + /** + * Sets the padding override. + * If this is set, the filter will use this padding instead of calculating it. + * Call `setPaddingOverride(null)` to clear the override. + * Call `setPaddingOverride()` to set the padding to 0. + * + * @method Phaser.Filters.Controller#setPaddingOverride + * @since 4.0.0 + * @param {number|null} [left=0] - The left padding. + * @param {number} [top=0] - The top padding. + * @param {number} [right=0] - The right padding. + * @param {number} [bottom=0] - The bottom padding. + */ + setPaddingOverride: function (left, top, right, bottom) + { + if (left === null) + { + this.paddingOverride = null; + return this; + } + + if (left === undefined) { left = 0; } + if (top === undefined) { top = 0; } + if (right === undefined) { right = 0; } + if (bottom === undefined) { bottom = 0; } + + this.paddingOverride = new Rectangle(left, top, right - left, bottom - top); + + return this; + }, + + /** + * Sets the active state of this filter. + * + * A disabled filter will not be used. + * + * @method Phaser.Filters.Controller#setActive + * @since 4.0.0 + * @param {boolean} value - `true` to enable this filter, or `false` to disable it. + * @return {this} This filter instance. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Destroys this Controller and nulls any references it holds. + * + * @method Phaser.Filters.Controller#destroy + * @since 4.0.0 + */ + destroy: function () + { + this.active = false; + this.renderNode = null; + this.camera = null; + } +}); + +module.exports = Controller; + + +/***/ }, + +/***/ 16898 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Displacement Filter Controller. + * + * This Filter controller manages the displacement effect. + * + * The displacement effect is a visual technique that alters the position of pixels in an image + * or texture based on the values of a displacement map. This effect is used to create the illusion + * of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to + * characters, objects, or backgrounds to enhance realism, convey movement, or achieve various + * stylistic appearances. + * + * This effect samples across an area. To avoid missing data at the edges, + * use `controller.setPaddingOverride(null)` to automatically pad game objects, + * or `camera.getPaddingWrapper(x)` to enlarge a camera. + * + * A Displacement effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addDisplacement(); + * camera.filters.external.addDisplacement(); + * ``` + * + * @class Displacement + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {string} [texture='__WHITE'] - The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. + * @param {number} [x=0.005] - The amount of horizontal displacement to apply. A very small float number, such as 0.005. + * @param {number} [y=0.005] - The amount of vertical displacement to apply. A very small float number, such as 0.005. + */ +var Displacement = new Class({ + Extends: Controller, + + initialize: function Displacement (camera, texture, x, y) + { + if (texture === undefined) { texture = '__WHITE'; } + if (x === undefined) { x = 0.005; } + if (y === undefined) { y = 0.005; } + + Controller.call(this, camera, 'FilterDisplacement'); + + /** + * The amount of horizontal displacement to apply. + * The maximum horizontal displacement in pixels is `x` + * multiplied by 0.5 times the width of the camera rendering the filter. + * + * @name Phaser.Filters.Displacement#x + * @type {number} + * @since 4.0.0 + * @default 0.005 + */ + this.x = x; + + /** + * The amount of vertical displacement to apply. + * The maximum vertical displacement in pixels is `y` + * multiplied by 0.5 times the height of the camera rendering the filter. + * + * @name Phaser.Filters.Displacement#y + * @type {number} + * @since 4.0.0 + * @default 0.005 + */ + this.y = y; + + /** + * The underlying texture used for displacement. + * + * @name Phaser.Filters.Displacement#texture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + */ + this.glTexture; + + this.setTexture(texture); + }, + + /** + * Sets the Texture to be used for the displacement effect. + * + * You can only use a whole texture, not a frame from a texture atlas or sprite sheet. + * + * @method Phaser.Filters.Displacement#setTexture + * @since 4.0.0 + * @param {string} [texture='__WHITE'] - The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. + * @return {this} This Filter Controller. + */ + setTexture: function (texture) + { + var phaserTexture = this.camera.scene.sys.textures.getFrame(texture); + + if (phaserTexture) + { + this.glTexture = phaserTexture.glTexture; + } + + return this; + }, + + /** + * Returns the amount of extra padding, in pixels, that this filter requires when rendering. + * The padding accounts for the displacement effect extending beyond the original bounds + * of the Camera's rendered output. + * + * @method Phaser.Filters.Displacement#getPadding + * @since 4.0.0 + * + * @return {Phaser.Geom.Rectangle} The padding Rectangle. + */ + getPadding: function () + { + var override = this.paddingOverride; + if (override) + { + this.currentPadding.setTo(override.x, override.y, override.width, override.height); + return override; + } + + var camera = this.camera; + var x = Math.ceil(camera.width * this.x * 0.5); + var y = Math.ceil(camera.height * this.y * 0.5); + + this.currentPadding.setTo(-x, -y, x * 2, y * 2); + + return this.currentPadding; + } +}); + +module.exports = Displacement; + + +/***/ }, + +/***/ 42652 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Glow Filter controller. + * + * This filter controller manages the glow effect for a Camera. + * + * The glow effect is a visual technique that creates a soft, luminous halo around game objects, + * characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal, + * or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on + * the inside of edges. The color and strength of the glow can be modified. + * + * This effect samples across an area. To avoid missing data at the edges, + * use `controller.setPaddingOverride(null)` to automatically pad game objects, + * or `camera.getPaddingWrapper(x)` to enlarge a camera. + * + * A Glow effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addGlow(); + * camera.filters.external.addGlow(); + * ``` + * + * Conversion note from Phaser 3: + * - The shader now uses stochastic sampling instead of sampling along straight lines. This improves quality, especially around corners. + * - `scale` has been added to the parameter list, before `knockout`. + * - `quality` is no longer a fraction, but an integer value. The default has changed from 0.1 to 10. This is not a linear conversion, because of the quality improvement. Judge the quality by eye and adjust the value accordingly. + * + * @class Glow + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {number} [color=0xffffff] - The color of the glow effect as a number value. + * @param {number} [outerStrength=4] - The strength of the glow outward from the edge of textures. + * @param {number} [innerStrength=0] - The strength of the glow inward from the edge of textures. + * @param {number} [scale=1] - The scale of the glow effect. This multiplies the fixed distance. + * @param {boolean} [knockout=false] - If `true` only the glow is drawn, not the texture itself. + * @param {number} [quality=10] - The quality of the glow effect. This cannot be changed after the filter has been created. + * @param {number} [distance=10] - The distance of the glow effect. This cannot be changed after the filter has been created. + */ +var Glow = new Class({ + Extends: Controller, + + initialize: function Glow (camera, color, outerStrength, innerStrength, scale, knockout, quality, distance) + { + if (outerStrength === undefined) { outerStrength = 4; } + if (innerStrength === undefined) { innerStrength = 0; } + if (scale === undefined) { scale = 1; } + if (knockout === undefined) { knockout = false; } + if (quality === undefined) { quality = camera.scene.sys.game.config.glowQuality; } + if (distance === undefined) { distance = camera.scene.sys.game.config.glowDistance; } + + Controller.call(this, camera, 'FilterGlow'); + + /** + * The strength of the glow outward from the edge of textures. + * + * @name Phaser.Filters.Glow#outerStrength + * @type {number} + * @since 4.0.0 + * @default 4 + */ + this.outerStrength = outerStrength; + + /** + * The strength of the glow inward from the edge of textures. + * + * @name Phaser.Filters.Glow#innerStrength + * @type {number} + * @since 4.0.0 + * @default 0 + */ + this.innerStrength = innerStrength; + + /** + * The scale of the glow effect. This multiplies the fixed distance. + * + * @name Phaser.Filters.Glow#scale + * @type {number} + * @since 4.0.0 + * @default 1 + */ + this.scale = scale; + + /** + * If `true` only the glow is drawn, not the texture itself. + * + * @name Phaser.Filters.Glow#knockout + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.knockout = knockout; + + /** + * The quality of the glow effect. + * This cannot be changed after the filter has been created. + * This controls the number of samples that the glow effect will run for. + * A higher number is higher quality, but slower to process. + * Integer values only. + * + * @name Phaser.Filters.Glow#quality + * @type {number} + * @since 4.0.0 + * @default 10 + * @private + * @readonly + */ + this._quality = Math.max(Math.round(quality), 1); + + /** + * The distance of the glow effect. + * This cannot be changed after the filter has been created. + * This controls the distance of the glow effect, in pixels. + * Integer values only. + * + * @name Phaser.Filters.Glow#distance + * @type {number} + * @since 4.0.0 + * @default 10 + * @private + * @readonly + */ + this._distance = Math.max(Math.round(distance), 1); + + /** + * The internal RGBA color of the glow, stored as four normalized + * floating-point values (red, green, blue, alpha) in the range 0 to 1, + * for direct use by the WebGL renderer. To set the glow color, use the + * `color` property instead. + * + * @name Phaser.Filters.Glow#glcolor + * @type {number[]} + * @since 4.0.0 + */ + this.glcolor = [ 1, 1, 1, 1 ]; + + if (color !== undefined) + { + this.color = color; + } + }, + + /** + * The color of the glow effect, expressed as a hex color value in the + * format 0xRRGGBB. Getting this value converts it from the internal + * normalized `glcolor` array. Setting it updates `glcolor` for use by + * the WebGL renderer. + * + * @name Phaser.Filters.Glow#color + * @type {number} + * @since 4.0.0 + */ + color: { + + get: function () + { + var color = this.glcolor; + + return (((color[0] * 255) << 16) + ((color[1] * 255) << 8) + (color[2] * 255 | 0)); + }, + + set: function (value) + { + var color = this.glcolor; + + color[0] = ((value >> 16) & 0xFF) / 255; + color[1] = ((value >> 8) & 0xFF) / 255; + color[2] = (value & 0xFF) / 255; + } + + }, + + /** + * The distance of the glow effect. + * This cannot be changed after the filter has been created. + * This controls the distance of the glow effect, in pixels. + * Integer values only. + * + * @name Phaser.Filters.Glow#distance + * @type {number} + * @since 4.0.0 + * @readonly + */ + distance: { + + get: function () + { + return this._distance; + } + + }, + + /** + * The quality of the glow effect. + * This cannot be changed after the filter has been created. + * This controls the number of samples that the glow effect will run for. + * A higher number is higher quality, but slower to process. + * Integer values only. + * + * @name Phaser.Filters.Glow#quality + * @type {number} + * @since 4.0.0 + * @readonly + */ + quality: { + + get: function () + { + return this._quality; + } + }, + + /** + * Returns the amount of extra padding, in pixels, that this filter requires when rendering. + * The padding accounts for the glow effect extending beyond the original bounds + * of the Camera's rendered output. + * + * @method Phaser.Filters.Glow#getPadding + * @since 4.0.0 + * + * @return {Phaser.Geom.Rectangle} The padding Rectangle. + */ + getPadding: function () + { + var override = this.paddingOverride; + if (override) + { + this.currentPadding.setTo(override.x, override.y, override.width, override.height); + return override; + } + + var padding = this.currentPadding; + var distance = Math.ceil(this.distance * this.scale); + + padding.left = -distance; + padding.top = -distance; + padding.right = distance; + padding.bottom = distance; + + return padding; + } +}); + +module.exports = Glow; + + +/***/ }, + +/***/ 43927 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var ColorRamp = __webpack_require__(73043); + +/** + * @classdesc + * The GradientMap Filter Controller. + * + * This controller manages the GradientMap effect for a Camera. + * + * GradientMap recolors an image using a ColorRamp. + * The image is converted to a progress value at each point, + * and that progress is evaluated as a color along the ramp. + * + * The progress value is normally the brightness of the image. + * You can use the `colorFactor` and `color` properties to customize it. + * + * @example + * const camera = this.cameras.main; + * camera.filters.internal.addGradientMap(); // Basic effect. + * camera.filters.external.addGradientMap({ + * colorFactor: [ -0.3, -0.6, -0.1, 0 ], + * color: [ 0.3, 0.6, 0.1, 0 ] + * }); // Invert brightness. + * + * @class GradientMap + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {Phaser.Types.Filters.GradientMapConfig} [config] - The configuration object for the GradientMap effect. + */ +var GradientMap = new Class({ + Extends: Controller, + + initialize: function GradientMap (camera, config) + { + if (!config) { config = {}; } + + var scene = camera.scene; + + Controller.call(this, camera, 'FilterGradientMap'); + + var ramp = config.ramp; + if (!ramp) + { + ramp = { colorStart: 0x000000, colorEnd: 0xffffff }; + } + if (!(ramp instanceof ColorRamp)) + { + // Ramp is a config. Construct it. + ramp = new ColorRamp(scene, ramp, true); + } + + /** + * The ColorRamp used to recolor the image. Each pixel's brightness + * (or custom progress value derived from `colorFactor` and `color`) + * is looked up along this ramp to determine its output color. + * + * @name Phaser.Filters.GradientMap#ramp + * @type {Phaser.Display.ColorRamp} + * @since 4.0.0 + */ + this.ramp = ramp; + + /** + * Whether to use Interleaved Gradient Noise to dither the ramp. + * This can reduce banding, but the effect is easily lost if the image + * is later transformed. + * + * @name Phaser.Filters.GradientMap#dither + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.dither = !!config.dither; + + /** + * RGBA offset values added directly to the ramp progress after `colorFactor` + * has been applied. Each element corresponds to a channel: red, green, blue, + * and alpha. For example, setting a channel to `1` when its corresponding + * `colorFactor` entry is `-1` effectively inverts that channel's contribution + * to the progress value. + * + * @name Phaser.Filters.GradientMap#color + * @type {number[]} + * @since 4.0.0 + * @default [ 0, 0, 0, 0 ] + */ + this.color = [ 0, 0, 0, 0 ]; + if (config.color) + { + this.color[0] = config.color[0] || 0; + this.color[1] = config.color[1] || 0; + this.color[2] = config.color[2] || 0; + this.color[3] = config.color[3] || 0; + } + + /** + * RGBA multipliers applied to each channel of the source image to compute + * the ramp progress value. The results are summed together. The defaults + * `[ 0.3, 0.6, 0.1, 0 ]` approximate standard luminance weights, producing + * a perceptually accurate grayscale progress. Keep the sum of factors equal + * to 1 for a normalized result, or use negative values (paired with `color` + * offsets) to invert a channel's contribution. + * + * @name Phaser.Filters.GradientMap#colorFactor + * @type {number[]} + * @since 4.0.0 + * @default [ 0.3, 0.6, 0.1, 0 ] + */ + this.colorFactor = [ 0.3, 0.6, 0.1, 0 ]; + if (config.colorFactor) + { + this.colorFactor[0] = config.colorFactor[0] || 0; + this.colorFactor[1] = config.colorFactor[1] || 0; + this.colorFactor[2] = config.colorFactor[2] || 0; + this.colorFactor[3] = config.colorFactor[3] || 0; + } + + /** + * Whether the input should be unpremultiplied before computing progress. + * This means that transparent colors are considered at full brightness. + * It is usually desirable. + * + * @name Phaser.Filters.GradientMap#unpremultiply + * @type {boolean} + * @since 4.0.0 + * @default true + */ + this.unpremultiply = config.unpremultiply === undefined ? true : config.unpremultiply; + + /** + * The blend strength of the gradient map effect over the original image, + * in the range 0 (no effect, original image fully visible) to 1 (full + * gradient map effect, original image fully replaced). + * + * @name Phaser.Filters.GradientMap#alpha + * @type {number} + * @since 4.0.0 + * @default 1 + */ + this.alpha = config.alpha === undefined ? 1 : config.alpha; + } +}); + +module.exports = GradientMap; + + +/***/ }, + +/***/ 84714 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var Matrix4 = __webpack_require__(37867); +var TransformMatrix = __webpack_require__(61340); +var Texture = __webpack_require__(79237); + +/** + * @classdesc + * The ImageLight Filter Controller. + * + * This filter controller manages the ImageLight effect for a Camera. + * + * ImageLight is a filter for image based lighting (IBL). + * It is used to simulate the lighting of an image + * using an environment map and a normal map. + * + * The environment map is an image that describes the lighting of the scene. + * This filter uses a single panorama image as the environment map. + * The top of the image is the sky, the bottom is the ground, + * and the X axis covers a full rotation. + * This kind of image is distorted towards the top and bottom, + * as the X axis is stretched wider and wider, + * so be careful if you're creating your own environment maps. + * + * Cube maps are not supported by Phaser at the time of writing. + * + * The effect is basically a reflection of the environment at infinite range. + * A sharp environment map will produce a sharp reflection, + * while a blurry environment map will produce a diffuse reflection. + * Use the PanoramaBlur filter to create correctly blurred environment maps. + * Use the NormalTools filter to manipulate the normal map if necessary, + * using a DynamicTexture to capture the output. + * + * An ImageLight effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addImageLight({ texture: 'lightmap' }); + * camera.filters.external.addImageLight({ texture: 'lightmap' }); + * ``` + * + * @class ImageLight + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {Phaser.Types.Filters.ImageLightConfig} [config] - The configuration object for the ImageLight effect. + */ +var ImageLight = new Class({ + Extends: Controller, + + initialize: function ImageLight (camera, config) + { + Controller.call(this, camera, 'FilterImageLight'); + + /** + * The underlying texture used for the ImageLight effect normal map. + * + * @name Phaser.Filters.ImageLight#normalGlTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + */ + this.normalGlTexture; + + /** + * The underlying texture used for the ImageLight effect environment map. + * + * @name Phaser.Filters.ImageLight#environmentGlTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + */ + this.environmentGlTexture; + + /** + * The view matrix used for the ImageLight effect. + * This controls the orientation of the environment map. + * You should set this to reflect the perspective of the camera. + * + * @name Phaser.Filters.ImageLight#viewMatrix + * @type {Phaser.Math.Matrix4} + * @since 4.0.0 + */ + this.viewMatrix = new Matrix4(); + + /** + * The initial rotation of the model in radians. + * This will be overridden by the modelRotationSource if it is set. + * + * @name Phaser.Filters.ImageLight#modelRotation + * @type {number} + * @since 4.0.0 + */ + this.modelRotation = config.modelRotation || 0; + + /** + * The source of the model rotation, used when the filter renders. + * If a function, it will be called to get the rotation. + * If a GameObject, it will be used to get the rotation from the GameObject's world transform. + * If null, the model rotation will be taken from the modelRotation property. + * + * @name Phaser.Filters.ImageLight#modelRotationSource + * @type {Phaser.GameObjects.GameObject | Phaser.Types.Filters.ImageLightSourceCallback | null} + * @since 4.0.0 + */ + this.modelRotationSource = config.modelRotationSource || null; + + /** + * The amount of bulge to apply to the ImageLight effect. + * This distorts the surface slightly, preventing flat areas in the normal map from reflecting a single flat color. + * A value of 0.1 is often plenty. + * + * @name Phaser.Filters.ImageLight#bulge + * @type {number} + * @since 4.0.0 + */ + this.bulge = config.bulge || 0; + + /** + * The color factor to apply to the ImageLight effect. This multiplies the intensity of the light in each color channel. Use values above 1 to substitute for high dynamic range lighting. + * + * @name Phaser.Filters.ImageLight#colorFactor + * @type {number[]} + * @since 4.0.0 + */ + this.colorFactor = config.colorFactor || [ 1, 1, 1 ]; + + /** + * A temporary matrix used for the ImageLight effect. + * + * @name Phaser.Filters.ImageLight#_tempMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 4.0.0 + * @private + */ + this._tempMatrix = new TransformMatrix(); + + /** + * A temporary parent matrix used for the ImageLight effect. + * + * @name Phaser.Filters.ImageLight#_tempParentMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 4.0.0 + * @private + */ + this._tempParentMatrix = new TransformMatrix(); + + this.setEnvironmentMap(config.environmentMap || '__WHITE'); + this.setNormalMap(config.normalMap || '__NORMAL'); + if (config.viewMatrix) + { + this.viewMatrix.set(config.viewMatrix); + } + }, + + /** + * Sets the texture to use for the ImageLight effect environment map. + * + * @method Phaser.Filters.ImageLight#setEnvironmentMap + * @since 4.0.0 + * @param {string|Phaser.Textures.Texture} texture - The texture to use for the ImageLight effect environment map. + * @return {this} This ImageLight instance. + */ + setEnvironmentMap: function (texture) + { + var phaserTexture = texture instanceof Texture ? texture : this.camera.scene.sys.textures.getFrame(texture); + + if (phaserTexture) + { + this.environmentGlTexture = phaserTexture.glTexture; + } + + return this; + }, + + /** + * Sets the texture to use for the ImageLight effect normal map. + * This should match the object being filtered. + * + * @method Phaser.Filters.ImageLight#setNormalMap + * @since 4.0.0 + * @param {string|Phaser.Textures.Texture} texture - The texture to use for the ImageLight effect normal map. + * @return {this} This ImageLight instance. + */ + setNormalMap: function (texture) + { + var phaserTexture = texture instanceof Texture ? texture : this.camera.scene.sys.textures.getFrame(texture); + + if (phaserTexture) + { + this.normalGlTexture = phaserTexture.glTexture; + } + + return this; + }, + + /** + * Sets the normal texture to use for the ImageLight effect from a GameObject. + * This will use the first data source image in the object's texture. + * Use this to extract a normal map which was loaded as a data source. + * + * @method Phaser.Filters.ImageLight#setNormalMapFromGameObject + * @since 4.0.0 + * @param {Phaser.GameObjects.GameObject} gameObject - The GameObject to use for the ImageLight effect normal map. + * @return {this} This ImageLight instance. + */ + setNormalMapFromGameObject: function (gameObject) + { + var texture = gameObject.texture; + var normalDataSource = texture.dataSource[0]; + if (normalDataSource) + { + this.normalGlTexture = normalDataSource.glTexture; + } + + return this; + }, + + /** + * Gets the rotation to use for the ImageLight effect. + * This will use the modelRotationSource if it is set. + * + * @method Phaser.Filters.ImageLight#getModelRotation + * @since 4.0.0 + * @return {number} The rotation to use for the ImageLight effect in radians. + */ + getModelRotation: function () + { + if (!this.modelRotationSource) + { + return this.modelRotation; + } + + if (typeof this.modelRotationSource === 'function') + { + return this.modelRotationSource(); + } + + if (this.modelRotationSource.hasTransformComponent) + { + return this.modelRotationSource.getWorldTransformMatrix(this._tempMatrix, this._tempParentMatrix).rotationNormalized; + } + + // This should never happen. + return this.modelRotation; + } +}); + +module.exports = ImageLight; + + +/***/ }, + +/***/ 51890 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var Color = __webpack_require__(40987); + +/** + * @classdesc + * The Key filter controller. + * + * The Key effect removes or isolates a specific color from an image. + * It can be used to remove a background color from an image, + * or to isolate a specific color for further processing. + * + * By default, Key will remove pixels that match the key color. + * You can instead keep only the matching pixels by setting `isolate`. + * + * The threshold and feather settings control how closely the key color matches. + * A match is measured by "distance between color vectors"; + * that is, how close the RGB values of the pixel are to the RGB values of the key color. + * + * A Key filter is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addKey({ color: '#ff00ff' }); + * camera.filters.external.addKey({ color: 0x00ff00 }); + * ``` + * + * @class Key + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {Phaser.Types.Filters.KeyConfig} [config={}] - The configuration for the filter. + */ +var Key = new Class({ + Extends: Controller, + initialize: function Key (camera, config) + { + if (config === undefined) { config = {}; } + + Controller.call(this, camera, 'FilterKey'); + + /** + * The color to use for the key. + * It is an array of 4 numbers between 0 and 1, representing the RGBA values. + * + * @name Phaser.Filters.Key#color + * @type {number[]} + * @since 4.0.0 + * @default [ 1, 1, 1, 1 ] + */ + this.color = [ 1, 1, 1, 1 ]; + if (config.color !== undefined) { this.setColor(config.color); } + if (config.alpha !== undefined) { this.setAlpha(config.alpha); } + + /** + * Whether to keep the region matching the key color. + * If true, the region matching the key color will be kept, + * and the rest will be removed. + * If false, the region matching the key color will be removed, + * and the rest will be kept. + * + * @name Phaser.Filters.Key#isolate + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.isolate = false; + if (config.isolate !== undefined) { this.isolate = config.isolate; } + + /** + * The threshold for the key color. + * A pixel is considered to be the key color if the difference between + * the pixel and the key color is less than the threshold. + * This should be between 0 and 1. + * The default threshold is 1 / 16, which is a good starting point for most images. + * + * @name Phaser.Filters.Key#threshold + * @type {number} + * @since 4.0.0 + * @default 0.0625 + */ + this.threshold = 0.0625; + if (config.threshold !== undefined) { this.threshold = config.threshold; } + + /** + * The feathering amount for the key color. + * Pixels outside the threshold, but still within the feather, + * will be a partial match. + * This should be a value between 0 and 1. + * + * @name Phaser.Filters.Key#feather + * @type {number} + * @since 4.0.0 + * @default 0 + */ + this.feather = 0; + if (config.feather !== undefined) { this.feather = config.feather; } + }, + + /** + * Sets the alpha value to use for the key. + * Alpha controls the opacity of pixels matched by the key color, in the range 0 to 1. + * This is stored in the fourth element of the color array. + * The RGB color values are preserved. + * + * @method Phaser.Filters.Key#setAlpha + * @since 4.0.0 + * @param {number} alpha - The alpha value to set on the key texture, between 0 (fully transparent) and 1 (fully opaque). + * @return {this} This Filter Controller. + */ + setAlpha: function (alpha) + { + this.color[3] = alpha; + return this; + }, + + /** + * Sets the color to use for the key. + * This is stored in the first three elements of the color array. + * The alpha value is preserved. + * + * @method Phaser.Filters.Key#setColor + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} color - The color to use for the key. It can be a hexcode number or string, an array of 3 numbers between 0 and 1, or a Color object. + * @return {this} This Filter Controller. + */ + setColor: function (color) + { + var alpha = this.color[3]; + if (typeof color === 'number') + { + var rgb = Color.IntegerToRGB(color); + this.color = [ rgb.r / 255, rgb.g / 255, rgb.b / 255, alpha ]; + } + else if (typeof color === 'string') + { + var colorObject = Color.HexStringToColor(color); + this.color = [ colorObject.redGL, colorObject.greenGL, colorObject.blueGL, alpha ]; + } + else if (Array.isArray(color)) + { + this.color = [ color[0], color[1], color[2], alpha ]; + } + else if (color instanceof Color) + { + this.color = [ color.redGL, color.greenGL, color.blueGL, alpha ]; + } + + return this; + } +}); + +module.exports = Key; + + +/***/ }, + +/***/ 97797 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var UUID = __webpack_require__(45650); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Mask Filter Controller. + * + * This filter controller manages a mask effect. + * + * A mask uses a texture to hide parts of an input. + * It multiplies the color and alpha of the input + * by the alpha of the mask in the corresponding texel. + * + * Masks can be inverted, which switches what they hide and what they show. + * + * Masks can use either a texture or a GameObject. + * If a GameObject is used, the mask will render the GameObject + * to a DynamicTexture and use that. + * The mask will automatically update when the GameObject changes, + * unless the `autoUpdate` flag is set to `false`. + * + * When the mask filter is used as an internal filter, + * the mask will match the object/view being filtered. + * This is useful for creating effects that follow the object, + * such as effects intended to match an animated sprite. + * + * When the mask filter is used as an external filter, + * the mask will match the context of the camera. + * This is useful for creating effects that cover the entire view. + * + * An optional `viewCamera` can be specified when creating the mask. + * If not used, mask objects will be viewed through the current camera, + * or through a default camera if no other option is set. + * For example, when rendering to a DynamicTexture outside the normal rendering + * flow. + * + * A Mask effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * const texture = 'MyMask'; + * + * camera.filters.internal.addMask(texture); + * camera.filters.external.addMask(texture, true, myCamera); + * ``` + * + * @class Mask + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {string|Phaser.GameObjects.GameObject} [mask='__WHITE'] - The source of the mask. This can be a unique string-based key of the texture to use for the mask, which must exist in the Texture Manager. Or it can be a GameObject, in which case the mask will render the GameObject to a DynamicTexture and use that. + * @param {boolean} [invert=false] - Whether to invert the mask. + * @param {Phaser.Cameras.Scene2D.Camera} [viewCamera] - The Camera to use when rendering the mask with a GameObject. If not specified, uses the scene's `main` camera. + * @param {'local'|'world'} [viewTransform='world'] - The transform to use when rendering the mask with a GameObject. 'local' uses the GameObject's own properties. 'world' uses the GameObject's `parentContainer` value to compute a world position. + * @param {number} [scaleFactor=1] - The scale factor to apply to the underlying mask texture. Can be used to balance memory usage and needed mask precision. This just adjusts the size of the texture; you must also adjust mask size to match, e.g. if scaleFactor is 0.5, your mask might be a Container with scale 0.5. It's easy to make things complicated when combining scale factor, object transform, and camera transform, so try to be precise when using this option. + */ +var Mask = new Class({ + Extends: Controller, + + initialize: function Mask (camera, mask, invert, viewCamera, viewTransform, scaleFactor) + { + if (mask === undefined) { mask = '__WHITE'; } + if (invert === undefined) { invert = false; } + if (scaleFactor === undefined) { scaleFactor = 1; } + + Controller.call(this, camera, 'FilterMask'); + + /** + * The underlying texture used for the mask. + * + * @name Phaser.Filters.Mask#glTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + */ + this.glTexture; + + /** + * The dynamic texture used for the mask. + * This is only set if the mask is a GameObject. + * + * @name Phaser.Filters.Mask#_dynamicTexture + * @type {Phaser.Textures.DynamicTexture} + * @private + * @since 4.0.0 + * @default null + */ + this._dynamicTexture = null; + + /** + * The GameObject used for the mask. + * This is only set if the mask is a GameObject. + * + * @name Phaser.Filters.Mask#maskGameObject + * @type {Phaser.GameObjects.GameObject} + * @since 4.0.0 + * @default null + */ + this.maskGameObject = null; + + /** + * Whether to invert the mask. + * An inverted mask switches what it hides and what it shows. + * + * @name Phaser.Filters.Mask#invert + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.invert = invert; + + /** + * Whether the mask should automatically update. + * This only applies when the mask is a GameObject. + * If `false`, the mask will not change even if the GameObject changes. + * + * @name Phaser.Filters.Mask#autoUpdate + * @type {boolean} + * @since 4.0.0 + * @default true + */ + this.autoUpdate = true; + + /** + * Whether the mask needs updating, once. + * This only applies when the mask is a GameObject. + * If `true`, the mask will be updated before the next render. + * This is automatically set to `true` when the mask is a GameObject, + * but it turns off after the mask is updated. + * + * @name Phaser.Filters.Mask#needsUpdate + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.needsUpdate = false; + + /** + * The transform type to use when rendering the mask with a GameObject. + * 'local' uses the GameObject's own properties. + * 'world' uses the GameObject's `parentContainer` value to compute a world position. + * This only applies when the mask is a GameObject. + * + * @name Phaser.Filters.Mask#viewTransform + * @type {'local'|'world'} + * @since 4.0.0 + * @default 'world' + */ + this.viewTransform = viewTransform || 'world'; + + /** + * The Camera to use when rendering the mask. + * If not specified, uses the currently rendering camera, + * or failing that, an internal Camera. + * + * @name Phaser.Filters.Mask#viewCamera + * @type {?Phaser.Cameras.Scene2D.Camera} + * @since 4.0.0 + */ + this.viewCamera = viewCamera; + + /** + * The scale factor to apply to the underlying mask texture. + * A value less than 1 reduces the texture resolution to save memory + * at the cost of mask precision. A value greater than 1 increases + * resolution for sharper masking but uses more memory. When changing + * this value, you must also scale the mask GameObject or Container + * to match, so that its rendered output fills the texture correctly. + * + * @name Phaser.Filters.Mask#scaleFactor + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.scaleFactor = scaleFactor; + + if (typeof mask === 'string') + { + this.setTexture(mask); + } + else + { + this.setGameObject(mask); + } + }, + + /** + * Updates the DynamicTexture for the mask. + * The DynamicTexture is created or resized if necessary. + * This is called automatically during rendering + * when the mask is a GameObject + * and the `needsUpdate` or `autoUpdate` flags are set. + * It should not be called directly. + * + * @method Phaser.Filters.Mask#updateDynamicTexture + * @since 4.0.0 + * @param {number} width - The width of the DynamicTexture. + * @param {number} height - The height of the DynamicTexture. + */ + updateDynamicTexture: function (width, height) + { + var scaleFactor = this.scaleFactor; + var scaledWidth = width * scaleFactor; + var scaledHeight = height * scaleFactor; + + var gameObject = this.maskGameObject; + + if (!gameObject) + { + return; + } + + if (!this._dynamicTexture) + { + var textureManager = this.camera.scene.sys.textures; + this._dynamicTexture = textureManager.addDynamicTexture(UUID(), scaledWidth, scaledHeight, false); + } + else if (this._dynamicTexture.width !== scaledWidth || this._dynamicTexture.height !== scaledHeight) + { + this._dynamicTexture.setSize(scaledWidth, scaledHeight, false); + } + else + { + this._dynamicTexture.clear(); + } + + this.glTexture = this._dynamicTexture.get().glTexture; + + var camera = this.viewCamera || gameObject.scene.renderer.currentViewCamera; + + // Draw the GameObject to the DynamicTexture. + this._dynamicTexture.capture(gameObject, { transform: this.viewTransform, camera: camera }); + this._dynamicTexture.render(); + + this.needsUpdate = false; + }, + + /** + * Sets the GameObject used for the mask. The GameObject will be rendered + * to an internal DynamicTexture on the next render pass. Setting a new + * GameObject also sets `needsUpdate` to `true`, ensuring the texture is + * refreshed before the next frame is drawn. + * + * @method Phaser.Filters.Mask#setGameObject + * @since 4.0.0 + * @param {Phaser.GameObjects.GameObject} gameObject - The GameObject to use for the mask. + * @return {this} This Filter Controller. + */ + setGameObject: function (gameObject) + { + this.maskGameObject = gameObject; + this.needsUpdate = true; + + // `_dynamicTexture` will be generated at render time, + // using the camera of the current context. + // The camera which owns this filter is only the correct camera + // if this filter is being used as an internal filter. + + return this; + }, + + /** + * Sets a static texture to use as the mask, looked up by key from the + * Texture Manager. Any previously assigned mask GameObject is cleared. + * Unlike a GameObject mask, a static texture mask does not update + * automatically between frames. + * + * @method Phaser.Filters.Mask#setTexture + * @since 4.0.0 + * @param {string} [texture='__WHITE'] - The unique string-based key of the texture to use for the mask, which must exist in the Texture Manager. + * @return {this} This Filter Controller. + */ + setTexture: function (texture) + { + var phaserTexture = this.camera.scene.sys.textures.getFrame(texture); + + if (phaserTexture) + { + this.maskGameObject = null; + this.glTexture = phaserTexture.glTexture; + } + + return this; + }, + + /** + * Destroys this filter, releasing all references and resources. + * + * If a dynamic texture was created for a mask GameObject, + * it will also be destroyed. + * + * @method Phaser.Filters.Mask#destroy + * @since 4.0.0 + */ + destroy: function () + { + if (this._dynamicTexture) + { + this._dynamicTexture.destroy(); + } + + this.maskGameObject = null; + this._dynamicTexture = null; + + Controller.prototype.destroy.call(this); + } +}); + +module.exports = Mask; + + +/***/ }, + +/***/ 37911 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var Matrix4 = __webpack_require__(37867); +var Vector3 = __webpack_require__(25836); + +/** + * @classdesc + * The NormalTools Filter Controller. + * + * This filter controller manages the NormalTools effect for a Camera. + * + * NormalTools is a filter for manipulating the normals of a normal map. + * It has several functions: + * + * - Rotate or reorient the normal map. + * - Change how strongly the normals face the camera. + * - Output a grayscale texture showing how strongly the normals face the camera, or some other vector. + * + * The output can be used for various purposes, such as: + * + * - Editing a normal map for special applications. + * - Altering the apparent visual depth of a normal map by manipulating the facing power. + * - Creating a base for other effects, such as a mask for a gradient or other effect. + * + * You can even use the output as a normal map for regular lighting. + * Ordinarily, normal maps are loaded alongside the main texture, + * but you can override this. + * + * ```js + * // Given a dynamic texture `dyn` where the filter output is drawn, + * // and a texture `spiderTex` with lighting enabled, + * // we can inject the WebGL texture straight into the scene lighting as a normal map. + * spiderTex.setDataSource(dyn.getWebGLTexture()); + * ``` + * + * A NormalTools effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addNormalTools({ + * rotation: 0, + * facingPower: 1, + * outputRatio: false, + * ratioVector: [ 0, 0, 1 ], + * ratioRadius: 1 + * }); + * camera.filters.external.addNormalTools({}); + * ``` + * + * @class NormalTools + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {Phaser.Types.Filters.NormalToolsConfig} [config] - The configuration object for the NormalTools effect. + */ +var NormalTools = new Class({ + Extends: Controller, + + initialize: function NormalTools (camera, config) + { + config = config || {}; + + Controller.call(this, camera, 'FilterNormalTools'); + + /** + * A private record of the last rotation set by `setRotation` + * or updated by `updateRotation`. + * This may be different from the `viewMatrix` rotation + * if the `viewMatrix` is manipulated directly. + * + * @name Phaser.Filters.NormalTools#_rotation + * @type {number} + * @since 4.0.0 + * @default 0 + * @private + */ + this._rotation = 0; + + /** + * The view matrix used for the NormalTools effect. + * This controls the orientation of the normal map. + * Use this to control 3D rotation of the normal map. + * Ordinarily, you would just use `setRotation` for 2D rotation. + * + * @name Phaser.Filters.NormalTools#viewMatrix + * @type {Phaser.Math.Matrix4} + * @since 4.0.0 + */ + this.viewMatrix = new Matrix4(); + + this.setRotation(config.rotation || 0); + + /** + * The source of the rotation. + * If a function, it will be called to get the rotation. + * If a GameObject, it will be used to get the rotation from the GameObject's world transform. + * If null, the rotation will not be updated by the filter. + * + * @name Phaser.Filters.NormalTools#rotationSource + * @type {Phaser.GameObjects.GameObject | Phaser.Types.Filters.NormalToolsSourceCallback | null} + * @since 4.0.0 + */ + this.rotationSource = config.rotationSource || null; + + /** + * The power of the facing effect. + * Higher values bend normals toward the camera; lower values bend them away. + * This can be useful for suggesting depth in a 2D scene. + * + * @name Phaser.Filters.NormalTools#facingPower + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.facingPower = config.facingPower || 1; + + /** + * Whether to output the ratio of the normal map. + * If true, the output will be a grayscale texture, with the white area + * being the areas where the normals are facing the camera, + * fading to black when they're orthogonal. + * You can manipulate this ratio with `ratioVector` and `ratioRadius`. + * This can be useful as a base for other effects. + * + * @name Phaser.Filters.NormalTools#outputRatio + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.outputRatio = config.outputRatio || false; + + /** + * The vector to use for the ratio output. + * This is the direction in which the ratio will be calculated. + * The default is the camera's forward direction. + * Manipulate this to highlight parts of the map which are facing in a specific direction. + * + * This is only used if outputRatio is true. + * + * @name Phaser.Filters.NormalTools#ratioVector + * @type {Phaser.Math.Vector3} + * @since 4.0.0 + */ + this.ratioVector = new Vector3(0, 0, 1); + if (config.ratioVector) + { + this.ratioVector.set(config.ratioVector[0], config.ratioVector[1], config.ratioVector[2]); + } + + /** + * How much of a hemisphere to consider for the ratio output. + * At 1, the ratio will be calculated for the entire hemisphere. + * At 0, the ratio will be calculated for a single point. + * This uses the same algorithm as `PanoramaBlur.radius`. + * + * This is only used if outputRatio is true. + * + * @name Phaser.Filters.NormalTools#ratioRadius + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.ratioRadius = config.ratioRadius || 1; + }, + + /** + * Gets the 2D rotation of the normal map, + * as set by `setRotation` or the `rotationSource`. + * + * This value is not accurate if the `viewMatrix` is manipulated directly, + * e.g. for 3D rotation. There is no single value which can + * accurately represent 3D rotation. + * + * @method Phaser.Filters.NormalTools#getRotation + * @since 4.0.0 + * @return {number} The rotation in radians. + */ + getRotation: function () + { + if (this.rotationSource) + { + if (typeof this.rotationSource === 'function') + { + return this.rotationSource(); + } + + if (this.rotationSource.hasTransformComponent) + { + return this.rotationSource.getWorldTransformMatrix().rotationNormalized; + } + } + + return this._rotation; + }, + + /** + * Sets the rotation of the normal map. + * This sets the `viewMatrix` to a rotation around the Z axis, + * suitable for 2D rotation. + * For more advanced controls, manipulate the filter's `viewMatrix` to control 3D rotation. + * + * @method Phaser.Filters.NormalTools#setRotation + * @since 4.0.0 + * @param {number} rotation - The rotation in radians. + * @return {this} This NormalTools instance. + */ + setRotation: function (rotation) + { + this.viewMatrix.identity().rotateZ(rotation); + this._rotation = rotation; + + return this; + }, + + /** + * Updates the rotation of the normal map from the rotationSource, + * if it is set. This is called automatically during rendering. + * + * @method Phaser.Filters.NormalTools#updateRotation + * @since 4.0.0 + * @return {this} This NormalTools instance. + */ + updateRotation: function () + { + if (this.rotationSource) + { + var rotation = this.getRotation(); + this.viewMatrix.identity().rotateZ(rotation); + this._rotation = rotation; + } + + return this; + } +}); + +module.exports = NormalTools; + + +/***/ }, + +/***/ 6379 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The PanoramaBlur Filter Controller. + * + * This filter controller manages the PanoramaBlur effect for a Camera. + * + * PanoramaBlur is a filter for blurring a panorama image. + * This is intended for use with filters like ImageLight that use a panorama image as the environment map. + * The blur treats a rectangular map as a sphere, + * and applies heavy distortion close to the poles to get a correct result. + * You should not use it for general purpose blurring. + * + * The effect can be very slow, as it uses a grid of samples. + * Total samples equals samplesX * samplesY. This can get very high, + * very quickly, so be careful when increasing these values. + * They don't need to be too high for good results. + * + * By default, the blur is fully diffuse, sampling an entire hemisphere per point. + * If you reduce the radius, the effect will be more focused. + * Use this to control different levels of glossiness in objects using environment maps. + * + * A PanoramaBlur effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addPanoramaBlur({}); + * camera.filters.external.addPanoramaBlur({}); + * ``` + * + * @example + * // Cache a panorama image in a scene. + * // Assume there is a panorama texture called 'panorama'. + * var panorama = this.add.image(0, 0, 'panorama'); + * panorama.setPosition(panorama.width / 2, panorama.height / 2); + * panorama.enableFilters().filters.internal.addPanoramaBlur({}); + * + * var panoramaBlurred = this.textures.addDynamicTexture('panorama-blurred', panorama.width, panorama.height); + * panoramaBlurred.draw(panorama).render(); + * + * panorama.destroy(); + * + * // Use the blurred panorama in a filter. + * anotherObject.enableFilters().filters.internal.addImageLight({ environmentMap: 'panorama-blurred' }); + * + * @class PanoramaBlur + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {Phaser.Types.Filters.PanoramaBlurConfig} [config] - The configuration object for the PanoramaBlur effect. + */ +var PanoramaBlur = new Class({ + Extends: Controller, + + initialize: function PanoramaBlur (camera, config) + { + if (config === undefined) { config = {}; } + + Controller.call(this, camera, 'FilterPanoramaBlur'); + + /** + * The radius of the blur effect. 1 samples an entire hemisphere; 0 samples a single point. + * + * @name Phaser.Filters.PanoramaBlur#radius + * @type {number} + * @since 4.0.0 + */ + this.radius = config.radius || 1; + + /** + * The number of samples to take along the X axis. More samples produces a more accurate blur, but at the cost of performance. The X axis in a panorama is usually wider than the Y axis. + * + * Altering this value triggers a shader re-compile. + * + * @name Phaser.Filters.PanoramaBlur#samplesX + * @type {number} + * @since 4.0.0 + */ + this.samplesX = config.samplesX || 32; + + /** + * The number of samples to take along the Y axis. More samples produces a more accurate blur, but at the cost of performance. + * + * Altering this value triggers a shader re-compile. + * + * @name Phaser.Filters.PanoramaBlur#samplesY + * @type {number} + * @since 4.0.0 + */ + this.samplesY = config.samplesY || 16; + + /** + * An exponent applied to samples. Power above 1 darkens the samples overall, but bright colors are suppressed less than dark ones, causing them to become relatively more dominant in the result. Power below 1 brightens samples overall, reducing the contrast between bright and dark colors. To simulate an HDR environment with bright sunlight that cannot be represented in sRGB color, use high power. + * + * @name Phaser.Filters.PanoramaBlur#power + * @type {number} + * @since 4.0.0 + */ + this.power = config.power || 1; + } +}); + +module.exports = PanoramaBlur; + + +/***/ }, + +/***/ 2195 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var FilterList = __webpack_require__(53427); +var Controller = __webpack_require__(13045); +var Blend = __webpack_require__(16762); + +/** + * @classdesc + * The Parallel Filters Controller. + * + * This filter controller splits the input into two lists of filters, + * runs each list separately, and then blends the results together. + * + * The Parallel Filters effect is useful for reusing an input. + * Ordinarily, a filter modifies the input and passes it to the next filter. + * This effect allows you to split the input and re-use it elsewhere. + * It does not gain performance benefits from parallel processing; + * it is a convenience for reusing the input. + * + * The Parallel Filters effect is not a filter itself. + * It is a controller that manages two FilterLists, + * and the final Blend filter that combines the results. + * The FilterLists are named 'top' and 'bottom'. + * The 'top' output is applied as a blend texture to the 'bottom' output. + * + * You do not have to populate both lists. If only one is populated, + * it will be blended with the original input at the end. + * This is useful when you want to retain image data that would be lost + * in the filter process. + * + * A Parallel Filters effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addParallelFilters(); + * camera.filters.external.addParallelFilters(); + * ``` + * + * @example + * // Create a customizable Bloom effect. + * const camera = this.cameras.main; + * const parallelFilters = camera.filters.internal.addParallelFilters(); + * parallelFilters.top.addThreshold(0.5, 1); + * parallelFilters.top.addBlur(); + * parallelFilters.blend.blendMode = Phaser.BlendModes.ADD; + * parallelFilters.blend.amount = 0.5; + * + * @class ParallelFilters + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + */ +var ParallelFilters = new Class({ + Extends: Controller, + + initialize: function ParallelFilters (camera) + { + Controller.call(this, camera, 'FilterParallelFilters'); + + /** + * The top FilterList. Filters added to this list receive the original + * input and are processed independently from the bottom list. The final + * output of this list is passed to the Blend controller as a blend + * texture, which is then composited onto the bottom output. + * + * @name Phaser.Filters.ParallelFilters#top + * @type {Phaser.GameObjects.Components.FilterList} + * @since 4.0.0 + */ + this.top = new FilterList(camera); + + /** + * The bottom FilterList. Filters added to this list receive the original + * input and are processed independently from the top list. The final + * output of this list serves as the base image onto which the top + * output is blended by the Blend controller. + * + * @name Phaser.Filters.ParallelFilters#bottom + * @type {Phaser.GameObjects.Components.FilterList} + * @since 4.0.0 + */ + this.bottom = new FilterList(camera); + + /** + * The Blend filter controller that composites the top and bottom + * FilterList outputs into a single result. It is a standard + * {@link Phaser.Filters.Blend} controller whose blend mode and amount + * can be configured to control how the two outputs are combined. + * See {@link Phaser.Filters.Blend} for more information. + * + * The `texture` property of the Blend controller will be + * overwritten during rendering. + * + * @name Phaser.Filters.ParallelFilters#blend + * @type {Phaser.Filters.Blend} + * @since 4.0.0 + */ + this.blend = new Blend(camera); + } +}); + +// To eliminate a circular dependency, +// addParallelFilters is defined and injected here. + +/** + * Adds a Parallel Filters effect. + * + * This filter controller splits the input into two lists of filters, + * runs each list separately, and then blends the results together. + * + * The Parallel Filters effect is useful for reusing an input. + * Ordinarily, a filter modifies the input and passes it to the next filter. + * This effect allows you to split the input and re-use it elsewhere. + * It does not gain performance benefits from parallel processing; + * it is a convenience for reusing the input. + * + * The Parallel Filters effect is not a filter itself. + * It is a controller that manages two FilterLists, + * and the final Blend filter that combines the results. + * The FilterLists are named 'top' and 'bottom'. + * The 'top' output is applied as a blend texture to the 'bottom' output. + * + * You do not have to populate both lists. If only one is populated, + * it will be blended with the original input at the end. + * This is useful when you want to retain image data that would be lost + * in the filter process. + * + * @example + * // Create a customizable Bloom effect. + * const camera = this.cameras.main; + * const parallelFilters = camera.filters.internal.addParallelFilters(); + * parallelFilters.top.addThreshold(0.5, 1); + * parallelFilters.top.addBlur(); + * parallelFilters.blend.blendMode = Phaser.BlendModes.ADD; + * parallelFilters.blend.amount = 0.5; + * + * @method Phaser.GameObjects.Components.FilterList#addParallelFilters + * @since 4.0.0 + * @return {Phaser.Filters.ParallelFilters} The new Parallel Filters filter controller. + */ +FilterList.prototype.addParallelFilters = function () +{ + return this.add(new ParallelFilters(this.camera)); +}; + +module.exports = ParallelFilters; + + +/***/ }, + +/***/ 29861 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Pixelate Filter Controller. + * + * This filter controller manages the pixelate effect for a Camera. + * The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image, + * creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic + * purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as + * during a transition or to censor specific content. + * + * A Pixelate effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addPixelate(); + * ``` + * + * @class Pixelate + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {number} [amount=1] - The amount of pixelation to apply. + */ +var Pixelate = new Class({ + Extends: Controller, + + initialize: function Pixelate (camera, amount) + { + if (amount === undefined) { amount = 1; } + + Controller.call(this, camera, 'FilterPixelate'); + + /** + * The amount of pixelation to apply. + * + * The size of the pixels is equal to 2 + the amount. + * + * @name Phaser.Filters.Pixelate#amount + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.amount = amount; + } +}); + +module.exports = Pixelate; + + +/***/ }, + +/***/ 14366 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Quantize Filter Controller. + * + * This controller manages the Quantize effect on a Camera. + * + * Quantization reduces the unique number of colors in an image, + * based on some limited number of steps per color channel. + * This is good for creating a retro or stylized effect. + * + * Basic quantization breaks each channel up into a number of `steps`. + * These steps are normally regular. You can bias them towards the top or bottom + * by changing that channel's `gamma` value. + * You can adjust the lowest step, thus all subsequent steps, with the `offset`. + * + * Quantization is done in either RGBA or HSVA space. + * The steps, gamma, and offset always apply in the same order, + * but depending on color mode, they are either applied to + * `[ red, green, blue, alpha ]` or `[ hue, saturation, value, alpha ]`. + * + * The output may optionally be dithered, to eliminate banding + * and create the illusion that there are many more colors in use. + * + * @example + * const camera = this.cameras.main; + * camera.filters.internal.addQuantize(); // Default effect. + * camera.filters.external.addQuantize({ + * steps: [ 16, 1, 1, 1 ], + * dither: true, + * mode: 1 + * }); // Quantize into 16 fully saturated rainbow hues, and dither. + * + * @class Quantize + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {Phaser.Types.Filters.QuantizeConfig} [config] - The configuration object for the Quantize effect. + */ +var Quantize = new Class({ + Extends: Controller, + + initialize: function Quantize (camera, config) + { + if (!config) { config = {}; } + + Controller.call(this, camera, 'FilterQuantize'); + + /** + * How many steps to divide each channel into. + * + * It's often useful to drop the last place to 1, + * because it's alpha in both RGBA and HSVA, + * and alpha is often either on or off. + * + * In RGBA mode, the first 3 channels (RGB) should + * probably be the same, unless there's a stylistic need. + * In HSVA mode, the first channel (H) should probably have + * many divisions to distinguish different hues, + * while the second and third channels (SV) may need fewer steps. + * + * @name Phaser.Filters.Quantize#steps + * @type {number[]} + * @since 4.0.0 + * @default [ 8, 8, 8, 8 ] + */ + this.steps = [ 8, 8, 8, 8 ]; + if (config.steps) + { + this.steps[0] = config.steps[0]; + this.steps[1] = config.steps[1]; + this.steps[2] = config.steps[2]; + this.steps[3] = config.steps[3]; + } + + /** + * Gamma curve applied to the input channels. + * This can help prioritize nuances in dark or light areas. + * + * In RGBA mode, the RGB channels can be treated the same. + * In HSVA mode, you probably want to apply gamma to just + * the value and saturation channels. + * + * @name Phaser.Filters.Quantize#gamma + * @type {number[]} + * @since 4.0.0 + * @default [ 1, 1, 1, 1 ] + */ + this.gamma = [ 1, 1, 1, 1 ]; + if (config.gamma) + { + this.gamma[0] = config.gamma[0]; + this.gamma[1] = config.gamma[1]; + this.gamma[2] = config.gamma[2]; + this.gamma[3] = config.gamma[3]; + } + + /** + * Offset to apply to the channels during quantization. + * This mainly exists to slide the hue angle for HSVA quantization. + * + * @name Phaser.Filters.Quantize#offset + * @type {number[]} + * @since 4.0.0 + * @default [ 0, 0, 0, 0 ] + */ + this.offset = [ 0, 0, 0, 0 ]; + if (config.offset) + { + this.offset[0] = config.offset[0]; + this.offset[1] = config.offset[1]; + this.offset[2] = config.offset[2]; + this.offset[3] = config.offset[3]; + } + + /** + * The color space to use. 0 is RGBA, 1 is HSVA. + * Use HSVA to control many hues with fewer levels + * of lightness/saturation. + * + * When the mode changes to HSVA, `steps`, `gamma`, and `offset` + * now apply to the hue, saturation, value, and alpha channels. + * They are otherwise unchanged. + * + * @name Phaser.Filters.Quantize#mode + * @type {number} + * @since 4.0.0 + * @default 0 + */ + this.mode = config.mode || 0; + + /** + * Whether to apply dither to the quantization, + * creating a smoother output with the reduced colors. + * + * @name Phaser.Filters.Quantize#dither + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.dither = !!config.dither; + } +}); + +module.exports = Quantize; + + +/***/ }, + +/***/ 63785 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Sampler Filter Controller. + * + * This controller reads pixel data from the camera's rendered output and passes + * it to a user-defined callback. Unlike other filter controllers, the Sampler + * does not alter the rendered image in any way — it is purely a data extraction + * tool. It can sample a single point, a rectangular region, or the entire + * camera view, and is useful for techniques such as color picking, pixel-perfect + * hit detection, or runtime visual analysis. + * + * This operation is expensive, so use sparingly. + * + * A Sampler is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addSampler(callback, region); + * camera.filters.external.addSampler(callback, region); + * ``` + * + * @class Sampler + * @memberof Phaser.Filters + * @extends Phaser.Filters.Controller + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {Phaser.Types.Renderer.Snapshot.SnapshotCallback} callback - The callback to call with the results of the sampler. + * @param {null|Phaser.Types.Math.Vector2Like|Phaser.Geom.Rectangle} [region=null] - The region to sample. If `null`, the entire camera view is sampled. If a `Phaser.Types.Math.Vector2Like`, a point is sampled. If a `Phaser.Geom.Rectangle`, the region is sampled. + */ +var Sampler = new Class({ + Extends: Controller, + + initialize: function Sampler (camera, callback, region) + { + if (region === undefined) { region = null; } + + Controller.call(this, camera, 'FilterSampler'); + + this.allowBaseDraw = false; + + /** + * The callback to invoke once the pixel data has been read from the + * sampled region. It receives the snapshot result, which may be an + * `HTMLImageElement` (for region snapshots) or a `Phaser.Display.Color` + * (for point snapshots), depending on the `region` type. + * + * @name Phaser.Filters.Sampler#callback + * @type {Phaser.Types.Renderer.Snapshot.SnapshotCallback} + * @since 4.0.0 + */ + this.callback = callback; + + /** + * The region to sample. If `null`, the entire camera view is sampled. + * If a `Phaser.Types.Math.Vector2Like`, a point is sampled. + * If a `Phaser.Geom.Rectangle`, the region is sampled. + * + * @name Phaser.Filters.Sampler#region + * @type {null|Phaser.Types.Math.Vector2Like|Phaser.Geom.Rectangle} + * @since 4.0.0 + */ + this.region = region; + } +}); + +module.exports = Sampler; + + +/***/ }, + +/***/ 62229 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Shadow Filter. + * + * This filter controller manages the shadow effect for a Camera. + * + * The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker, + * offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows + * help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional. + * + * This effect samples across an area. To avoid missing data at the edges, + * use `controller.setPaddingOverride(null)` to automatically pad game objects, + * or `camera.getPaddingWrapper(x)` to enlarge a camera. + * + * A Shadow effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addShadow(); + * camera.filters.external.addShadow(); + * ``` + * + * @class Shadow + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {number} [x=0] - The horizontal offset of the shadow effect. + * @param {number} [y=0] - The vertical offset of the shadow effect. + * @param {number} [decay=0.1] - The amount of decay for the shadow effect. + * @param {number} [power=1] - The power of the shadow effect. + * @param {number} [color=0x000000] - The color of the shadow, as a hex value. + * @param {number} [samples=6] - The number of samples that the shadow effect will run for. + * @param {number} [intensity=1] - The intensity of the shadow effect. + */ +var Shadow = new Class({ + + Extends: Controller, + + initialize: function Shadow (camera, x, y, decay, power, color, samples, intensity) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (decay === undefined) { decay = 0.1; } + if (power === undefined) { power = 1; } + if (samples === undefined) { samples = 6; } + if (intensity === undefined) { intensity = 1; } + + Controller.call(this, camera, 'FilterShadow'); + + /** + * The horizontal offset of the shadow effect. + * + * @name Phaser.Filters.Shadow#x + * @type {number} + * @since 4.0.0 + */ + this.x = x; + + /** + * The vertical offset of the shadow effect. + * + * @name Phaser.Filters.Shadow#y + * @type {number} + * @since 4.0.0 + */ + this.y = y; + + /** + * Controls how quickly the shadow fades over distance. Lower values produce longer, + * more gradual shadows; higher values produce shorter, more concentrated shadows. + * + * @name Phaser.Filters.Shadow#decay + * @type {number} + * @since 4.0.0 + */ + this.decay = decay; + + /** + * An exponent applied to the shadow falloff curve. Higher values create sharper + * shadow edges; lower values create softer, more diffuse shadows. + * + * @name Phaser.Filters.Shadow#power + * @type {number} + * @since 4.0.0 + */ + this.power = power; + + /** + * The internal WebGL color array used by the shader. Stores the shadow color + * as normalized RGBA float values in the range 0 to 1. This array is updated + * automatically when the `color` property is set. + * + * @name Phaser.Filters.Shadow#glcolor + * @type {number[]} + * @since 4.0.0 + */ + this.glcolor = [ 0, 0, 0, 1 ]; + + /** + * The number of samples that the shadow effect will run for. + * + * This should be an integer with a minimum value of 1 and a maximum of 12. + * + * @name Phaser.Filters.Shadow#samples + * @type {number} + * @since 4.0.0 + */ + this.samples = samples; + + /** + * A multiplier for the overall shadow visibility. Higher values produce darker, + * more prominent shadows. + * + * @name Phaser.Filters.Shadow#intensity + * @type {number} + * @since 4.0.0 + */ + this.intensity = intensity; + + if (color !== undefined) + { + this.color = color; + } + }, + + /** + * The color of the shadow, expressed as a hex RGB value (e.g. `0xff0000` for red, + * `0x000000` for black). Setting this property updates the internal `glcolor` array + * used by the WebGL shader. + * + * @name Phaser.Filters.Shadow#color + * @type {number} + * @since 4.0.0 + */ + color: { + + get: function () + { + var color = this.glcolor; + + return (((color[0] * 255) << 16) + ((color[1] * 255) << 8) + (color[2] * 255 | 0)); + }, + + set: function (value) + { + var color = this.glcolor; + + color[0] = ((value >> 16) & 0xFF) / 255; + color[1] = ((value >> 8) & 0xFF) / 255; + color[2] = (value & 0xFF) / 255; + } + + }, + + /** + * Returns the amount of extra padding, in pixels, that this filter requires when rendering. + * The padding accounts for the shadow effect extending beyond the original bounds + * of the filtered Game Object. + * + * @method Phaser.Filters.Shadow#getPadding + * @since 4.0.0 + * + * @return {Phaser.Geom.Rectangle} The padding Rectangle. + */ + getPadding: function () + { + var override = this.paddingOverride; + if (override) + { + this.currentPadding.setTo(override.x, override.y, override.width, override.height); + return override; + } + + var camera = this.camera; + var factor = this.decay * this.intensity; + var x = Math.ceil(Math.abs(this.x) * camera.width * factor); + var y = Math.ceil(Math.abs(this.y) * camera.height * factor); + + // Never get smaller, only larger. + this.currentPadding.setTo(-x, -y, x * 2, y * 2); + + return this.currentPadding; + } +}); + +module.exports = Shadow; + + +/***/ }, + +/***/ 99534 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); + +/** + * @classdesc + * The Threshold Filter Controller. + * + * This controller manages a threshold filter. + * Input values are compared to a threshold value or range. + * Values below the threshold are set to 0, and values above the threshold are set to 1. + * Values within the range are linearly interpolated between 0 and 1. + * + * This is useful for creating effects such as sharp edges from gradients, + * or for creating binary effects. + * + * The threshold is stored as a range, with two edges. + * Each edge has a value for each channel, between 0 and 1. + * If the two edges are the same, the threshold has no interpolation, + * and will output either 0 or 1. + * Each channel can also be inverted. + * + * A Threshold effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addThreshold(); + * camera.filters.external.addThreshold(); + * ``` + * + * @class Threshold + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @extends Phaser.Filters.Controller + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this filter. + * @param {number|number[]} [edge1=0.5] - The first edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. + * @param {number|number[]} [edge2=0.5] - The second edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. + * @param {boolean|boolean[]} [invert=false] - Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean to apply to all 4 channels. + */ +var Threshold = new Class({ + Extends: Controller, + + initialize: function Threshold (camera, edge1, edge2, invert) + { + Controller.call(this, camera, 'FilterThreshold'); + + /** + * The first edge of the threshold. + * This contains the lowest value for each channel. + * + * @name Phaser.Filters.Threshold#edge1 + * @type {number[]} + * @default [ 0.5, 0.5, 0.5, 0.5 ] + * @since 4.0.0 + */ + this.edge1 = [ 0.5, 0.5, 0.5, 0.5 ]; + + /** + * The second edge of the threshold. + * This contains the highest value for each channel. + * If it is the same as the first edge, the threshold is a single value. + * + * @name Phaser.Filters.Threshold#edge2 + * @type {number[]} + * @default [ 0.5, 0.5, 0.5, 0.5 ] + * @since 4.0.0 + */ + this.edge2 = [ 0.5, 0.5, 0.5, 0.5 ]; + + /** + * Whether each channel is inverted. When a channel is inverted, its + * output is flipped so that values that would normally output 0 instead + * output 1, and vice versa. This applies per-channel to the RGBA + * components of the threshold result. + * + * @name Phaser.Filters.Threshold#invert + * @type {boolean[]} + * @default [ false, false, false, false ] + * @since 4.0.0 + */ + this.invert = [ false, false, false, false ]; + + this.setEdge(edge1, edge2); + this.setInvert(invert); + }, + + /** + * Set the edges of the threshold. + * If the second edge is not provided, it will be set to the first edge. + * + * This ensures that the first edge is not greater than the second edge. + * It may swap channels between edges to ensure this. + * + * @method Phaser.Filters.Threshold#setEdge + * @since 4.0.0 + * @param {number|number[]} [edge1=0.5] - The first edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. + * @param {number|number[]} [edge2=0.5] - The second edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. + * @return {Phaser.Filters.Threshold} This Threshold instance. + */ + setEdge: function (edge1, edge2) + { + if (edge1 === undefined) + { + edge1 = 0.5; + } + if (typeof edge1 === 'number') + { + edge1 = [ edge1, edge1, edge1, edge1 ]; + } + + this.edge1[0] = edge1[0]; + this.edge1[1] = edge1[1]; + this.edge1[2] = edge1[2]; + this.edge1[3] = edge1[3]; + + if (edge2 === undefined) + { + edge2 = edge1; + } + if (typeof edge2 === 'number') + { + edge2 = [ edge2, edge2, edge2, edge2 ]; + } + + this.edge2[0] = edge2[0]; + this.edge2[1] = edge2[1]; + this.edge2[2] = edge2[2]; + this.edge2[3] = edge2[3]; + + for (var i = 0; i < 4; i++) + { + if (this.edge1[i] > this.edge2[i]) + { + var temp = this.edge1[i]; + this.edge1[i] = this.edge2[i]; + this.edge2[i] = temp; + } + } + + return this; + }, + + /** + * Sets the invert state for each channel of the threshold filter. + * When a channel is inverted, its output is flipped: pixels that would + * output 0 instead output 1, and vice versa. This can be used to create + * negative or reversed threshold effects per channel. + * If `invert` is not provided, all channels default to `false`. + * + * @method Phaser.Filters.Threshold#setInvert + * @since 4.0.0 + * @param {boolean|boolean[]} [invert=false] - Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean to apply to all 4 channels. + * @return {Phaser.Filters.Threshold} This Threshold instance. + */ + setInvert: function (invert) + { + if (invert === undefined) + { + invert = false; + } + if (typeof invert === 'boolean') + { + invert = [ invert, invert, invert, invert ]; + } + + this.invert[0] = invert[0]; + this.invert[1] = invert[1]; + this.invert[2] = invert[2]; + this.invert[3] = invert[3]; + + return this; + } +}); + +module.exports = Threshold; + + +/***/ }, + +/***/ 20263 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var Color = __webpack_require__(40987); + +/** + * @classdesc + * The Vignette Filter Controller. + * + * This controller manages the vignette effect for a Camera. + * + * The vignette effect is a visual technique where the edges of the screen, + * or a Game Object, gradually darken or blur, + * creating a frame-like appearance. This effect is used to draw the player's + * focus towards the central action or subject, enhance immersion, + * and provide a cinematic or artistic quality to the game's visuals. + * + * This filter supports colored borders, and a limited set of blend modes, + * to increase its stylistic power. + * + * A Vignette effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * + * camera.filters.internal.addVignette(); + * camera.filters.external.addVignette(); + * ``` + * + * @class Vignette + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {number} [x=0.5] - The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. + * @param {number} [y=0.5] - The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. + * @param {number} [radius=0.5] - The radius of the vignette effect. This value is normalized to the range 0 to 1. + * @param {number} [strength=0.5] - The strength of the vignette effect. + * @param {number | string | Phaser.Types.Display.InputColorObject | Phaser.Display.Color} [color=0x000000] - The color of the vignette effect, as a hex code or Color object. + * @param {number} [blendMode=Phaser.BlendModes.NORMAL] - The blend mode to use with the vignette. Only NORMAL, ADD, MULTIPLY, and SCREEN are supported. + */ +var Vignette = new Class({ + + Extends: Controller, + + initialize: function Vignette (camera, x, y, radius, strength, color, blendMode) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = 0.5; } + if (radius === undefined) { radius = 0.5; } + if (strength === undefined) { strength = 0.5; } + if (color === undefined) { color = 0x000000; } + if (blendMode === undefined) { blendMode = 0; } + + Controller.call(this, camera, 'FilterVignette'); + + /** + * The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. + * + * @name Phaser.Filters.Vignette#x + * @type {number} + * @since 4.0.0 + */ + this.x = x; + + /** + * The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. + * + * @name Phaser.Filters.Vignette#y + * @type {number} + * @since 4.0.0 + */ + this.y = y; + + /** + * The radius of the vignette effect. This value is normalized to the range 0 to 1. + * + * @name Phaser.Filters.Vignette#radius + * @type {number} + * @since 4.0.0 + */ + this.radius = radius; + + /** + * The strength of the vignette effect. Higher values produce a more + * intense, opaque vignette overlay at the edges, while lower values + * produce a subtler, more transparent effect. + * + * @name Phaser.Filters.Vignette#strength + * @type {number} + * @since 4.0.0 + */ + this.strength = strength; + + /** + * The color of the vignette effect. + * + * @name Phaser.Filters.Vignette#color + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.color = new Color(); + + /** + * The blend mode used to combine the vignette color with the input. + * Note that only NORMAL, ADD, MULTIPLY and SCREEN are supported. + * + * @name Phaser.Filters.Vignette#blendMode + * @type {Phaser.BlendModes} + * @since 4.0.0 + * @default Phaser.BlendModes.NORMAL + */ + this.blendMode = blendMode; + + this.setColor(color); + }, + + /** + * Sets the color of the vignette overlay. + * + * @method Phaser.Filters.Vignette#setColor + * @since 4.0.0 + * @param {number | string | Phaser.Types.Display.InputColorObject | Phaser.Display.Color} color - The color to set. Note that a Color object will be copied, not attached. + * @return {this} This filter instance. + */ + setColor: function (color) + { + if (typeof color === 'number') + { + Color.IntegerToColor(color, this.color); + } + else if (typeof color === 'string') + { + Color.HexStringToColor(color, this.color); + } + else if (color.setTo) + { + this.color.setTo(color.red, color.green, color.blue, color.alpha); + } + else if (color) + { + this.color.setTo(color.r || 0, color.g || 0, color.b || 0, color.a || 255); + } + else + { + this.color.setTo(0, 0, 0, 255); + } + + return this; + } +}); + +module.exports = Vignette; + + +/***/ }, + +/***/ 90002 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(13045); +var Texture = __webpack_require__(79237); + +/** + * @classdesc + * The Wipe Filter Controller. + * + * This controller manages the wipe effect for a Camera. + * + * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements + * in the game, such as images, text, or scene transitions. This effect is often used to create + * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition + * between game states. + * + * You can set both the direction and the axis of the wipe effect. The following combinations are possible: + * + * * left to right: direction 0, axis 0 + * * right to left: direction 1, axis 0 + * * top to bottom: direction 1, axis 1 + * * bottom to top: direction 0, axis 1 + * + * It is up to you to set the `progress` value yourself, e.g. via a Tween, in order to transition the effect. + * + * A Wipe effect is added to a Camera via the FilterList component: + * + * ```js + * const camera = this.cameras.main; + * camera.filters.internal.addWipe(); + * camera.filters.external.addWipe(); + * ``` + * + * @class Wipe + * @extends Phaser.Filters.Controller + * @memberof Phaser.Filters + * @constructor + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that owns this filter. + * @param {number} [wipeWidth=0.1] - The width of the wipe effect. This value is normalized in the range 0 to 1. + * @param {number} [direction=0] - The direction of the wipe effect. Either 0 (left to right, or top to bottom) or 1 (right to left, or bottom to top). Set in conjunction with the axis property. + * @param {number} [axis=0] - The axis of the wipe effect. Either 0 (X) or 1 (Y). Set in conjunction with the direction property. + * @param {number} [reveal=0] - Is this a reveal (1) or a wipe (0) effect? Reveal shows the input in wiped areas; wipe shows the input in unwiped areas. + * @param {string | Phaser.Textures.Texture} [wipeTexture='__DEFAULT'] - Texture or texture key to use where the input texture is not shown. The default texture is blank. Use another texture for a wipe transition. + */ +var Wipe = new Class({ + Extends: Controller, + + initialize: function Wipe (camera, wipeWidth, direction, axis, reveal, wipeTexture) + { + if (wipeWidth === undefined) + { + wipeWidth = 0.1; + } + + Controller.call(this, camera, 'FilterWipe'); + + /** + * The progress of the Wipe effect. This value is normalized to the range 0 to 1. + * + * Adjust this value to make the wipe transition (e.g. via a Tween). + * + * @name Phaser.Filters.Wipe#progress + * @type {number} + * @since 4.0.0 + */ + this.progress = 0; + + /** + * The width of the wipe effect. This value is normalized in the range 0 to 1. + * + * @name Phaser.Filters.Wipe#wipeWidth + * @type {number} + * @since 4.0.0 + * @default 0.1 + */ + this.wipeWidth = wipeWidth; + + /** + * The direction of the wipe effect. Either 0 (left to right, or top to bottom) or 1 (right to left, or bottom to top). Set in conjunction with the axis property. + * + * @name Phaser.Filters.Wipe#direction + * @type {number} + * @since 4.0.0 + */ + this.direction = direction || 0; + + /** + * The axis of the wipe effect. Either 0 (X) or 1 (Y). Set in conjunction with the direction property. + * + * @name Phaser.Filters.Wipe#axis + * @type {number} + * @since 4.0.0 + */ + this.axis = axis || 0; + + /** + * Is this a reveal (1) or a wipe (0) effect? + * Reveal shows the input in wiped areas; + * wipe shows the input in unwiped areas. + * + * @name Phaser.Filters.Wipe#reveal + * @type {number} + * @since 4.0.0 + */ + this.reveal = reveal || 0; + + /** + * The texture to use where the input is removed. + * The default texture '__DEFAULT' is blank. + * Use another texture for a wipe transition. + * + * @name Phaser.Filters.Wipe#wipeTexture + * @type {Phaser.Textures.Texture} + * @since 4.0.0 + */ + this.wipeTexture = null; + + this.setTexture(wipeTexture); + }, + + /** + * Set the width of the wipe effect. + * + * @method Phaser.Filters.Wipe#setWipeWidth + * @since 4.0.0 + * @param {number} width - The width of the wipe effect. This value is normalized in the range 0 to 1. + * @return {this} - This filter instance. + */ + setWipeWidth: function (width) + { + if (width === undefined) + { + width = 0.1; + } + this.wipeWidth = width; + return this; + }, + + /** + * Set the wipe effect to run left to right. + * + * @method Phaser.Filters.Wipe#setLeftToRight + * @since 4.0.0 + * @return {this} - This filter instance. + */ + setLeftToRight: function () + { + this.direction = 0; + this.axis = 0; + return this; + }, + + /** + * Set the wipe effect to run right to left. + * + * @method Phaser.Filters.Wipe#setRightToLeft + * @since 4.0.0 + * @return {this} - This filter instance. + */ + setRightToLeft: function () + { + this.direction = 1; + this.axis = 0; + return this; + }, + + /** + * Set the wipe effect to run top to bottom. + * + * @method Phaser.Filters.Wipe#setTopToBottom + * @since 4.0.0 + * @return {this} - This filter instance. + */ + setTopToBottom: function () + { + this.direction = 1; + this.axis = 1; + return this; + }, + + /** + * Set the wipe effect to run bottom to top. + * + * @method Phaser.Filters.Wipe#setBottomToTop + * @since 4.0.0 + * @return {this} - This filter instance. + */ + setBottomToTop: function () + { + this.direction = 0; + this.axis = 1; + return this; + }, + + /** + * Configures this filter to run as a wipe effect, where the input is removed + * as the transition progresses. Also resets `progress` to 0. + * Use `setRevealEffect` for the opposite behavior. + * + * @method Phaser.Filters.Wipe#setWipeEffect + * @since 4.0.0 + * @return {this} - This filter instance. + */ + setWipeEffect: function () + { + this.reveal = 0; + this.progress = 0; + return this; + }, + + /** + * Configures this filter to run as a reveal effect, where the input is gradually + * uncovered as the transition progresses. Also resets the texture to the default + * blank texture and resets `progress` to 0. + * Use `setWipeEffect` for the opposite behavior. + * + * @method Phaser.Filters.Wipe#setRevealEffect + * @since 4.0.0 + * @return {this} - This filter instance. + */ + setRevealEffect: function () + { + this.setTexture(); + this.reveal = 1; + this.progress = 0; + return this; + }, + + + /** + * Set the texture to use where the input is removed. + * The default texture is blank, so the input is just hidden. + * + * @method Phaser.Filters.Wipe#setTexture + * @since 4.0.0 + * @param {string | Phaser.Textures.Texture} [texture='__DEFAULT'] - Texture or texture key to use for regions where the input is removed. + * @return {this} - This filter instance. + */ + setTexture: function (texture) + { + if (texture === undefined) + { + texture = '__DEFAULT'; + } + if (texture instanceof Texture) + { + this.wipeTexture = texture; + } + else + { + this.wipeTexture = this.camera.scene.sys.textures.get(texture) || this.camera.scene.sys.textures.get('__DEFAULT'); + } + return this; + }, + + /** + * Sets the progress of the wipe effect, controlling how far along the transition + * has advanced. A value of 0 means the transition has not started, and 1 means it + * is complete. You would typically drive this via a Tween rather than setting it directly. + * + * @method Phaser.Filters.Wipe#setProgress + * @since 4.0.0 + * @param {number} value - Progress, normalized to the range 0-1. + * @return {this} - This filter instance. + */ + setProgress: function (value) + { + this.progress = value; + return this; + } +}); + +module.exports = Wipe; + + +/***/ }, + +/***/ 11889 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Filters + */ + +var Filters = { + Controller: __webpack_require__(13045), + + Barrel: __webpack_require__(10189), + Blend: __webpack_require__(16762), + Blocky: __webpack_require__(37597), + Blur: __webpack_require__(88344), + Bokeh: __webpack_require__(47564), + ColorMatrix: __webpack_require__(77011), + CombineColorMatrix: __webpack_require__(95200), + Displacement: __webpack_require__(16898), + Glow: __webpack_require__(42652), + GradientMap: __webpack_require__(43927), + ImageLight: __webpack_require__(84714), + Key: __webpack_require__(51890), + Mask: __webpack_require__(97797), + NormalTools: __webpack_require__(37911), + PanoramaBlur: __webpack_require__(6379), + ParallelFilters: __webpack_require__(2195), + Pixelate: __webpack_require__(29861), + Quantize: __webpack_require__(14366), + Sampler: __webpack_require__(63785), + Shadow: __webpack_require__(62229), + Threshold: __webpack_require__(99534), + Vignette: __webpack_require__(20263), + Wipe: __webpack_require__(90002) +}; + +module.exports = Filters; + + +/***/ }, + +/***/ 25305 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BlendModes = __webpack_require__(10312); +var GetAdvancedValue = __webpack_require__(23568); + +/** + * Builds a Game Object using the provided configuration object, applying properties such as + * position, depth, flip, scale, scroll factor, rotation, alpha, origin, blend mode, and + * visibility. If the config's `add` property is `true` (the default), the Game Object is + * added to the Scene's Display List. If the Game Object has a `preUpdate` method it is also + * added to the Scene's Update List. This function is used internally by Game Object factories + * and creators, and is not typically called directly. + * + * @function Phaser.GameObjects.BuildGameObject + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene. + * @param {Phaser.GameObjects.GameObject} gameObject - The initial GameObject. + * @param {Phaser.Types.GameObjects.GameObjectConfig} config - The config to build the GameObject with. + * + * @return {Phaser.GameObjects.GameObject} The built Game Object. + */ +var BuildGameObject = function (scene, gameObject, config) +{ + // Position + + gameObject.x = GetAdvancedValue(config, 'x', 0); + gameObject.y = GetAdvancedValue(config, 'y', 0); + gameObject.depth = GetAdvancedValue(config, 'depth', 0); + + // Flip + + gameObject.flipX = GetAdvancedValue(config, 'flipX', false); + gameObject.flipY = GetAdvancedValue(config, 'flipY', false); + + // Scale + // Either: { scale: 2 } or { scale: { x: 2, y: 2 }} + + var scale = GetAdvancedValue(config, 'scale', null); + + if (typeof scale === 'number') + { + gameObject.setScale(scale); + } + else if (scale !== null) + { + gameObject.scaleX = GetAdvancedValue(scale, 'x', 1); + gameObject.scaleY = GetAdvancedValue(scale, 'y', 1); + } + + // ScrollFactor + // Either: { scrollFactor: 2 } or { scrollFactor: { x: 2, y: 2 }} + + var scrollFactor = GetAdvancedValue(config, 'scrollFactor', null); + + if (typeof scrollFactor === 'number') + { + gameObject.setScrollFactor(scrollFactor); + } + else if (scrollFactor !== null) + { + gameObject.scrollFactorX = GetAdvancedValue(scrollFactor, 'x', 1); + gameObject.scrollFactorY = GetAdvancedValue(scrollFactor, 'y', 1); + } + + // Rotation + + gameObject.rotation = GetAdvancedValue(config, 'rotation', 0); + + var angle = GetAdvancedValue(config, 'angle', null); + + if (angle !== null) + { + gameObject.angle = angle; + } + + // Alpha + + gameObject.alpha = GetAdvancedValue(config, 'alpha', 1); + + // Origin + // Either: { origin: 0.5 } or { origin: { x: 0.5, y: 0.5 }} + + var origin = GetAdvancedValue(config, 'origin', null); + + if (typeof origin === 'number') + { + gameObject.setOrigin(origin); + } + else if (origin !== null) + { + var ox = GetAdvancedValue(origin, 'x', 0.5); + var oy = GetAdvancedValue(origin, 'y', 0.5); + + gameObject.setOrigin(ox, oy); + } + + // BlendMode + + gameObject.blendMode = GetAdvancedValue(config, 'blendMode', BlendModes.NORMAL); + + // Visible + + gameObject.visible = GetAdvancedValue(config, 'visible', true); + + // Add to Scene + + var add = GetAdvancedValue(config, 'add', true); + + if (add) + { + scene.sys.displayList.add(gameObject); + } + + if (gameObject.preUpdate) + { + scene.sys.updateList.add(gameObject); + } + + return gameObject; +}; + +module.exports = BuildGameObject; + + +/***/ }, + +/***/ 13059 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetAdvancedValue = __webpack_require__(23568); + +/** + * Reads the `anims` property from a Game Object configuration object and uses it to + * configure the animation state of the given Sprite. If the `anims` property is absent, + * the Sprite is returned unchanged. + * + * The `anims` value may be either a string or an object. If it is a string, it is treated + * as an animation key and the animation is played immediately. If it is an object, the + * animation key and playback options (such as `delay`, `repeat`, `yoyo`, and `startFrame`) + * are read from it. Depending on the `play` and `delayedPlay` properties, the animation + * will be played immediately, played after a delay, or simply loaded ready to play later. + * + * @function Phaser.GameObjects.BuildGameObjectAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - The Sprite whose animation state will be configured. + * @param {object} config - The Game Object configuration object. The `anims` property of this object is used to configure the animation. + * + * @return {Phaser.GameObjects.Sprite} The updated Sprite. + */ +var BuildGameObjectAnimation = function (sprite, config) +{ + var animConfig = GetAdvancedValue(config, 'anims', null); + + if (animConfig === null) + { + return sprite; + } + + if (typeof animConfig === 'string') + { + // { anims: 'key' } + sprite.anims.play(animConfig); + } + else if (typeof animConfig === 'object') + { + // { anims: { + // key: string + // startFrame: [string|number] + // delay: [float] + // repeat: [integer] + // repeatDelay: [float] + // yoyo: [boolean] + // play: [boolean] + // delayedPlay: [boolean] + // } + // } + + var anims = sprite.anims; + + var key = GetAdvancedValue(animConfig, 'key', undefined); + + if (key) + { + var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); + + var delay = GetAdvancedValue(animConfig, 'delay', 0); + var repeat = GetAdvancedValue(animConfig, 'repeat', 0); + var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); + var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); + + var play = GetAdvancedValue(animConfig, 'play', false); + var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); + + var playConfig = { + key: key, + delay: delay, + repeat: repeat, + repeatDelay: repeatDelay, + yoyo: yoyo, + startFrame: startFrame + }; + + if (play) + { + anims.play(playConfig); + } + else if (delayedPlay > 0) + { + anims.playAfterDelay(playConfig, delayedPlay); + } + else + { + anims.load(playConfig); + } + } + } + + return sprite; +}; + +module.exports = BuildGameObjectAnimation; + + +/***/ }, + +/***/ 8050 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var List = __webpack_require__(73162); +var PluginCache = __webpack_require__(37277); +var GameObjectEvents = __webpack_require__(51708); +var SceneEvents = __webpack_require__(44594); +var StableSort = __webpack_require__(19186); + +/** + * @classdesc + * The Display List is a Scene plugin that maintains the ordered list of Game Objects + * to be rendered each frame. Game Objects are automatically sorted by depth before + * rendering. You do not normally interact with the Display List directly; instead use + * `addToDisplayList` and `removeFromDisplayList` on individual Game Objects. + * + * @class DisplayList + * @extends Phaser.Structs.List. + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this Display List belongs to. + */ +var DisplayList = new Class({ + + Extends: List, + + initialize: + + function DisplayList (scene) + { + List.call(this, scene); + + /** + * The flag that determines whether Game Objects should be sorted when `depthSort()` is called. + * + * @name Phaser.GameObjects.DisplayList#sortChildrenFlag + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.sortChildrenFlag = false; + + /** + * The Scene that this Display List belongs to. + * + * @name Phaser.GameObjects.DisplayList#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The Scene's Systems. + * + * @name Phaser.GameObjects.DisplayList#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * The Scene's Event Emitter. + * + * @name Phaser.GameObjects.DisplayList#events + * @type {Phaser.Events.EventEmitter} + * @since 3.50.0 + */ + this.events = scene.sys.events; + + // Set the List callbacks + this.addCallback = this.addChildCallback; + this.removeCallback = this.removeChildCallback; + + this.events.once(SceneEvents.BOOT, this.boot, this); + this.events.on(SceneEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.DisplayList#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.events.once(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * Internal method called from `List.addCallback`. + * + * @method Phaser.GameObjects.DisplayList#addChildCallback + * @private + * @fires Phaser.Scenes.Events#ADDED_TO_SCENE + * @fires Phaser.GameObjects.Events#ADDED_TO_SCENE + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was added to the list. + */ + addChildCallback: function (gameObject) + { + if (gameObject.displayList && gameObject.displayList !== this) + { + gameObject.removeFromDisplayList(); + } + + if (gameObject.parentContainer) + { + gameObject.parentContainer.remove(gameObject); + } + + if (!gameObject.displayList) + { + this.queueDepthSort(); + + gameObject.displayList = this; + + gameObject.emit(GameObjectEvents.ADDED_TO_SCENE, gameObject, this.scene); + + this.events.emit(SceneEvents.ADDED_TO_SCENE, gameObject, this.scene); + } + }, + + /** + * Internal method called from `List.removeCallback`. + * + * @method Phaser.GameObjects.DisplayList#removeChildCallback + * @private + * @fires Phaser.Scenes.Events#REMOVED_FROM_SCENE + * @fires Phaser.GameObjects.Events#REMOVED_FROM_SCENE + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was removed from the list. + */ + removeChildCallback: function (gameObject) + { + this.queueDepthSort(); + + gameObject.displayList = null; + + gameObject.emit(GameObjectEvents.REMOVED_FROM_SCENE, gameObject, this.scene); + + this.events.emit(SceneEvents.REMOVED_FROM_SCENE, gameObject, this.scene); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.DisplayList#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * Force a sort of the display list on the next call to depthSort. + * + * @method Phaser.GameObjects.DisplayList#queueDepthSort + * @since 3.0.0 + */ + queueDepthSort: function () + { + this.sortChildrenFlag = true; + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.GameObjects.DisplayList#depthSort + * @since 3.0.0 + */ + depthSort: function () + { + if (this.sortChildrenFlag) + { + StableSort(this.list, this.sortByDepth); + + this.sortChildrenFlag = false; + } + }, + + /** + * Compare the depth of two Game Objects. + * + * @method Phaser.GameObjects.DisplayList#sortByDepth + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first Game Object. + * @param {Phaser.GameObjects.GameObject} childB - The second Game Object. + * + * @return {number} The difference between the depths of each Game Object. + */ + sortByDepth: function (childA, childB) + { + return childA._depth - childB._depth; + }, + + /** + * Returns an array which contains all objects currently on the Display List. + * This is a reference to the main list array, not a copy of it, so be careful not to modify it. + * + * @method Phaser.GameObjects.DisplayList#getChildren + * @since 3.12.0 + * + * @return {Phaser.GameObjects.GameObject[]} The group members. + */ + getChildren: function () + { + return this.list; + }, + + /** + * The Scene that owns this plugin is shutting down. + * + * We need to kill and reset all internal properties as well as stop listening to Scene events. + * + * @method Phaser.GameObjects.DisplayList#shutdown + * @private + * @since 3.0.0 + */ + shutdown: function () + { + var list = this.list; + var i = list.length; + + while (i--) + { + if (list[i]) + { + list[i].destroy(true); + } + } + + list.length = 0; + + this.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Phaser.GameObjects.DisplayList#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.events.off(SceneEvents.START, this.start, this); + + this.scene = null; + this.systems = null; + this.events = null; + } + +}); + +PluginCache.register('DisplayList', DisplayList, 'displayList'); + +module.exports = DisplayList; + + +/***/ }, + +/***/ 95643 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var ComponentsToJSON = __webpack_require__(53774); +var DataManager = __webpack_require__(45893); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(51708); +var SceneEvents = __webpack_require__(44594); + +/** + * @classdesc + * The base class that all Game Objects in Phaser extend. + * + * A Game Object is anything that can be added to a Scene's display list and rendered to screen, + * such as a Sprite, Image, Text, or Graphics object. Game Objects are the building blocks of + * every Phaser game — they represent visual entities that live in a Scene, can be positioned, + * scaled, rotated, and interacted with. + * + * This class provides the core shared functionality used by all Game Objects: lifecycle management + * (active/destroy), data storage via the Data Manager, input handling, physics body attachment, + * display list and update list membership, and event emission. + * + * You do not instantiate `GameObject` directly. Instead, use it as the base class for your own + * custom Game Object types by extending it through Phaser's `Class` utility, or simply use one + * of the many built-in Game Object types provided by Phaser. + * + * @class GameObject + * @memberof Phaser.GameObjects + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Filters + * @extends Phaser.GameObjects.Components.RenderSteps + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. + */ +var GameObject = new Class({ + + Extends: EventEmitter, + + Mixins: [ + Components.Filters, + Components.RenderSteps + ], + + initialize: + + function GameObject (scene, type) + { + EventEmitter.call(this); + + /** + * A reference to the Scene to which this Game Object belongs. + * + * Game Objects can only belong to one Scene. + * + * You should consider this property as being read-only. You cannot move a + * Game Object to another Scene by simply changing it. + * + * @name Phaser.GameObjects.GameObject#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Holds a reference to the Display List that contains this Game Object. + * + * This is set automatically when this Game Object is added to a Scene or Layer. + * + * You should treat this property as being read-only. + * + * @name Phaser.GameObjects.GameObject#displayList + * @type {(Phaser.GameObjects.DisplayList|Phaser.GameObjects.Layer)} + * @default null + * @since 3.50.0 + */ + this.displayList = null; + + /** + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. + * + * @name Phaser.GameObjects.GameObject#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The current state of this Game Object. + * + * Phaser itself will never modify this value, although plugins may do so. + * + * Use this property to track the state of a Game Object during its lifetime. For example, it could change from + * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant + * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * + * @name Phaser.GameObjects.GameObject#state + * @type {(number|string)} + * @since 3.16.0 + */ + this.state = 0; + + /** + * The parent Container of this Game Object, if it has one. + * + * @name Phaser.GameObjects.GameObject#parentContainer + * @type {Phaser.GameObjects.Container} + * @since 3.4.0 + */ + this.parentContainer = null; + + /** + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.GameObject#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. + * + * @name Phaser.GameObjects.GameObject#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. + * + * @name Phaser.GameObjects.GameObject#tabIndex + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.tabIndex = -1; + + /** + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * + * @name Phaser.GameObjects.GameObject#data + * @type {Phaser.Data.DataManager} + * @default null + * @since 3.0.0 + */ + this.data = null; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + * + * @name Phaser.GameObjects.GameObject#renderFlags + * @type {number} + * @default 15 + * @since 3.0.0 + */ + this.renderFlags = 15; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id + * + * @name Phaser.GameObjects.GameObject#cameraFilter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cameraFilter = 0; + + /** + * The current vertex rounding mode of this Game Object. + * This is used by the WebGL Renderer to determine how to round the vertex positions. + * It can have several values: + * + * - `off` - No rounding is applied. + * - `safe` - Rounding is applied if the object is 'safe'. + * - `safeAuto` - Rounding is applied if the object is 'safe' and the camera has `roundPixels` enabled. + * - `full` - Rounding is always applied. + * - `fullAuto` - Rounding is always applied if the camera has `roundPixels` enabled. + * + * A 'safe' object is one that is not rotated or scaled + * by any transform matrix while rendering. + * The effective transform is a simple translation. + * In such cases, rounding will affect all vertices the same way. + * + * Using full rounding can cause vertices to wobble, because they might + * not be aligned to the pixel grid. + * Full rounding gives a janky look like PS1 games. + * + * You can use other values if you want to create your own custom rounding modes. + * + * @name Phaser.GameObjects.GameObject#vertexRoundMode + * @type {string} + * @default 'safeAuto' + * @since 4.0.0 + */ + this.vertexRoundMode = 'safeAuto'; + + /** + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. + * + * @name Phaser.GameObjects.GameObject#input + * @type {?Phaser.Types.Input.InteractiveObject} + * @default null + * @since 3.0.0 + */ + this.input = null; + + /** + * If this Game Object is enabled for Arcade or Matter Physics then this property will contain a reference to a Physics Body. + * + * @name Phaser.GameObjects.GameObject#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody|MatterJS.BodyType)} + * @default null + * @since 3.0.0 + */ + this.body = null; + + /** + * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`. + * This includes calls that may come from a Group, Container or the Scene itself. + * While it allows you to persist a Game Object across Scenes, please understand you are entirely + * responsible for managing references to and from this Game Object. + * + * @name Phaser.GameObjects.GameObject#ignoreDestroy + * @type {boolean} + * @default false + * @since 3.5.0 + */ + this.ignoreDestroy = false; + + /** + * Whether this Game Object has been destroyed. + * Check this property to avoid bugs caused by calling methods on a + * destroyed Game Object, e.g. in a Tween or Timer. + * + * This is a read-only property that is automatically set to `true` + * when the Game Object is destroyed. + * You should not set this property directly. + * It is set before `preDestroy` is called or the DESTROY event is emitted. + * + * @name Phaser.GameObjects.GameObject#isDestroyed + * @type {boolean} + * @default false + * @readonly + * @since 4.0.0 + */ + this.isDestroyed = false; + + // Initialize RenderSteps mixin. + if (this.addRenderStep) + { + this.addRenderStep(this.renderWebGL); + } + + this.on(Events.ADDED_TO_SCENE, this.addedToScene, this); + this.on(Events.REMOVED_FROM_SCENE, this.removedFromScene, this); + + // Tell the Scene to re-sort the children + scene.sys.queueDepthSort(); + }, + + /** + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * + * @method Phaser.GameObjects.GameObject#setActive + * @since 3.0.0 + * + * @param {boolean} value - True if this Game Object should be set as active, false if not. + * + * @return {this} This GameObject. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * + * @method Phaser.GameObjects.GameObject#setName + * @since 3.0.0 + * + * @param {string} value - The name to be given to this Game Object. + * + * @return {this} This GameObject. + */ + setName: function (value) + { + this.name = value; + + return this; + }, + + /** + * Sets the current state of this Game Object. + * + * Phaser itself will never modify the State of a Game Object, although plugins may do so. + * + * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. + * The state value should typically be an integer (ideally mapped to a constant + * in your game code), but could also be a string. It is recommended to keep it light and simple. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * + * @method Phaser.GameObjects.GameObject#setState + * @since 3.16.0 + * + * @param {(number|string)} value - The state of the Game Object. + * + * @return {this} This GameObject. + */ + setState: function (value) + { + this.state = value; + + return this; + }, + + /** + * Adds a Data Manager component to this Game Object. + * + * @method Phaser.GameObjects.GameObject#setDataEnabled + * @since 3.0.0 + * @see Phaser.Data.DataManager + * + * @return {this} This GameObject. + */ + setDataEnabled: function () + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this; + }, + + /** + * Allows you to store a key value pair within this Game Objects Data Manager. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.GameObjects.GameObject#setData + * @since 3.0.0 + * + * @generic {any} T + * @genericUse {(string|T)} - [key] + * + * @param {(string|object)} key - The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. + * @param {*} [value] - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {this} This GameObject. + */ + setData: function (key, value) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.set(key, value); + + return this; + }, + + /** + * Increase a value for the given key within this Game Object's Data Manager. If the key doesn't already exist in the Data Manager then it is created with a value of 0 before being increased. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * @method Phaser.GameObjects.GameObject#incData + * @since 3.23.0 + * + * @param {string} key - The key to change the value for. + * @param {number} [amount=1] - The amount to increase the given key by. Pass a negative value to decrease the key. + * + * @return {this} This GameObject. + */ + incData: function (key, amount) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.inc(key, amount); + + return this; + }, + + /** + * Toggle a boolean value for the given key within this Game Object's Data Manager. If the key doesn't already exist in the Data Manager then it is created with a value of `false` before being toggled to `true`. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * @method Phaser.GameObjects.GameObject#toggleData + * @since 3.23.0 + * + * @param {string} key - The key to toggle the value for. + * + * @return {this} This GameObject. + */ + toggleData: function (key) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.toggle(key); + + return this; + }, + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.GameObjects.GameObject#getData + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + getData: function (key) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this.data.get(key); + }, + + /** + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @example + * sprite.setInteractive(); + * + * @example + * sprite.setInteractive(new Phaser.Geom.Circle(45, 46, 45), Phaser.Geom.Circle.Contains); + * + * @example + * graphics.setInteractive(new Phaser.Geom.Rectangle(0, 0, 128, 128), Phaser.Geom.Rectangle.Contains); + * + * @method Phaser.GameObjects.GameObject#setInteractive + * @since 3.0.0 + * + * @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. + * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. + * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? + * + * @return {this} This GameObject. + */ + setInteractive: function (hitArea, hitAreaCallback, dropZone) + { + this.scene.sys.input.enable(this, hitArea, hitAreaCallback, dropZone); + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + * + * @method Phaser.GameObjects.GameObject#disableInteractive + * @since 3.7.0 + * + * @param {boolean} [resetCursor=false] - Should the currently active Input cursor, if any, be reset to the default cursor? + * + * @return {this} This GameObject. + */ + disableInteractive: function (resetCursor) + { + if (resetCursor === undefined) { resetCursor = false; } + + this.scene.sys.input.disable(this, resetCursor); + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) + * + * @method Phaser.GameObjects.GameObject#removeInteractive + * @since 3.7.0 + * + * @param {boolean} [resetCursor=false] - Should the currently active Input cursor, if any, be reset to the default cursor? + * + * @return {this} This GameObject. + */ + removeInteractive: function (resetCursor) + { + if (resetCursor === undefined) { resetCursor = false; } + + this.scene.sys.input.clear(this); + + if (resetCursor) + { + this.scene.sys.input.resetCursor(); + } + + this.input = undefined; + + return this; + }, + + /** + * This callback is invoked when this Game Object is added to a Scene. + * + * Can be overridden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to add themselves into the Update List. + * + * You can also listen for the `ADDED_TO_SCENE` event from this Game Object. + * + * @method Phaser.GameObjects.GameObject#addedToScene + * @since 3.50.0 + */ + addedToScene: function () + { + }, + + /** + * This callback is invoked when this Game Object is removed from a Scene. + * + * Can be overridden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to remove themselves from the Update List. + * + * You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object. + * + * @method Phaser.GameObjects.GameObject#removedFromScene + * @since 3.50.0 + */ + removedFromScene: function () + { + }, + + /** + * Override this method in your own custom Game Objects to perform per-frame update logic. + * This method is called by the Scene's Update List on every game frame, if the Game Object + * is on that list. It is not called automatically — the Game Object must be added to the + * Update List via `addToUpdateList` or by having a `preUpdate` method. + * + * This base implementation is intentionally empty, allowing Game Objects to be used in an + * Object Pool without requiring any update logic. + * + * @method Phaser.GameObjects.GameObject#update + * @since 3.0.0 + * + * @param {...*} [args] - Any arguments that are passed to the update method. + */ + update: function () + { + }, + + /** + * Returns a JSON representation of the Game Object. + * + * @method Phaser.GameObjects.GameObject#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + return ComponentsToJSON(this); + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.GameObject#willRender + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + var listWillRender = (this.displayList && this.displayList.active) ? this.displayList.willRender(camera) : true; + + return !(!listWillRender || GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Checks if this Game Object should round its vertices, + * based on the given Camera and the `vertexRoundMode` of this Game Object. + * This is used by the WebGL Renderer to determine how to round the vertex positions. + * + * You can override this method in your own custom Game Object classes to provide + * custom logic for vertex rounding. + * + * @method Phaser.GameObjects.GameObject#willRoundVertices + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * @param {boolean} onlyTranslated - If true, the object is only translated, not scaled or rotated. + * @return {boolean} True if the Game Object should be rounded, otherwise false. + */ + willRoundVertices: function (camera, onlyTranslated) + { + switch (this.vertexRoundMode) + { + case 'safe': + return onlyTranslated; + + case 'safeAuto': + return onlyTranslated && camera.roundPixels; + + case 'full': + return true; + + case 'fullAuto': + return camera.roundPixels; + + case 'off': + default: + return false; + } + }, + + /** + * Sets the vertex round mode of this Game Object. + * This is used by the WebGL Renderer to determine how to round the vertex positions. + * @see {@link Phaser.GameObjects.GameObject#vertexRoundMode} for more details. + * + * @method Phaser.GameObjects.GameObject#setVertexRoundMode + * @since 4.0.0 + * @param {string} mode - The vertex round mode to set. Can be 'off', 'safe', 'safeAuto', 'full' or 'fullAuto'. + * @return {this} This GameObject. + */ + setVertexRoundMode: function (mode) + { + this.vertexRoundMode = mode; + + return this; + }, + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). + * + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. + * + * @method Phaser.GameObjects.GameObject#getIndexList + * @since 3.4.0 + * + * @return {number[]} An array of display list position indexes. + */ + getIndexList: function () + { + // eslint-disable-next-line consistent-this + var child = this; + var parent = this.parentContainer; + + var indexes = []; + + while (parent) + { + indexes.unshift(parent.getIndex(child)); + + child = parent; + + if (!parent.parentContainer) + { + break; + } + else + { + parent = parent.parentContainer; + } + } + + if (this.displayList) + { + indexes.unshift(this.displayList.getIndex(child)); + } + else + { + indexes.unshift(this.scene.sys.displayList.getIndex(child)); + } + + return indexes; + }, + + /** + * Adds this Game Object to the given Display List. + * + * If no Display List is specified, it will default to the Display List owned by the Scene to which + * this Game Object belongs. + * + * A Game Object can only exist on one Display List at any given time, but may move freely between them. + * + * If this Game Object is already on another Display List when this method is called, it will first + * be removed from it, before being added to the new list. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * + * If a Game Object isn't on any display list, it will not be rendered. If you just wish to temporarily + * disable it from rendering, consider using the `setVisible` method, instead. + * + * @method Phaser.GameObjects.GameObject#addToDisplayList + * @fires Phaser.Scenes.Events#ADDED_TO_SCENE + * @fires Phaser.GameObjects.Events#ADDED_TO_SCENE + * @since 3.53.0 + * + * @param {(Phaser.GameObjects.DisplayList|Phaser.GameObjects.Layer)} [displayList] - The Display List to add to. Defaults to the Scene Display List. + * + * @return {this} This Game Object. + */ + addToDisplayList: function (displayList) + { + if (displayList === undefined) { displayList = this.scene.sys.displayList; } + + if (this.displayList && this.displayList !== displayList) + { + this.removeFromDisplayList(); + } + + // Don't repeat if it's already on this list + if (!displayList.exists(this)) + { + this.displayList = displayList; + + displayList.add(this, true); + + displayList.queueDepthSort(); + + this.emit(Events.ADDED_TO_SCENE, this, this.scene); + + displayList.events.emit(SceneEvents.ADDED_TO_SCENE, this, this.scene); + } + + return this; + }, + + /** + * Adds this Game Object to the Update List belonging to the Scene. + * + * When a Game Object is added to the Update List it will have its `preUpdate` method called + * every game frame. This method is passed two parameters: `time` and `delta`. + * + * If you wish to run your own logic within `preUpdate` then you should always call + * `super.preUpdate(time, delta)` within it, or it may fail to process required operations, + * such as Sprite animations. + * + * @method Phaser.GameObjects.GameObject#addToUpdateList + * @since 3.53.0 + * + * @return {this} This Game Object. + */ + addToUpdateList: function () + { + if (this.scene && this.preUpdate) + { + this.scene.sys.updateList.add(this); + } + + return this; + }, + + /** + * Removes this Game Object from the Display List it is currently on. + * + * A Game Object can only exist on one Display List at any given time, but may be freely removed + * and added back at a later stage. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * + * If a Game Object isn't on any Display List, it will not be rendered. If you just wish to temporarily + * disable it from rendering, consider using the `setVisible` method, instead. + * + * @method Phaser.GameObjects.GameObject#removeFromDisplayList + * @fires Phaser.Scenes.Events#REMOVED_FROM_SCENE + * @fires Phaser.GameObjects.Events#REMOVED_FROM_SCENE + * @since 3.53.0 + * + * @return {this} This Game Object. + */ + removeFromDisplayList: function () + { + var displayList = this.displayList || this.scene.sys.displayList; + + if (displayList && displayList.exists(this)) + { + displayList.remove(this, true); + + displayList.queueDepthSort(); + + this.displayList = null; + + this.emit(Events.REMOVED_FROM_SCENE, this, this.scene); + + displayList.events.emit(SceneEvents.REMOVED_FROM_SCENE, this, this.scene); + } + + return this; + }, + + /** + * Removes this Game Object from the Scene's Update List. + * + * When a Game Object is on the Update List, it will have its `preUpdate` method called + * every game frame. Calling this method will remove it from the list, preventing this. + * + * Removing a Game Object from the Update List will stop most internal functions working. + * For example, removing a Sprite from the Update List will prevent it from being able to + * run animations. + * + * @method Phaser.GameObjects.GameObject#removeFromUpdateList + * @since 3.53.0 + * + * @return {this} This Game Object. + */ + removeFromUpdateList: function () + { + if (this.scene && this.preUpdate) + { + this.scene.sys.updateList.remove(this); + } + + return this; + }, + + /** + * Returns a reference to the underlying display list _array_ that contains this Game Object, + * which will be either the Scene's Display List or the internal list belonging + * to its parent Container, if it has one. + * + * If this Game Object is not on a display list or in a container, it will return `null`. + * + * You should be very careful with this method, and understand that it returns a direct reference to the + * internal array used by the Display List. Mutating this array directly can cause all kinds of subtle + * and difficult to debug issues in your game. + * + * @method Phaser.GameObjects.GameObject#getDisplayList + * @since 3.85.0 + * + * @return {?Phaser.GameObjects.GameObject[]} The internal Display List array of Game Objects, or `null`. + */ + getDisplayList: function () + { + var list = null; + + if (this.parentContainer) + { + list = this.parentContainer.list; + } + else if (this.displayList) + { + list = this.displayList.list; + } + + return list; + }, + + /** + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * + * @method Phaser.GameObjects.GameObject#destroy + * @fires Phaser.GameObjects.Events#DESTROY + * @since 3.0.0 + * + * @param {boolean} [fromScene=false] - `True` if this Game Object is being destroyed by the Scene, `false` if not. + */ + destroy: function (fromScene) + { + // This Game Object has already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + if (fromScene === undefined) { fromScene = false; } + + this.isDestroyed = true; + + if (this.preDestroy) + { + this.preDestroy.call(this); + } + + this.emit(Events.DESTROY, this, fromScene); + + this.removeAllListeners(); + this.removeFromDisplayList(); + this.removeFromUpdateList(); + + if (this.input) + { + this.scene.sys.input.clear(this); + + this.input = undefined; + } + + if (this.data) + { + this.data.destroy(); + + this.data = undefined; + } + + if (this.body) + { + this.body.destroy(); + + this.body = undefined; + } + + if (this.filterCamera) + { + this.filterCamera.destroy(); + + this.filterCamera = undefined; + } + + this.active = false; + this.visible = false; + + this.scene = undefined; + this.parentContainer = undefined; + } + +}); + +/** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * + * @constant {number} RENDER_MASK + * @memberof Phaser.GameObjects.GameObject + * @default + */ +GameObject.RENDER_MASK = 15; + +module.exports = GameObject; + + +/***/ }, + +/***/ 44603 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); + +/** + * @classdesc + * The Game Object Creator is a Scene plugin that allows you to quickly create many common + * types of Game Objects and return them using a configuration object, rather than + * having to specify individual parameters as required by the GameObjectFactory. + * + * Game Objects made via this class are automatically added to the Scene and Update List + * unless you explicitly set the `add` property in the configuration object to `false`. + * + * @class GameObjectCreator + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Creator belongs. + */ +var GameObjectCreator = new Class({ + + initialize: + + function GameObjectCreator (scene) + { + /** + * The Scene to which this Game Object Creator belongs. + * + * @name Phaser.GameObjects.GameObjectCreator#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectCreator#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Event Emitter. + * + * @name Phaser.GameObjects.GameObjectCreator#events + * @type {Phaser.Events.EventEmitter} + * @protected + * @since 3.50.0 + */ + this.events = scene.sys.events; + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectCreator#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectCreator#updateList + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + + this.events.once(SceneEvents.BOOT, this.boot, this); + this.events.on(SceneEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectCreator#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + this.events.once(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectCreator#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + * + * @method Phaser.GameObjects.GameObjectCreator#shutdown + * @private + * @since 3.0.0 + */ + shutdown: function () + { + this.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Phaser.GameObjects.GameObjectCreator#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.events.off(SceneEvents.START, this.start, this); + + this.scene = null; + this.systems = null; + this.events = null; + + this.displayList = null; + this.updateList = null; + } + +}); + +/** + * Registers a Game Object creator function on the GameObjectCreator prototype, + * making it available for creating Game Objects via the Scene's make property. + * + * @method Phaser.GameObjects.GameObjectCreator.register + * @static + * @since 3.0.0 + * + * @param {string} factoryType - The key of the factory that you will use to call the Phaser.Scene.make[ factoryType ] method. + * @param {function} factoryFunction - The constructor function to be called when you invoke the Phaser.Scene.make method. + */ +GameObjectCreator.register = function (factoryType, factoryFunction) +{ + if (!GameObjectCreator.prototype.hasOwnProperty(factoryType)) + { + GameObjectCreator.prototype[factoryType] = factoryFunction; + } +}; + +/** + * Removes a previously registered custom Game Object Creator from the GameObjectCreator prototype, + * making it no longer available via the Scene's make property. + * + * With this method you can remove a custom Game Object Creator that has been previously + * registered in the Game Object Creator. Pass in its `factoryType` in order to remove it. + * + * @method Phaser.GameObjects.GameObjectCreator.remove + * @static + * @since 3.0.0 + * + * @param {string} factoryType - The key of the factory that you want to remove from the GameObjectCreator. + */ +GameObjectCreator.remove = function (factoryType) +{ + if (GameObjectCreator.prototype.hasOwnProperty(factoryType)) + { + delete GameObjectCreator.prototype[factoryType]; + } +}; + +PluginCache.register('GameObjectCreator', GameObjectCreator, 'make'); + +module.exports = GameObjectCreator; + + +/***/ }, + +/***/ 39429 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); + +/** + * @classdesc + * The Game Object Factory is a Scene plugin that allows you to quickly create many common + * types of Game Objects and have them automatically registered with the Scene. + * It is accessible via `this.add` from within a Scene. + * + * Game Objects directly register themselves with the Factory and inject their own creation + * methods into the class. + * + * @class GameObjectFactory + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. + */ +var GameObjectFactory = new Class({ + + initialize: + + function GameObjectFactory (scene) + { + /** + * The Scene to which this Game Object Factory belongs. + * + * @name Phaser.GameObjects.GameObjectFactory#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectFactory#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Event Emitter. + * + * @name Phaser.GameObjects.GameObjectFactory#events + * @type {Phaser.Events.EventEmitter} + * @protected + * @since 3.50.0 + */ + this.events = scene.sys.events; + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectFactory#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectFactory#updateList + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + + this.events.once(SceneEvents.BOOT, this.boot, this); + this.events.on(SceneEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectFactory#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + this.events.once(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectFactory#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * Adds an existing Game Object to this Scene. + * + * If the Game Object renders, it will be added to the Display List. + * If it has a `preUpdate` method, it will be added to the Update List. + * + * @method Phaser.GameObjects.GameObjectFactory#existing + * @since 3.0.0 + * + * @generic {(Phaser.GameObjects.GameObject|Phaser.GameObjects.Group|Phaser.GameObjects.Layer)} G - [child,$return] + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.Group|Phaser.GameObjects.Layer)} child - The child to be added to this Scene. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was added. + */ + existing: function (child) + { + if (child.renderCanvas || child.renderWebGL) + { + this.displayList.add(child); + } + + // For when custom objects have overridden `preUpdate` but don't hook into the ADDED_TO_SCENE event: + // Adding to the list multiple times is safe, as it won't add duplicates into the list anyway. + if (child.preUpdate) + { + this.updateList.add(child); + } + + return child; + }, + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + * + * @method Phaser.GameObjects.GameObjectFactory#shutdown + * @private + * @since 3.0.0 + */ + shutdown: function () + { + this.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Phaser.GameObjects.GameObjectFactory#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.events.off(SceneEvents.START, this.start, this); + + this.scene = null; + this.systems = null; + this.events = null; + + this.displayList = null; + this.updateList = null; + } + +}); + +/** + * Registers a Game Object factory function on the GameObjectFactory prototype, + * making it available for creating Game Objects via the Scene's add property. + * + * @method Phaser.GameObjects.GameObjectFactory.register + * @static + * @since 3.0.0 + * + * @param {string} factoryType - The key under which the factory will be registered, accessible as `Phaser.Scene.add[factoryType]`. + * @param {function} factoryFunction - The factory function to be called when `Phaser.Scene.add[factoryType]` is invoked. + */ +GameObjectFactory.register = function (factoryType, factoryFunction) +{ + if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) + { + GameObjectFactory.prototype[factoryType] = factoryFunction; + } +}; + +/** + * Removes a Game Object factory function from the GameObjectFactory prototype. + * + * @method Phaser.GameObjects.GameObjectFactory.remove + * @static + * @since 3.0.0 + * + * @param {string} factoryType - The key of the factory that you want to remove from the GameObjectFactory. + */ +GameObjectFactory.remove = function (factoryType) +{ + if (GameObjectFactory.prototype.hasOwnProperty(factoryType)) + { + delete GameObjectFactory.prototype[factoryType]; + } +}; + +PluginCache.register('GameObjectFactory', GameObjectFactory, 'add'); + +module.exports = GameObjectFactory; + + +/***/ }, + +/***/ 91296 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var TransformMatrix = __webpack_require__(61340); + +var camMatrix = new TransformMatrix(); +var spriteMatrix = new TransformMatrix(); +var calcMatrix = new TransformMatrix(); +var camExternalMatrix = new TransformMatrix(); + +var result = { + camera: camMatrix, + sprite: spriteMatrix, + calc: calcMatrix, + cameraExternal: camExternalMatrix +}; + +/** + * Calculates the Transform Matrix of the given Game Object and Camera, factoring in + * the parent matrix if provided. + * + * Note that the object this result contains _references_ to the Transform Matrices, + * not new instances of them. Therefore, you should use their values immediately, or + * copy them to your own matrix, as they will be replaced as soon as another Game + * Object is rendered. + * + * @function Phaser.GameObjects.GetCalcMatrix + * @memberof Phaser.GameObjects + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} src - The Game Object to calculate the transform matrix for. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera being used to render the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - The transform matrix of the parent container, if any. + * @param {boolean} [ignoreCameraPosition=false] - Should the camera's translation be ignored? This is what moves a camera around on the screen, but it should be ignored when the camera is being rendered to a framebuffer. + * + * @return {Phaser.Types.GameObjects.GetCalcMatrixResults} The results object containing the updated transform matrices. + */ +var GetCalcMatrix = function (src, camera, parentMatrix, ignoreCameraPosition) +{ + if (ignoreCameraPosition) + { + camExternalMatrix.loadIdentity(); + } + else + { + camExternalMatrix.copyFrom(camera.matrixExternal); + } + + camMatrix.copyWithScrollFactorFrom( + ignoreCameraPosition ? camera.matrix : camera.matrixCombined, + camera.scrollX, camera.scrollY, + src.scrollFactorX, src.scrollFactorY + ); + + calcMatrix.copyFrom(camMatrix); + + if (parentMatrix) + { + calcMatrix.multiply(parentMatrix); + } + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + calcMatrix.multiply(spriteMatrix); + + return result; +}; + +module.exports = GetCalcMatrix; + + +/***/ }, + +/***/ 45027 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var ProcessQueue = __webpack_require__(25774); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); + +/** + * @classdesc + * The Update List is a Scene plugin that maintains the list of Game Objects whose + * `preUpdate` method should be called every frame. Game Objects like Sprites add + * themselves to the Update List automatically so their animations are processed. + * You do not normally interact with the Update List directly; instead use + * `addToUpdateList` and `removeFromUpdateList` on individual Game Objects. + * + * @class UpdateList + * @extends Phaser.Structs.ProcessQueue. + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that the Update List belongs to. + */ +var UpdateList = new Class({ + + Extends: ProcessQueue, + + initialize: + + function UpdateList (scene) + { + ProcessQueue.call(this); + + // No duplicates in this list + this.checkQueue = true; + + /** + * The Scene that the Update List belongs to. + * + * @name Phaser.GameObjects.UpdateList#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The Scene's Systems. + * + * @name Phaser.GameObjects.UpdateList#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * The `pending` list is a selection of items which are due to be made 'active' in the next update. + * + * @name Phaser.GameObjects.UpdateList#_pending + * @type {Array.<*>} + * @private + * @default [] + * @since 3.20.0 + */ + + /** + * The `active` list is a selection of items which are considered active and should be updated. + * + * @name Phaser.GameObjects.UpdateList#_active + * @type {Array.<*>} + * @private + * @default [] + * @since 3.20.0 + */ + + /** + * The `destroy` list is a selection of items that were active and are awaiting being destroyed in the next update. + * + * @name Phaser.GameObjects.UpdateList#_destroy + * @type {Array.<*>} + * @private + * @default [] + * @since 3.20.0 + */ + + /** + * The total number of items awaiting processing. + * + * @name Phaser.GameObjects.UpdateList#_toProcess + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.UpdateList#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.UpdateList#start + * @private + * @since 3.5.0 + */ + start: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on(SceneEvents.PRE_UPDATE, this.update, this); + eventEmitter.on(SceneEvents.UPDATE, this.sceneUpdate, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The update step. + * + * Pre-updates every active Game Object in the list. + * + * @method Phaser.GameObjects.UpdateList#sceneUpdate + * @since 3.20.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time elapsed since the last frame. + */ + sceneUpdate: function (time, delta) + { + var list = this._active; + var length = list.length; + + for (var i = 0; i < length; i++) + { + var gameObject = list[i]; + + if (gameObject.active) + { + gameObject.preUpdate.call(gameObject, time, delta); + } + } + }, + + /** + * The Scene that owns this plugin is shutting down. + * + * We need to destroy all active, pending, and queued Game Objects, reset all internal properties, and stop listening to Scene events. + * + * @method Phaser.GameObjects.UpdateList#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + var i = this._active.length; + + while (i--) + { + this._active[i].destroy(true); + } + + i = this._pending.length; + + while (i--) + { + this._pending[i].destroy(true); + } + + i = this._destroy.length; + + while (i--) + { + this._destroy[i].destroy(true); + } + + this._toProcess = 0; + + this._pending = []; + this._active = []; + this._destroy = []; + + this.removeAllListeners(); + + var eventEmitter = this.systems.events; + + eventEmitter.off(SceneEvents.PRE_UPDATE, this.update, this); + eventEmitter.off(SceneEvents.UPDATE, this.sceneUpdate, this); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * + * We need to shut down and then clear all external references. + * + * @method Phaser.GameObjects.UpdateList#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.systems.events.off(SceneEvents.START, this.start, this); + + this.scene = null; + this.systems = null; + } + + /** + * Adds a new item to the Update List. + * + * The item is added to the pending list and made active in the next update. + * + * @method Phaser.GameObjects.UpdateList#add + * @since 3.0.0 + * + * @param {*} item - The item to add to the queue. + * + * @return {*} The item that was added. + */ + + /** + * Removes an item from the Update List. + * + * The item is added to the pending destroy and fully removed in the next update. + * + * @method Phaser.GameObjects.UpdateList#remove + * @since 3.0.0 + * + * @param {*} item - The item to be removed from the queue. + * + * @return {*} The item that was removed. + */ + + /** + * Removes all active items from this Update List. + * + * All the items are marked as 'pending destroy' and fully removed in the next update. + * + * @method Phaser.GameObjects.UpdateList#removeAll + * @since 3.20.0 + * + * @return {this} This Update List object. + */ + + /** + * Update this queue. First it will process any items awaiting destruction, and remove them. + * + * Then it will check to see if there are any items pending insertion, and move them to an + * active state. Finally, it will return a list of active items for further processing. + * + * @method Phaser.GameObjects.UpdateList#update + * @since 3.0.0 + * + * @return {Array.<*>} A list of active items. + */ + + /** + * Returns the current list of active items. + * + * This method returns a reference to the active list array, not a copy of it. + * Therefore, be careful to not modify this array outside of the ProcessQueue. + * + * @method Phaser.GameObjects.UpdateList#getActive + * @since 3.0.0 + * + * @return {Array.<*>} A list of active items. + */ + + /** + * The number of entries in the active list. + * + * @name Phaser.GameObjects.UpdateList#length + * @type {number} + * @readonly + * @since 3.20.0 + */ +}); + +PluginCache.register('UpdateList', UpdateList, 'updateList'); + +module.exports = UpdateList; + + +/***/ }, + +/***/ 3217 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var tempTextureData = { + frame: null, + uvSource: null +}; + +var tempTransformData = { + quad: new Float32Array(8) +}; + +/** + * Renders one character of the Bitmap Text to WebGL. + * + * @function BatchChar + * @since 3.50.0 + * @private + * + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.Renderer.WebGL.RenderNodes.SubmitterQuad} submitterNode - The Submitter Node which handles rendering the character as a quad. + * @param {Phaser.GameObjects.BitmapText} src - The BitmapText Game Object. + * @param {Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter} char - The character to render. + * @param {Phaser.Types.GameObjects.BitmapText.BitmapFontCharacterData} glyph - The character glyph. + * @param {number} offsetX - The x offset. + * @param {number} offsetY - The y offset. + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix. + * @param {object} tintData - The tint data to pass to the submitter node. + */ +var BatchChar = function (drawingContext, submitterNode, src, char, glyph, offsetX, offsetY, calcMatrix, tintData) +{ + tempTextureData.frame = src.frame; + tempTextureData.uvSource = glyph; + + var x = (char.x - src.displayOriginX) + offsetX; + var y = (char.y - src.displayOriginY) + offsetY; + + var xw = x + char.w; + var yh = y + char.h; + + var a = calcMatrix.a; + var b = calcMatrix.b; + var c = calcMatrix.c; + var d = calcMatrix.d; + var e = calcMatrix.e; + var f = calcMatrix.f; + + var tx0 = x * a + y * c + e; + var ty0 = x * b + y * d + f; + + var tx1 = x * a + yh * c + e; + var ty1 = x * b + yh * d + f; + + var tx2 = xw * a + yh * c + e; + var ty2 = xw * b + yh * d + f; + + var tx3 = xw * a + y * c + e; + var ty3 = xw * b + y * d + f; + + tempTransformData.quad[0] = tx0; + tempTransformData.quad[1] = ty0; + + tempTransformData.quad[2] = tx1; + tempTransformData.quad[3] = ty1; + + tempTransformData.quad[4] = tx2; + tempTransformData.quad[5] = ty2; + + tempTransformData.quad[6] = tx3; + tempTransformData.quad[7] = ty3; + + submitterNode.run( + drawingContext, + src, + undefined, + 0, + tempTextureData, + tempTransformData, + tintData + ); +}; + +module.exports = BatchChar; + + +/***/ }, + +/***/ 53048 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculate the full bounds, in local and world space, of a BitmapText Game Object. + * + * Returns a BitmapTextSize object that contains global and local variants of the Game Objects x and y coordinates and + * its width and height. Also includes an array of the line lengths and all word positions. + * + * The global position and size take into account the Game Object's position and scale. + * + * The local position and size just takes into account the font data. + * + * @function GetBitmapTextSize + * @since 3.0.0 + * @private + * + * @param {(Phaser.GameObjects.DynamicBitmapText|Phaser.GameObjects.BitmapText)} src - The BitmapText to calculate the bounds values for. + * @param {boolean} [round=false] - Whether to round the positions to the nearest integer. + * @param {boolean} [updateOrigin=false] - Whether to update the origin of the BitmapText after bounds calculations? + * @param {object} [out] - Object to store the results in, to save constant object creation. If not provided an empty object is returned. + * + * @return {Phaser.Types.GameObjects.BitmapText.BitmapTextSize} The calculated bounds values of the BitmapText. + */ +var GetBitmapTextSize = function (src, round, updateOrigin, out) +{ + if (updateOrigin === undefined) { updateOrigin = false; } + + if (out === undefined) + { + out = { + local: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + global: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + lines: { + shortest: 0, + longest: 0, + lengths: null, + height: 0 + }, + wrappedText: '', + words: [], + characters: [], + scaleX: 0, + scaleY: 0 + }; + + return out; + } + + var text = src.text; + var textLength = text.length; + var maxWidth = src.maxWidth; + var wordWrapCharCode = src.wordWrapCharCode; + + var bx = Number.MAX_VALUE; + var by = Number.MAX_VALUE; + var bw = 0; + var bh = 0; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var letterSpacing = src.letterSpacing; + var lineSpacing = src.lineSpacing; + + var xAdvance = 0; + var yAdvance = 0; + + var charCode = 0; + + var glyph = null; + + var align = src._align; + + var x = 0; + var y = 0; + + var scale = (src.fontSize / src.fontData.size); + var sx = scale * src.scaleX; + var sy = scale * src.scaleY; + + var lastGlyph = null; + var lastCharCode = 0; + var lineWidths = []; + var shortestLine = Number.MAX_VALUE; + var longestLine = 0; + var currentLine = 0; + var currentLineWidth = 0; + + var i; + var j; + var lines; + var words = []; + var characters = []; + var current = null; + + // Measure the width of the text + var measureTextWidth = function (text, fontData) + { + var width = 0; + + for (var i = 0; i < text.length; i++) + { + var charCode = text.charCodeAt(i); + var glyph = fontData.chars[charCode]; + + if (glyph) + { + width += glyph.xAdvance; + } + } + + return width * sx; + }; + + // Scan for breach of maxWidth and insert carriage-returns + if (maxWidth > 0) + { + // Split the text into lines + lines = text.split('\n'); + var wrappedLines = []; + + // Loop through each line + for (i = 0; i < lines.length; i++) + { + var line = lines[i]; + var word = ''; + var wrappedLine = ''; + var lineToCheck = ''; + var lineWithWord = ''; + + // Loop through each character in a line + for (j = 0; j < line.length; j++) + { + charCode = line.charCodeAt(j); + + word += line[j]; + + // White space or end of line? + if (charCode === wordWrapCharCode || j === line.length - 1) + { + lineWithWord = lineToCheck + word; + + var textWidth = measureTextWidth(lineWithWord, src.fontData); + + if (textWidth <= maxWidth) + { + lineToCheck = lineWithWord; + } + else + { + // If the current word is too long to fit on a line, wrap it + // Remove trailing word wrap char to keep text length the same + wrappedLine = wrappedLine.slice(0, -1); + wrappedLine += (wrappedLine ? '\n' : '') + lineToCheck; + lineToCheck = word; + } + + word = ''; + } + } + + wrappedLine = wrappedLine.slice(0, -1); + wrappedLine += (wrappedLine ? '\n' : '') + lineToCheck; + wrappedLines.push(wrappedLine); + } + + text = wrappedLines.join('\n'); + + out.wrappedText = text; + + textLength = text.length; + } + + var charIndex = 0; + + for (i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + if (charCode === 10) + { + if (current !== null) + { + words.push({ + word: current.word, + i: current.i, + x: current.x * sx, + y: current.y * sy, + w: current.w * sx, + h: current.h * sy + }); + + current = null; + } + + lastGlyph = null; + + lineWidths[currentLine] = currentLineWidth; + + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + currentLine++; + currentLineWidth = 0; + + xAdvance = 0; + yAdvance = (lineHeight + lineSpacing) * currentLine; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + x = xAdvance; + y = yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (bx > x) + { + bx = x; + } + + if (by > y) + { + by = y; + } + + var gw = x + glyph.xAdvance; + var gh = y + lineHeight; + + if (bw < gw) + { + bw = gw; + } + + if (bh < gh) + { + bh = gh; + } + + var charWidth = glyph.xOffset + glyph.xAdvance + ((kerningOffset !== undefined) ? kerningOffset : 0); + + if (charCode === wordWrapCharCode) + { + if (current !== null) + { + words.push({ + word: current.word, + i: current.i, + x: current.x * sx, + y: current.y * sy, + w: current.w * sx, + h: current.h * sy + }); + + current = null; + } + } + else + { + if (current === null) + { + // We're starting a new word, recording the starting index, etc + current = { word: '', i: charIndex, x: xAdvance, y: yAdvance, w: 0, h: lineHeight }; + } + + current.word = current.word.concat(text[i]); + current.w += charWidth; + } + + characters.push({ + i: charIndex, + idx: i, + char: text[i], + code: charCode, + x: (glyph.xOffset + x) * scale, + y: (glyph.yOffset + yAdvance) * scale, + w: glyph.width * scale, + h: glyph.height * scale, + t: yAdvance * scale, + r: gw * scale, + b: lineHeight * scale, + line: currentLine, + glyph: glyph + }); + + xAdvance += glyph.xAdvance + letterSpacing + ((kerningOffset !== undefined) ? kerningOffset : 0); + lastGlyph = glyph; + lastCharCode = charCode; + currentLineWidth = gw * scale; + charIndex++; + } + + // Last word + if (current !== null) + { + words.push({ + word: current.word, + i: current.i, + x: current.x * sx, + y: current.y * sy, + w: current.w * sx, + h: current.h * sy + }); + } + + lineWidths[currentLine] = currentLineWidth; + + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + // Adjust all of the character positions based on alignment + if (align > 0) + { + for (var c = 0; c < characters.length; c++) + { + var currentChar = characters[c]; + + if (align === 1) + { + var ax1 = ((longestLine - lineWidths[currentChar.line]) / 2); + + currentChar.x += ax1; + currentChar.r += ax1; + } + else if (align === 2) + { + var ax2 = (longestLine - lineWidths[currentChar.line]); + + currentChar.x += ax2; + currentChar.r += ax2; + } + } + } + + var local = out.local; + var global = out.global; + + lines = out.lines; + + local.x = bx * scale; + local.y = by * scale; + local.width = bw * scale; + local.height = bh * scale; + + global.x = (src.x - src._displayOriginX) + (bx * sx); + global.y = (src.y - src._displayOriginY) + (by * sy); + + global.width = bw * sx; + global.height = bh * sy; + + lines.shortest = shortestLine; + lines.longest = longestLine; + lines.lengths = lineWidths; + + if (round) + { + local.x = Math.ceil(local.x); + local.y = Math.ceil(local.y); + local.width = Math.ceil(local.width); + local.height = Math.ceil(local.height); + + global.x = Math.ceil(global.x); + global.y = Math.ceil(global.y); + global.width = Math.ceil(global.width); + global.height = Math.ceil(global.height); + + lines.shortest = Math.ceil(shortestLine); + lines.longest = Math.ceil(longestLine); + } + + if (updateOrigin) + { + src._displayOriginX = (src.originX * local.width); + src._displayOriginY = (src.originY * local.height); + + global.x = src.x - (src._displayOriginX * src.scaleX); + global.y = src.y - (src._displayOriginY * src.scaleY); + + if (round) + { + global.x = Math.ceil(global.x); + global.y = Math.ceil(global.y); + } + } + + out.words = words; + out.characters = characters; + out.lines.height = lineHeight; + out.scale = scale; + out.scaleX = src.scaleX; + out.scaleY = src.scaleY; + + return out; +}; + +module.exports = GetBitmapTextSize; + + +/***/ }, + +/***/ 61327 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ParseXMLBitmapFont = __webpack_require__(21859); + +/** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + * + * @function ParseFromAtlas + * @since 3.0.0 + * @private + * + * @param {Phaser.Scene} scene - The Scene to parse the Bitmap Font for. + * @param {string} fontName - The key of the font to add to the Bitmap Font cache. + * @param {string} textureKey - The key of the BitmapFont's texture. + * @param {string} frameKey - The key of the BitmapFont texture's frame. + * @param {string} xmlKey - The key of the XML data of the font to parse. + * @param {number} [xSpacing] - The x-axis spacing to add between each letter. + * @param {number} [ySpacing] - The y-axis spacing to add to the line height. + * + * @return {boolean} Whether the parsing was successful or not. + */ +var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) +{ + var texture = scene.sys.textures.get(textureKey); + var frame = texture.get(frameKey); + var xml = scene.sys.cache.xml.get(xmlKey); + + if (frame && xml) + { + var data = ParseXMLBitmapFont(xml, frame, xSpacing, ySpacing, texture); + + scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey, fromAtlas: true }); + + return true; + } + else + { + return false; + } +}; + +module.exports = ParseFromAtlas; + + +/***/ }, + +/***/ 6925 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetValue = __webpack_require__(35154); + +/** + * Parses a Retro Font configuration object and builds a `BitmapFontData` structure that can + * be passed to the BitmapText constructor to render text using a fixed-width retro font. + * + * A retro font is a texture containing a uniform grid of characters, each cell being the same + * width and height. This function reads the configuration, looks up the source texture frame, + * then iterates over every character defined in `config.chars`, calculating its pixel position + * and normalised UV coordinates within the texture. The resulting data object maps each + * character code to its own glyph entry and is suitable for registering in the Bitmap Font cache. + * + * If `config.chars` is an empty string the function returns `undefined` without producing any data. + * + * @function Phaser.GameObjects.RetroFont.Parse + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Phaser Scene. + * @param {Phaser.Types.GameObjects.BitmapText.RetroFontConfig} config - The font configuration object. + * + * @return {Phaser.Types.GameObjects.BitmapText.BitmapFontData} A parsed Bitmap Font data entry containing per-character glyph data and UV coordinates, ready for the Bitmap Font cache. + */ +var ParseRetroFont = function (scene, config) +{ + var w = config.width; + var h = config.height; + + var cx = Math.floor(w / 2); + var cy = Math.floor(h / 2); + + var letters = GetValue(config, 'chars', ''); + + if (letters === '') + { + return; + } + + var key = GetValue(config, 'image', ''); + + var frame = scene.sys.textures.getFrame(key); + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = frame.source.width; + var textureHeight = frame.source.height; + + var offsetX = GetValue(config, 'offset.x', 0); + var offsetY = GetValue(config, 'offset.y', 0); + var spacingX = GetValue(config, 'spacing.x', 0); + var spacingY = GetValue(config, 'spacing.y', 0); + var lineSpacing = GetValue(config, 'lineSpacing', 0); + + var charsPerRow = GetValue(config, 'charsPerRow', null); + + if (charsPerRow === null) + { + charsPerRow = textureWidth / w; + + if (charsPerRow > letters.length) + { + charsPerRow = letters.length; + } + } + + var x = offsetX; + var y = offsetY; + + var data = { + retroFont: true, + font: key, + size: w, + lineHeight: h + lineSpacing, + chars: {} + }; + + var r = 0; + + for (var i = 0; i < letters.length; i++) + { + var charCode = letters.charCodeAt(i); + + var u0 = (textureX + x) / textureWidth; + var v0 = 1 - (textureY + y) / textureHeight; + var u1 = (textureX + x + w) / textureWidth; + var v1 = 1 - (textureY + y + h) / textureHeight; + + data.chars[charCode] = + { + x: x, + y: y, + width: w, + height: h, + centerX: cx, + centerY: cy, + xOffset: 0, + yOffset: 0, + xAdvance: w, + data: {}, + kerning: {}, + u0: u0, + v0: v0, + u1: u1, + v1: v1 + }; + + r++; + + if (r === charsPerRow) + { + r = 0; + x = offsetX; + y += h + spacingY; + } + else + { + x += w + spacingX; + } + } + + var entry = { + data: data, + frame: null, + texture: key + }; + + return entry; +}; + +module.exports = ParseRetroFont; + + +/***/ }, + +/***/ 21859 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Read an integer value from an XML Node. + * + * @function getValue + * @since 3.0.0 + * @private + * + * @param {Node} node - The XML Node. + * @param {string} attribute - The attribute to read. + * + * @return {number} The parsed value. + */ +function getValue (node, attribute) +{ + return parseInt(node.getAttribute(attribute), 10); +} + +/** + * Parse an XML font to Bitmap Font data for the Bitmap Font cache. + * + * @function ParseXMLBitmapFont + * @since 3.0.0 + * @private + * + * @param {XMLDocument} xml - The XML Document to parse the font from. + * @param {Phaser.Textures.Frame} frame - The texture frame to take into account when creating the uv data. + * @param {number} [xSpacing=0] - The x-axis spacing to add between each letter. + * @param {number} [ySpacing=0] - The y-axis spacing to add to the line height. + * @param {Phaser.Textures.Texture} [texture] - If provided, each glyph in the Bitmap Font will be added to this texture as a frame. + * + * @return {Phaser.Types.GameObjects.BitmapText.BitmapFontData} The parsed Bitmap Font data. + */ +var ParseXMLBitmapFont = function (xml, frame, xSpacing, ySpacing, texture) +{ + if (xSpacing === undefined) { xSpacing = 0; } + if (ySpacing === undefined) { ySpacing = 0; } + + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = frame.source.width; + var textureHeight = frame.source.height; + var sourceIndex = frame.sourceIndex; + + var data = {}; + var info = xml.getElementsByTagName('info')[0]; + var common = xml.getElementsByTagName('common')[0]; + + data.font = info.getAttribute('face'); + data.size = getValue(info, 'size'); + data.lineHeight = getValue(common, 'lineHeight') + ySpacing; + data.chars = {}; + + var letters = xml.getElementsByTagName('char'); + + var adjustForTrim = (frame !== undefined && frame.trimmed); + + if (adjustForTrim) + { + var trimX = frame.data.spriteSourceSize.x; + var trimY = frame.data.spriteSourceSize.y; + } + + for (var i = 0; i < letters.length; i++) + { + var node = letters[i]; + + var charCode = getValue(node, 'id'); + var letter = String.fromCharCode(charCode); + var gx = getValue(node, 'x'); + var gy = getValue(node, 'y'); + var gw = getValue(node, 'width'); + var gh = getValue(node, 'height'); + + // Handle frame trim issues + if (adjustForTrim) + { + gx -= trimX; + gy -= trimY; + } + + var u0 = (textureX + gx) / textureWidth; + var v0 = 1 - (textureY + gy) / textureHeight; + var u1 = (textureX + gx + gw) / textureWidth; + var v1 = 1 - (textureY + gy + gh) / textureHeight; + + data.chars[charCode] = + { + x: gx, + y: gy, + width: gw, + height: gh, + centerX: Math.floor(gw / 2), + centerY: Math.floor(gh / 2), + xOffset: getValue(node, 'xoffset'), + yOffset: getValue(node, 'yoffset'), + xAdvance: getValue(node, 'xadvance') + xSpacing, + data: {}, + kerning: {}, + u0: u0, + v0: v0, + u1: u1, + v1: v1 + }; + + if (texture && gw !== 0 && gh !== 0) + { + texture.add(letter, sourceIndex, gx + frame.data.cut.x, gy + frame.data.cut.y, gw, gh); + } + } + + var kernings = xml.getElementsByTagName('kerning'); + + for (i = 0; i < kernings.length; i++) + { + var kern = kernings[i]; + + var first = getValue(kern, 'first'); + var second = getValue(kern, 'second'); + var amount = getValue(kern, 'amount'); + + data.chars[second].kerning[first] = amount; + } + + return data; +}; + +module.exports = ParseXMLBitmapFont; + + +/***/ }, + +/***/ 196 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RETRO_FONT_CONST = __webpack_require__(87662); +var Extend = __webpack_require__(79291); + +/** + * @namespace Phaser.GameObjects.RetroFont + * @since 3.6.0 + */ + +var RetroFont = { Parse: __webpack_require__(6925) }; + +// Merge in the consts +RetroFont = Extend(false, RetroFont, RETRO_FONT_CONST); + +module.exports = RetroFont; + + +/***/ }, + +/***/ 87662 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RETRO_FONT_CONST = { + + /** + * A RetroFont character set containing the full printable ASCII range (space through tilde), + * including both uppercase and lowercase letters, digits, and symbols. + * + * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET1 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET1: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', + + /** + * A RetroFont character set containing printable ASCII characters from space through uppercase Z, + * including digits and common symbols but no lowercase letters. + * + * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET2 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET2: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * A RetroFont character set containing uppercase letters followed by digits, with a trailing space. + * + * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET3 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET3: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ', + + /** + * A RetroFont character set containing uppercase letters, a space, then digits. The space + * character appears between the alphabet and the digits rather than at the end. + * + * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET4 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET4: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789', + + /** + * A RetroFont character set containing uppercase letters followed by common punctuation + * symbols and digits. Useful for fonts that include sentence punctuation such as periods, + * commas, parentheses, and question marks. + * + * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET5 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET5: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789', + + /** + * A RetroFont character set containing uppercase letters, digits, and a range of punctuation + * symbols including quotes, parentheses, and a trailing space. + * + * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.` + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET6 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET6: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' ', + + /** + * A RetroFont character set where the characters are arranged in a non-sequential, + * interleaved order. This matches the sprite layout of certain retro font sheets where + * every fifth character continues the sequence (A, G, M, S, Y, then B, H, N, T, Z, etc.). + * + * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET7 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET7: 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39', + + /** + * A RetroFont character set where digits come first, followed by a space, period, and then + * uppercase letters. Use this when the font sprite sheet places numerals before the alphabet. + * + * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET8 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET8: '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * A RetroFont character set containing uppercase letters, parentheses and a hyphen, digits, + * and common sentence punctuation including quotes and an exclamation mark. + * + * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET9 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET9: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!', + + /** + * A RetroFont character set containing only the 26 uppercase letters of the alphabet. + * Use this for font sprite sheets that contain no digits, spaces, or punctuation glyphs. + * + * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET10 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET10: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * A RetroFont character set containing uppercase letters, a broad selection of punctuation + * symbols including quotes and arithmetic operators, followed by digits. + * + * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET11 + * @since 3.6.0 + * @type {string} + */ + TEXT_SET11: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789' + +}; + +module.exports = RETRO_FONT_CONST; + + +/***/ }, + +/***/ 2638 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BitmapText = __webpack_require__(22186); +var Class = __webpack_require__(83419); +var Render = __webpack_require__(12310); + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering, each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} + * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} + * Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/} + * Littera (Flash-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} + * + * @class DynamicBitmapText + * @extends Phaser.GameObjects.BitmapText + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {number} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var DynamicBitmapText = new Class({ + + Extends: BitmapText, + + Mixins: [ + Render + ], + + initialize: + + function DynamicBitmapText (scene, x, y, font, text, size, align) + { + BitmapText.call(this, scene, x, y, font, text, size, align); + + this.type = 'DynamicBitmapText'; + + /** + * The horizontal scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * The vertical scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * The crop width of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropWidth = 0; + + /** + * The crop height of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropHeight = 0; + + /** + * A callback that alters how each character of the Bitmap Text is rendered. + * + * @name Phaser.GameObjects.DynamicBitmapText#displayCallback + * @type {Phaser.Types.GameObjects.BitmapText.DisplayCallback} + * @since 3.0.0 + */ + this.displayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. Its updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + * + * @name Phaser.GameObjects.DynamicBitmapText#callbackData + * @type {Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig} + * @since 3.11.0 + */ + this.callbackData = { + parent: this, + color: 0, + tint: { + topLeft: 0, + topRight: 0, + bottomLeft: 0, + bottomRight: 0 + }, + index: 0, + charCode: 0, + x: 0, + y: 0, + scale: 0, + rotation: 0, + data: 0 + }; + }, + + /** + * Set the crop size of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the crop. + * @param {number} height - The height of the crop. + * + * @return {this} This Game Object. + */ + setSize: function (width, height) + { + this.cropWidth = width; + this.cropHeight = height; + + return this; + }, + + /** + * Set a callback that alters how each character of the Bitmap Text is rendered. + * + * The callback receives a {@link Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig} object that contains information about the character that's + * about to be rendered. + * + * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the + * usual values when rendering. + * + * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.BitmapText.DisplayCallback} callback - The display callback to set. + * + * @return {this} This Game Object. + */ + setDisplayCallback: function (callback) + { + this.displayCallback = callback; + + return this; + }, + + /** + * Set the horizontal scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollX + * @since 3.0.0 + * + * @param {number} value - The horizontal scroll position to set. + * + * @return {this} This Game Object. + */ + setScrollX: function (value) + { + this.scrollX = value; + + return this; + }, + + /** + * Set the vertical scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollY + * @since 3.0.0 + * + * @param {number} value - The vertical scroll position to set. + * + * @return {this} This Game Object. + */ + setScrollY: function (value) + { + this.scrollY = value; + + return this; + } + +}); + +module.exports = DynamicBitmapText; + + +/***/ }, + +/***/ 86741 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicBitmapTextCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + camera.addToRenderList(src); + + var textureFrame = src.fromAtlas + ? src.frame + : src.texture.frames['__BASE']; + + var displayCallback = src.displayCallback; + var callbackData = src.callbackData; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var letterSpacing = src._letterSpacing; + + var xAdvance = 0; + var yAdvance = 0; + + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var rotation = 0; + var scale = 0; + var baseScale = (src._fontSize / src.fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + var roundPixels = camera.roundPixels; + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.beginPath(); + ctx.rect(0, 0, src.cropWidth, src.cropHeight); + ctx.clip(); + } + + for (var i = 0; i < textLength; i++) + { + // Reset the scale (in case the callback changed it) + scale = baseScale; + rotation = 0; + + charCode = text.charCodeAt(i); + + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = (glyph.xOffset + xAdvance) - src.scrollX; + y = (glyph.yOffset + yAdvance) - src.scrollY; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (displayCallback) + { + callbackData.index = i; + callbackData.charCode = charCode; + callbackData.x = x; + callbackData.y = y; + callbackData.scale = scale; + callbackData.rotation = rotation; + callbackData.data = glyph.data; + + var output = displayCallback(callbackData); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + } + + x *= scale; + y *= scale; + + x += lineOffsetX; + + xAdvance += glyph.xAdvance + letterSpacing + ((kerningOffset !== undefined) ? kerningOffset : 0); + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + if (roundPixels) + { + x = Math.round(x); + y = Math.round(y); + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.rotate(rotation); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = DynamicBitmapTextCanvasRenderer; + + +/***/ }, + +/***/ 11164 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BitmapText = __webpack_require__(2638); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); + +/** + * Creates a new Dynamic Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.BitmapText.BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetAdvancedValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 72566 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DynamicBitmapText = __webpack_require__(2638); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering, each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have fewer features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 12310 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(73482); +} + +if (true) +{ + renderCanvas = __webpack_require__(86741); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 73482 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var TintModes = __webpack_require__(84322); +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); + +var tempMatrix = new TransformMatrix(); + +var tempTextureData = { + frame: null, + uvSource: null +}; + +var tempTintData1 = { + tintEffect: TintModes.MULTIPLY, + tintTopLeft: 0, + tintTopRight: 0, + tintBottomLeft: 0, + tintBottomRight: 0 +}; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicBitmapTextWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var text = src.text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var currentContext = drawingContext; + + var submitterNode = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + var result = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas); + + var spriteMatrix = result.sprite; + var calcMatrix = result.calc; + + var fontMatrix = tempMatrix; + + var crop = (src.cropWidth > 0 || src.cropHeight > 0); + + if (crop) + { + currentContext = drawingContext.getClone(); + currentContext.setScissorEnable(true); + currentContext.setScissorBox( + calcMatrix.tx, + calcMatrix.ty, + src.cropWidth * calcMatrix.scaleX, + src.cropHeight * calcMatrix.scaleY + ); + currentContext.use(); + } + + tempTextureData.frame = src.frame; + + var tintMode = TintModes.MULTIPLY; + var tintTL = Utils.getTintAppendFloatAlpha(src.tintTopLeft, src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src.tintTopRight, src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src.tintBottomLeft, src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src.tintBottomRight, src._alphaBR); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src.letterSpacing; + var glyph; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + var scrollX = src.scrollX; + var scrollY = src.scrollY; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src.fontSize / fontData.size); + var rotation = 0; + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + var bounds = src.getTextBounds(false); + + // In case the method above changed it (word wrapping) + if (src.maxWidth > 0) + { + text = bounds.wrappedText; + textLength = text.length; + } + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var displayCallback = src.displayCallback; + var callbackData = src.callbackData; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + tempTextureData.uvSource = glyph; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = (glyph.xOffset + xAdvance) - scrollX; + var y = (glyph.yOffset + yAdvance) - scrollY; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode] || 0; + x += kerningOffset; + xAdvance += kerningOffset; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + if (displayCallback) + { + callbackData.color = 0; + callbackData.tintMode = tintMode; + callbackData.tint.topLeft = tintTL; + callbackData.tint.topRight = tintTR; + callbackData.tint.bottomLeft = tintBL; + callbackData.tint.bottomRight = tintBR; + callbackData.index = i; + callbackData.charCode = charCode; + callbackData.x = x; + callbackData.y = y; + callbackData.scale = scale; + callbackData.rotation = rotation; + callbackData.data = glyph.data; + + var output = displayCallback(callbackData); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + + if (output.color) + { + tintTL = output.color; + tintTR = output.color; + tintBL = output.color; + tintBR = output.color; + } + else + { + tintTL = output.tint.topLeft; + tintTR = output.tint.topRight; + tintBL = output.tint.bottomLeft; + tintBR = output.tint.bottomRight; + } + + tintMode = output.tintMode; + tintTL = Utils.getTintAppendFloatAlpha(tintTL, src._alphaTL); + tintTR = Utils.getTintAppendFloatAlpha(tintTR, src._alphaTR); + tintBL = Utils.getTintAppendFloatAlpha(tintBL, src._alphaBL); + tintBR = Utils.getTintAppendFloatAlpha(tintBR, src._alphaBR); + } + + tempTintData1.tintEffect = tintMode; + tempTintData1.tintTopLeft = tintTL; + tempTintData1.tintTopRight = tintTR; + tempTintData1.tintBottomLeft = tintBL; + tempTintData1.tintBottomRight = tintBR; + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + fontMatrix.applyITRS(x, y, rotation, scale, scale); + + calcMatrix.multiply(fontMatrix, spriteMatrix); + + var xw = glyphW; + var yh = glyphH; + + var tx0 = spriteMatrix.e; + var ty0 = spriteMatrix.f; + + var tx1 = yh * spriteMatrix.c + spriteMatrix.e; + var ty1 = yh * spriteMatrix.d + spriteMatrix.f; + + var tx2 = xw * spriteMatrix.a + yh * spriteMatrix.c + spriteMatrix.e; + var ty2 = xw * spriteMatrix.b + yh * spriteMatrix.d + spriteMatrix.f; + + var tx3 = xw * spriteMatrix.a + spriteMatrix.e; + var ty3 = xw * spriteMatrix.b + spriteMatrix.f; + + submitterNode.run( + currentContext, + src, + undefined, + 0, + tempTextureData, + { + quad: [ tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3 ] + }, + tempTintData1 + ); + } + + if (crop) + { + drawingContext.use(); + } +}; + +module.exports = DynamicBitmapTextWebGLRenderer; + + +/***/ }, + +/***/ 22186 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DefaultBitmapTextNodes = __webpack_require__(70972); +var Class = __webpack_require__(83419); +var Clamp = __webpack_require__(45319); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var GetBitmapTextSize = __webpack_require__(53048); +var ParseFromAtlas = __webpack_require__(61327); +var ParseXMLBitmapFont = __webpack_require__(21859); +var Rectangle = __webpack_require__(87841); +var Render = __webpack_require__(18658); +var TintModes = __webpack_require__(84322); + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} + * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} + * Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/} + * Littera (Flash-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} + * + * @class BitmapText + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {number} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var BitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.GetBounds, + Components.Lighting, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function BitmapText (scene, x, y, font, text, size, align) + { + if (text === undefined) { text = ''; } + if (align === undefined) { align = 0; } + + GameObject.call(this, scene, 'BitmapText'); + + /** + * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. + * + * @name Phaser.GameObjects.BitmapText#font + * @type {string} + * @readonly + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + if (!entry) + { + console.warn('Invalid BitmapText key: ' + font); + } + + /** + * The data of the Bitmap Font used by this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#fontData + * @type {Phaser.Types.GameObjects.BitmapText.BitmapFontData} + * @readonly + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * The text that this Bitmap Text object displays. + * + * @name Phaser.GameObjects.BitmapText#_text + * @type {string} + * @private + * @since 3.0.0 + */ + this._text = ''; + + /** + * The font size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_fontSize + * @type {number} + * @private + * @since 3.0.0 + */ + this._fontSize = size || this.fontData.size; + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * @name Phaser.GameObjects.BitmapText#_letterSpacing + * @type {number} + * @private + * @since 3.4.0 + */ + this._letterSpacing = 0; + + /** + * Adds / Removes line spacing in a multiline BitmapText object. + * + * Can be a negative or positive number. + * + * @name Phaser.GameObjects.BitmapText#_lineSpacing + * @type {number} + * @private + * @since 3.60.0 + */ + this._lineSpacing = 0; + + /** + * Controls the alignment of each line of text in this BitmapText object. + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#_align + * @type {number} + * @private + * @since 3.11.0 + */ + this._align = align; + + /** + * An object that describes the size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_bounds + * @type {Phaser.Types.GameObjects.BitmapText.BitmapTextSize} + * @private + * @since 3.0.0 + */ + this._bounds = GetBitmapTextSize(); + + /** + * An internal dirty flag for bounds calculation. + * + * @name Phaser.GameObjects.BitmapText#_dirty + * @type {boolean} + * @private + * @since 3.11.0 + */ + this._dirty = true; + + /** + * Internal cache var holding the maxWidth. + * + * @name Phaser.GameObjects.BitmapText#_maxWidth + * @type {number} + * @private + * @since 3.21.0 + */ + this._maxWidth = 0; + + /** + * The character code used to detect for word wrapping. + * Defaults to 32 (a space character). + * + * @name Phaser.GameObjects.BitmapText#wordWrapCharCode + * @type {number} + * @since 3.21.0 + */ + this.wordWrapCharCode = 32; + + /** + * Internal array holding the character tint color data. + * + * @name Phaser.GameObjects.BitmapText#charColors + * @type {array} + * @private + * @since 3.50.0 + */ + this.charColors = []; + + /** + * The horizontal offset of the drop shadow. + * + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. + * + * @name Phaser.GameObjects.BitmapText#dropShadowX + * @type {number} + * @since 3.50.0 + */ + this.dropShadowX = 0; + + /** + * The vertical offset of the drop shadow. + * + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. + * + * @name Phaser.GameObjects.BitmapText#dropShadowY + * @type {number} + * @since 3.50.0 + */ + this.dropShadowY = 0; + + /** + * The color of the drop shadow. + * + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. + * + * @name Phaser.GameObjects.BitmapText#dropShadowColor + * @type {number} + * @since 3.50.0 + */ + this.dropShadowColor = 0x000000; + + /** + * The alpha value of the drop shadow. + * + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. + * + * @name Phaser.GameObjects.BitmapText#dropShadowAlpha + * @type {number} + * @since 3.50.0 + */ + this.dropShadowAlpha = 0.5; + + /** + * Indicates whether the font texture is from an atlas or not. + * + * @name Phaser.GameObjects.BitmapText#fromAtlas + * @type {boolean} + * @since 3.54.0 + * @readonly + */ + this.fromAtlas = entry.fromAtlas; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initRenderNodes(this._defaultRenderNodesMap); + + this.setText(text); + }, + + /** + * The default render nodes to initialize. + * + * @name Phaser.GameObjects.BitmapText#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultBitmapTextNodes; + } + }, + + /** + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setLeftAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setLeftAlign: function () + { + this._align = BitmapText.ALIGN_LEFT; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setCenterAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setCenterAlign: function () + { + this._align = BitmapText.ALIGN_CENTER; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setRightAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setRightAlign: function () + { + this._align = BitmapText.ALIGN_RIGHT; + + this._dirty = true; + + return this; + }, + + /** + * Set the font size of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - The font size to set. + * + * @return {this} This BitmapText Object. + */ + setFontSize: function (size) + { + this._fontSize = size; + + this._dirty = true; + + return this; + }, + + /** + * Sets the letter spacing between each character of this Bitmap Text. + * Can be a positive value to increase the space, or negative to reduce it. + * Spacing is applied after the kerning values have been set. + * + * @method Phaser.GameObjects.BitmapText#setLetterSpacing + * @since 3.4.0 + * + * @param {number} [spacing=0] - The amount of horizontal space to add between each character. + * + * @return {this} This BitmapText Object. + */ + setLetterSpacing: function (spacing) + { + if (spacing === undefined) { spacing = 0; } + + this._letterSpacing = spacing; + + this._dirty = true; + + return this; + }, + + /** + * Sets the line spacing value. This value is added to the font height to + * calculate the overall line height. + * + * Spacing can be a negative or positive number. + * + * Only has an effect if this BitmapText object contains multiple lines of text. + * + * @method Phaser.GameObjects.BitmapText#setLineSpacing + * @since 3.60.0 + * + * @param {number} [spacing=0] - The amount of space to add between each line in multi-line text. + * + * @return {this} This BitmapText Object. + */ + setLineSpacing: function (spacing) + { + if (spacing === undefined) { spacing = 0; } + + this.lineSpacing = spacing; + + return this; + }, + + /** + * Set the textual content of this BitmapText. + * + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. + * + * @method Phaser.GameObjects.BitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {this} This BitmapText Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this._text = value.toString(); + + this._dirty = true; + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * Sets a drop shadow effect on this Bitmap Text. + * + * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * + * You can set the vertical and horizontal offset of the shadow, as well as the color and alpha. + * + * Once a shadow has been enabled you can modify the `dropShadowX` and `dropShadowY` properties of this + * Bitmap Text directly to adjust the position of the shadow in real-time. + * + * If you wish to clear the shadow, call this method with no parameters specified. + * + * @method Phaser.GameObjects.BitmapText#setDropShadow + * @webglOnly + * @since 3.50.0 + * + * @param {number} [x=0] - The horizontal offset of the drop shadow. + * @param {number} [y=0] - The vertical offset of the drop shadow. + * @param {number} [color=0x000000] - The color of the drop shadow, given as a hex value, i.e. `0x000000` for black. + * @param {number} [alpha=0.5] - The alpha of the drop shadow, given as a float between 0 and 1. This is combined with the Bitmap Text alpha as well. + * + * @return {this} This BitmapText Object. + */ + setDropShadow: function (x, y, color, alpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (color === undefined) { color = 0x000000; } + if (alpha === undefined) { alpha = 0.5; } + + this.dropShadowX = x; + this.dropShadowY = y; + this.dropShadowColor = color; + this.dropShadowAlpha = alpha; + + return this; + }, + + /** + * Sets a tint on a range of characters in this Bitmap Text, starting from the `start` parameter index + * and running for `length` quantity of characters. + * + * The `start` parameter can be negative. In this case, it starts at the end of the text and counts + * backwards `start` places. + * + * You can also pass in -1 as the `length` and it will tint all characters from `start` + * up until the end of the string. + + * Remember that spaces and punctuation count as characters. + * + * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * + * The tint applies a color to the pixel color values + * from the Bitmap Text texture in one of several modes: + * + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * + * You can provide either one color value, + * in which case the whole character will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the character range. + * + * To modify the tint color once set, call this method again with new color values. + * + * Using `setWordTint` can override tints set by this function, and vice versa. + * + * To remove a tint call this method with just the `start`, and optionally, the `length` parameters defined. + * + * @method Phaser.GameObjects.BitmapText#setCharacterTint + * @webglOnly + * @since 3.50.0 + * + * @param {number} [start=0] - The starting character to begin the tint at. If negative, it counts back from the end of the text. + * @param {number} [length=1] - The number of characters to tint. Remember that spaces count as a character too. Pass -1 to tint all characters from `start` onwards. + * @param {number} [tintMode=Phaser.TintModes.MULTIPLY] - The tint mode to use. + * @param {number} [topLeft=0xffffff] - The tint being applied to the top-left of the character. If no other values are given this value is applied evenly, tinting the whole character. + * @param {number} [topRight] - The tint being applied to the top-right of the character. + * @param {number} [bottomLeft] - The tint being applied to the bottom-left of the character. + * @param {number} [bottomRight] - The tint being applied to the bottom-right of the character. + * + * @return {this} This BitmapText Object. + */ + setCharacterTint: function (start, length, tintMode, topLeft, topRight, bottomLeft, bottomRight) + { + if (start === undefined) { start = 0; } + if (length === undefined) { length = 1; } + if (tintMode === undefined) { tintMode = TintModes.MULTIPLY; } + if (topLeft === undefined) { topLeft = -1; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + var len = this.text.length; + + if (length === -1) + { + length = len; + } + + if (start < 0) + { + start = len + start; + } + + start = Clamp(start, 0, len - 1); + + var end = Clamp(start + length, start, len); + + var charColors = this.charColors; + + for (var i = start; i < end; i++) + { + var color = charColors[i]; + + if (topLeft === -1) + { + charColors[i] = null; + } + else + { + var tintEffect = tintMode; + + if (color) + { + color.tintEffect = tintEffect; + color.tintTL = topLeft; + color.tintTR = topRight; + color.tintBL = bottomLeft; + color.tintBR = bottomRight; + } + else + { + charColors[i] = { + tintEffect: tintEffect, + tintTL: topLeft, + tintTR: topRight, + tintBL: bottomLeft, + tintBR: bottomRight + }; + } + } + } + + return this; + }, + + /** + * Sets a tint on a matching word within this Bitmap Text. + * + * The `word` parameter can be either a string or a number. + * + * If a string, it will run a string comparison against the text contents, and if matching, + * it will tint the whole word. + * + * If a number, it will tint that word, based on its index within the words array. + * + * The `count` parameter controls how many words are replaced. Pass in -1 to replace them all. + * + * This parameter is ignored if you pass a number as the `word` to be searched for. + * + * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * + * The tint applies a color to the pixel color values + * from the Bitmap Text texture in one of several modes: + * + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * + * You can provide either one color value, + * in which case the whole character will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the character range. + * + * To modify the tint color once set, call this method again with new color values. + * + * Using `setCharacterTint` can override tints set by this function, and vice versa. + * + * @method Phaser.GameObjects.BitmapText#setWordTint + * @webglOnly + * @since 3.50.0 + * + * @param {(string|number)} word - The word to search for. Either a string, or an index of the word in the words array. + * @param {number} [count=1] - The number of matching words to tint. Pass -1 to tint all matching words. + * @param {number} [tintMode=Phaser.TintModes.MULTIPLY] - The tint mode to use. + * @param {number} [topLeft=0xffffff] - The tint being applied to the top-left of the word. If no other values are given this value is applied evenly, tinting the whole word. + * @param {number} [topRight] - The tint being applied to the top-right of the word. + * @param {number} [bottomLeft] - The tint being applied to the bottom-left of the word. + * @param {number} [bottomRight] - The tint being applied to the bottom-right of the word. + * + * @return {this} This BitmapText Object. + */ + setWordTint: function (word, count, tintMode, topLeft, topRight, bottomLeft, bottomRight) + { + if (count === undefined) { count = 1; } + + var bounds = this.getTextBounds(); + + var words = bounds.words; + + var wordIsNumber = (typeof(word) === 'number'); + + var total = 0; + + for (var i = 0; i < words.length; i++) + { + var lineword = words[i]; + + if ((wordIsNumber && i === word) || (!wordIsNumber && lineword.word === word)) + { + this.setCharacterTint(lineword.i, lineword.word.length, tintMode, topLeft, topRight, bottomLeft, bottomRight); + + total++; + + if (total === count) + { + return this; + } + } + } + + return this; + }, + + /** + * Calculate the bounds of this Bitmap Text. + * + * An object is returned that contains the position, width and height of the Bitmap Text in local and global + * contexts. + * + * Local size is based on just the font size and a [0, 0] position. + * + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. + * + * @method Phaser.GameObjects.BitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} [round=false] - Whether to round the results up to the nearest integer. + * + * @return {Phaser.Types.GameObjects.BitmapText.BitmapTextSize} An object that describes the size of this Bitmap Text. + */ + getTextBounds: function (round) + { + // local = The BitmapText based on fontSize and 0x0 coords + // global = The BitmapText, taking into account scale and world position + // lines = The BitmapText line data + + var bounds = this._bounds; + + if (this._dirty || round || this.scaleX !== bounds.scaleX || this.scaleY !== bounds.scaleY) + { + GetBitmapTextSize(this, round, true, bounds); + + this._dirty = false; + } + + return bounds; + }, + + /** + * Gets the character located at the given x/y coordinate within this Bitmap Text. + * + * The coordinates you pass in are translated into the local space of the + * Bitmap Text, however, it is up to you to first translate the input coordinates to world space. + * + * If you wish to use this in combination with an input event, be sure + * to pass in `Pointer.worldX` and `worldY` so they are in world space. + * + * In some cases, based on kerning, characters can overlap. When this happens, + * the first character in the word is returned. + * + * Note that this does not work for DynamicBitmapText if you have changed the + * character positions during render. It will only scan characters in their un-translated state. + * + * @method Phaser.GameObjects.BitmapText#getCharacterAt + * @since 3.50.0 + * + * @param {number} x - The x position to check. + * @param {number} y - The y position to check. + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera which is being tested against. If not given will use the Scene default camera. + * + * @return {Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter} The character object at the given position, or `null`. + */ + getCharacterAt: function (x, y, camera) + { + var point = this.getLocalPoint(x, y, null, camera); + + var bounds = this.getTextBounds(); + + var chars = bounds.characters; + + var tempRect = new Rectangle(); + + for (var i = 0; i < chars.length; i++) + { + var char = chars[i]; + + tempRect.setTo(char.x, char.t, char.r - char.x, char.b); + + if (tempRect.contains(point.x, point.y)) + { + return char; + } + } + + return null; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.BitmapText#updateDisplayOrigin + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._dirty = true; + + this.getTextBounds(false); + + return this; + }, + + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing text, size and alignment are preserved, + * unless overridden via the arguments. + * + * @method Phaser.GameObjects.BitmapText#setFont + * @since 3.11.0 + * + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {number} [size] - The font size of this Bitmap Text. If not specified the current size will be used. + * @param {number} [align=0] - The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. + * + * @return {this} This BitmapText Object. + */ + setFont: function (key, size, align) + { + if (size === undefined) { size = this._fontSize; } + if (align === undefined) { align = this._align; } + + var entry = this.scene.sys.cache.bitmapFont.get(key); + + if (entry) + { + this.font = key; + this.fontData = entry.data; + this._fontSize = size; + this._align = align; + this.fromAtlas = entry.fromAtlas === true; + + this.setTexture(entry.texture, entry.frame); + + GetBitmapTextSize(this, false, true, this._bounds); + } + + return this; + }, + + /** + * Sets the maximum display width of this BitmapText in pixels. + * + * If `BitmapText.text` is longer than `maxWidth` then the lines will be automatically wrapped + * based on the previous whitespace character found in the line. + * + * If no whitespace was found then no wrapping will take place and consequently the `maxWidth` value will not be honored. + * + * Disable maxWidth by setting the value to 0. + * + * You can set the whitespace character to be searched for by setting the `wordWrapCharCode` parameter or property. + * + * @method Phaser.GameObjects.BitmapText#setMaxWidth + * @since 3.21.0 + * + * @param {number} value - The maximum display width of this BitmapText in pixels. Set to zero to disable. + * @param {number} [wordWrapCharCode] - The character code to check for when word wrapping. Defaults to 32 (the space character). + * + * @return {this} This BitmapText Object. + */ + setMaxWidth: function (value, wordWrapCharCode) + { + this._maxWidth = value; + + this._dirty = true; + + if (wordWrapCharCode !== undefined) + { + this.wordWrapCharCode = wordWrapCharCode; + } + + return this; + }, + + /** + * Sets the display size of this BitmapText Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.BitmapText#setDisplaySize + * @since 3.61.0 + * + * @param {number} width - The width of this BitmapText Game Object. + * @param {number} height - The height of this BitmapText Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (displayWidth, displayHeight) + { + this.setScale(1, 1); + + this.getTextBounds(false); + + var scaleX = displayWidth / this.width; + + var scaleY = displayHeight / this.height; + + this.setScale(scaleX, scaleY); + + return this; + }, + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#align + * @type {number} + * @since 3.11.0 + */ + align: { + + set: function (value) + { + this._align = value; + this._dirty = true; + }, + + get: function () + { + return this._align; + } + + }, + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + * + * @name Phaser.GameObjects.BitmapText#text + * @type {string} + * @since 3.0.0 + */ + text: { + + set: function (value) + { + this.setText(value); + }, + + get: function () + { + return this._text; + } + + }, + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + * + * @name Phaser.GameObjects.BitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + fontSize: { + + set: function (value) + { + this._fontSize = value; + this._dirty = true; + }, + + get: function () + { + return this._fontSize; + } + + }, + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + * + * @name Phaser.GameObjects.BitmapText#letterSpacing + * @type {number} + * @since 3.0.0 + */ + letterSpacing: { + + set: function (value) + { + this._letterSpacing = value; + this._dirty = true; + }, + + get: function () + { + return this._letterSpacing; + } + + }, + + /** + * Adds / Removes spacing between lines. + * + * Can be a negative or positive number. + * + * You can also use the method `setLineSpacing` if you want a chainable way to change the line spacing. + * + * @name Phaser.GameObjects.BitmapText#lineSpacing + * @type {number} + * @since 3.60.0 + */ + lineSpacing: { + + set: function (value) + { + this._lineSpacing = value; + this._dirty = true; + }, + + get: function () + { + return this._lineSpacing; + } + + }, + + /** + * The maximum display width of this BitmapText in pixels. + * + * If BitmapText.text is longer than maxWidth then the lines will be automatically wrapped + * based on the last whitespace character found in the line. + * + * If no whitespace was found then no wrapping will take place and consequently the maxWidth value will not be honored. + * + * Disable maxWidth by setting the value to 0. + * + * @name Phaser.GameObjects.BitmapText#maxWidth + * @type {number} + * @since 3.21.0 + */ + maxWidth: { + + set: function (value) + { + this._maxWidth = value; + this._dirty = true; + }, + + get: function () + { + return this._maxWidth; + } + + }, + + /** + * The width of this Bitmap Text. + * + * This property is read-only. + * + * @name Phaser.GameObjects.BitmapText#width + * @type {number} + * @readonly + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.width; + } + + }, + + /** + * The height of this Bitmap Text. + * + * This property is read-only. + * + * @name Phaser.GameObjects.BitmapText#height + * @type {number} + * @readonly + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.height; + } + + }, + + /** + * The displayed width of this Bitmap Text. + * + * This value takes into account the scale factor. + * + * This property is read-only. + * + * @name Phaser.GameObjects.BitmapText#displayWidth + * @type {number} + * @readonly + * @since 3.60.0 + */ + displayWidth: { + + set: function(value) + { + this.setScaleX(1); + + this.getTextBounds(false); + + var scale = value / this.width; + + this.setScaleX(scale); + }, + + get: function () + { + return this.width; + } + + }, + + /** + * The displayed height of this Bitmap Text. + * + * This value takes into account the scale factor. + * + * This property is read-only. + * + * @name Phaser.GameObjects.BitmapText#displayHeight + * @type {number} + * @readonly + * @since 3.60.0 + */ + displayHeight: { + + set: function(value) + { + this.setScaleY(1); + + this.getTextBounds(false); + + var scale = value / this.height; + + this.setScaleY(scale); + }, + + get: function () + { + return this.height; + } + + }, + + /** + * Build a JSON representation of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.BitmapText.JSONBitmapText} A JSON representation of this Bitmap Text. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize, + letterSpacing: this.letterSpacing, + lineSpacing: this.lineSpacing, + align: this.align + }; + + out.data = data; + + return out; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.BitmapText#preDestroy + * @protected + * @since 3.50.0 + */ + preDestroy: function () + { + this.charColors.length = 0; + this._bounds = null; + this.fontData = null; + } + +}); + +/** + * Left align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_LEFT + * @type {number} + * @since 3.11.0 + */ +BitmapText.ALIGN_LEFT = 0; + +/** + * Center align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_CENTER + * @type {number} + * @since 3.11.0 + */ +BitmapText.ALIGN_CENTER = 1; + +/** + * Right align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_RIGHT + * @type {number} + * @since 3.11.0 + */ +BitmapText.ALIGN_RIGHT = 2; + +/** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + * + * @method Phaser.GameObjects.BitmapText.ParseFromAtlas + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to parse the Bitmap Font for. + * @param {string} fontName - The key of the font to add to the Bitmap Font cache. + * @param {string} textureKey - The key of the BitmapFont's texture. + * @param {string} frameKey - The key of the BitmapFont texture's frame. + * @param {string} xmlKey - The key of the XML data of the font to parse. + * @param {number} [xSpacing] - The x-axis spacing to add between each letter. + * @param {number} [ySpacing] - The y-axis spacing to add to the line height. + * + * @return {boolean} Whether the parsing was successful or not. + */ +BitmapText.ParseFromAtlas = ParseFromAtlas; + +/** + * Parse an XML font to Bitmap Font data for the Bitmap Font cache. + * + * @method Phaser.GameObjects.BitmapText.ParseXMLBitmapFont + * @since 3.17.0 + * + * @param {XMLDocument} xml - The XML Document to parse the font from. + * @param {Phaser.Textures.Frame} frame - The texture frame to take into account when creating the uv data. + * @param {number} [xSpacing=0] - The x-axis spacing to add between each letter. + * @param {number} [ySpacing=0] - The y-axis spacing to add to the line height. + * + * @return {Phaser.Types.GameObjects.BitmapText.BitmapFontData} The parsed Bitmap Font data. + */ +BitmapText.ParseXMLBitmapFont = ParseXMLBitmapFont; + +module.exports = BitmapText; + + +/***/ }, + +/***/ 37289 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + camera.addToRenderList(src); + + var textureFrame = src.fromAtlas + ? src.frame + : src.texture.frames['__BASE']; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var letterSpacing = src._letterSpacing; + var lineSpacing = src._lineSpacing; + + var xAdvance = 0; + var yAdvance = 0; + + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var image = textureFrame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var scale = (src._fontSize / src.fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + var bounds = src.getTextBounds(false); + + // In case the method above changed it (word wrapping) + if (src.maxWidth > 0) + { + text = bounds.wrappedText; + textLength = text.length; + } + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight + lineSpacing; + + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + x *= scale; + y *= scale; + + x += lineOffsetX; + + xAdvance += glyph.xAdvance + letterSpacing + ((kerningOffset !== undefined) ? kerningOffset : 0); + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + if (roundPixels) + { + x = Math.round(x); + y = Math.round(y); + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = BitmapTextCanvasRenderer; + + +/***/ }, + +/***/ 57336 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BitmapText = __webpack_require__(22186); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); + +/** + * Creates a new Bitmap Text Game Object and returns it. + * + * BitmapText objects work by taking a pre-rendered font texture and then stamping out each character + * of the text from that texture. This makes rendering very fast compared to using a Canvas-based font, + * but it means the font must be created in advance and stored as a texture atlas. Use this method via + * `scene.make.bitmapText()` when you need high-performance static text rendering in your game. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#bitmapText + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.BitmapText.BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectCreator.register('bitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + var align = GetValue(config, 'align', 0); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 34914 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BitmapText = __webpack_require__(22186); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering, each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have fewer features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#bitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * @param {number} [align=0] - The alignment of the text in a multi-line BitmapText object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectFactory.register('bitmapText', function (x, y, font, text, size, align) +{ + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size, align)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 18658 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(33590); +} + +if (true) +{ + renderCanvas = __webpack_require__(37289); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 33590 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BatchChar = __webpack_require__(3217); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); + +var tempTintData1 = { + tintEffect: 0, + tintTopLeft: 0, + tintTopRight: 0, + tintBottomLeft: 0, + tintBottomRight: 0 +}; + +var tempTintData2 = { + tintEffect: 0, + tintTopLeft: 0, + tintTopRight: 0, + tintBottomLeft: 0, + tintBottomRight: 0 +}; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var submitterNode = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var charColors = src.charColors; + + var getTint = Utils.getTintAppendFloatAlpha; + + tempTintData1.tintEffect = src.tintMode; + tempTintData1.tintTopLeft = getTint(src.tintTopLeft, src._alphaTL); + tempTintData1.tintTopRight = getTint(src.tintTopRight, src._alphaTR); + tempTintData1.tintBottomLeft = getTint(src.tintBottomLeft, src._alphaBL); + tempTintData1.tintBottomRight = getTint(src.tintBottomRight, src._alphaBR); + + // Update the bounds - skipped internally if not dirty + var bounds = src.getTextBounds(false); + + var i; + var char; + var glyph; + + var characters = bounds.characters; + + var dropShadowX = src.dropShadowX; + var dropShadowY = src.dropShadowY; + + var dropShadow = (dropShadowX !== 0 || dropShadowY !== 0); + + if (dropShadow) + { + var srcShadowColor = src.dropShadowColor; + var srcShadowAlpha = src.dropShadowAlpha; + + tempTintData2.tintEffect = 1; + tempTintData2.tintTopLeft = getTint(srcShadowColor, srcShadowAlpha * src._alphaTL); + tempTintData2.tintTopRight = getTint(srcShadowColor, srcShadowAlpha * src._alphaTR); + tempTintData2.tintBottomLeft = getTint(srcShadowColor, srcShadowAlpha * src._alphaBL); + tempTintData2.tintBottomRight = getTint(srcShadowColor, srcShadowAlpha * src._alphaBR); + + for (i = 0; i < characters.length; i++) + { + char = characters[i]; + glyph = char.glyph; + + if (char.code === 32 || glyph.width === 0 || glyph.height === 0) + { + continue; + } + + BatchChar(drawingContext, submitterNode, src, char, glyph, dropShadowX, dropShadowY, calcMatrix, tempTintData2); + } + } + + for (i = 0; i < characters.length; i++) + { + char = characters[i]; + glyph = char.glyph; + + if (char.code === 32 || glyph.width === 0 || glyph.height === 0) + { + continue; + } + + if (charColors[char.i]) + { + var color = charColors[char.i]; + + tempTintData2.tintEffect = color.tintEffect; + tempTintData2.tintTopLeft = getTint(color.tintTL, src._alphaTL); + tempTintData2.tintTopRight = getTint(color.tintTR, src._alphaTR); + tempTintData2.tintBottomLeft = getTint(color.tintBL, src._alphaBL); + tempTintData2.tintBottomRight = getTint(color.tintBR, src._alphaBR); + + BatchChar(drawingContext, submitterNode, src, char, glyph, 0, 0, calcMatrix, tempTintData2); + } + else + { + BatchChar(drawingContext, submitterNode, src, char, glyph, 0, 0, calcMatrix, tempTintData1); + } + } +}; + +module.exports = BitmapTextWebGLRenderer; + + +/***/ }, + +/***/ 6107 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BlitterRender = __webpack_require__(48011); +var Bob = __webpack_require__(46590); +var DefaultBlitterNodes = __webpack_require__(98682); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Frame = __webpack_require__(4327); +var GameObject = __webpack_require__(95643); +var List = __webpack_require__(73162); + +/** + * @callback CreateCallback + * + * @param {Phaser.GameObjects.Bob} bob - The Bob that was created by the Blitter. + * @param {number} index - The position of the Bob within the Blitter display list. + */ + +/** + * @classdesc + * A Blitter Game Object. + * + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. + * + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. + * + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. + * + * @class Blitter + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. + * @param {(string|number)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. + */ +var Blitter = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Lighting, + Components.Mask, + Components.RenderNodes, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + BlitterRender + ], + + initialize: + + function Blitter (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Blitter'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.initRenderNodes(this._defaultRenderNodesMap); + + /** + * The children of this Blitter. + * This List contains all of the Bob objects created by the Blitter. + * + * @name Phaser.GameObjects.Blitter#children + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.children = new List(); + + /** + * A transient array that holds all of the Bobs that will be rendered this frame. + * The array is re-populated whenever the dirty flag is set. + * + * @name Phaser.GameObjects.Blitter#renderList + * @type {Phaser.GameObjects.Bob[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.renderList = []; + + /** + * Is the Blitter considered dirty? + * A 'dirty' Blitter has had its child count changed since the last frame. + * + * @name Phaser.GameObjects.Blitter#dirty + * @type {boolean} + * @since 3.0.0 + */ + this.dirty = false; + }, + + /** + * The default render nodes to use for this Game Object. + * + * @name Phaser.GameObjects.Blitter#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultBlitterNodes; + } + }, + + /** + * Creates a new Bob in this Blitter. + * + * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. + * A Bob can use any frame belonging to the texture bound to the Blitter. + * + * @method Phaser.GameObjects.Blitter#create + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|number|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * @param {number} [index] - The position in the Blitter's Display List to add the new Bob at. Defaults to the top of the list. + * + * @return {Phaser.GameObjects.Bob} The newly created Bob object. + */ + create: function (x, y, frame, visible, index) + { + if (visible === undefined) { visible = true; } + if (index === undefined) { index = this.children.length; } + + if (frame === undefined) + { + frame = this.frame; + } + else if (!(frame instanceof Frame)) + { + frame = this.texture.get(frame); + } + + var bob = new Bob(this, x, y, frame, visible); + + this.children.addAt(bob, index, false); + + this.dirty = true; + + return bob; + }, + + /** + * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. + * + * @method Phaser.GameObjects.Blitter#createFromCallback + * @since 3.0.0 + * + * @param {CreateCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param {number} quantity - The quantity of Bob objects to create. + * @param {(string|number|Phaser.Textures.Frame|string[]|number[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Bob[]} An array of Bob objects that were created. + */ + createFromCallback: function (callback, quantity, frame, visible) + { + var bobs = this.createMultiple(quantity, frame, visible); + + for (var i = 0; i < bobs.length; i++) + { + var bob = bobs[i]; + + callback.call(this, bob, i); + } + + return bobs; + }, + + /** + * Creates multiple Bobs in one call. + * + * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. + * + * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first + * frame and 10 with the second. + * + * @method Phaser.GameObjects.Blitter#createMultiple + * @since 3.0.0 + * + * @param {number} quantity - The quantity of Bob objects to create. + * @param {(string|number|Phaser.Textures.Frame|string[]|number[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Bob[]} An array of Bob objects that were created. + */ + createMultiple: function (quantity, frame, visible) + { + if (frame === undefined) { frame = this.frame.name; } + if (visible === undefined) { visible = true; } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + + var bobs = []; + var _this = this; + + frame.forEach(function (singleFrame) + { + for (var i = 0; i < quantity; i++) + { + bobs.push(_this.create(0, 0, singleFrame, visible)); + } + }); + + return bobs; + }, + + /** + * Checks if the given child can render or not, by checking its `visible` and `alpha` values. + * + * @method Phaser.GameObjects.Blitter#childCanRender + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Bob} child - The Bob to check for rendering. + * + * @return {boolean} Returns `true` if the given child can render, otherwise `false`. + */ + childCanRender: function (child) + { + return (child.visible && child.alpha > 0); + }, + + /** + * Returns an array of Bobs to be rendered. + * If the Blitter is dirty then a new list is generated and stored in `renderList`. + * + * @method Phaser.GameObjects.Blitter#getRenderList + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Bob[]} An array of Bob objects that will be rendered this frame. + */ + getRenderList: function () + { + if (this.dirty) + { + this.renderList = this.children.list.filter(this.childCanRender, this); + this.dirty = false; + } + + return this.renderList; + }, + + /** + * Removes all Bobs from the children List and marks the Blitter as dirty. + * + * @method Phaser.GameObjects.Blitter#clear + * @since 3.0.0 + * + * @param {boolean} [destroyBobs=false] - Should the Bobs be destroyed as well? If `false` they will just be removed from the Blitter. + */ + clear: function (destroyBobs) + { + if (destroyBobs) + { + var children = this.children.list; + var i = children.length; + + while (i--) + { + children[i].destroy(); + } + } + else + { + this.children.removeAll(); + } + + this.dirty = true; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Blitter#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.clear(true); + + this.children.destroy(); + + this.renderList = []; + } + +}); + +module.exports = Blitter; + + +/***/ }, + +/***/ 72396 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + var list = src.getRenderList(); + + if (list.length === 0) + { + return; + } + + var ctx = renderer.currentContext; + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + camera.addToRenderList(src); + + // Blend Mode + Scale Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + + ctx.imageSmoothingEnabled = !src.frame.source.scaleMode; + + var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; + var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; + + ctx.save(); + + if (parentMatrix) + { + parentMatrix.copyToContext(ctx); + } + + var roundPixels = camera.roundPixels; + + // Render bobs + for (var i = 0; i < list.length; i++) + { + var bob = list[i]; + var flip = (bob.flipX || bob.flipY); + var frame = bob.frame; + var cd = frame.canvasData; + var dx = frame.x; + var dy = frame.y; + var fx = 1; + var fy = 1; + + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + ctx.globalAlpha = bobAlpha; + + if (!flip) + { + if (roundPixels) + { + dx = Math.round(dx); + dy = Math.round(dy); + } + + if (cd.width > 0 && cd.height > 0) + { + ctx.drawImage( + frame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + dx + bob.x + cameraScrollX, + dy + bob.y + cameraScrollY, + cd.width, + cd.height + ); + } + } + else + { + if (bob.flipX) + { + fx = -1; + dx -= cd.width; + } + + if (bob.flipY) + { + fy = -1; + dy -= cd.height; + } + + if (cd.width > 0 && cd.height > 0) + { + ctx.save(); + ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); + ctx.scale(fx, fy); + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, dx, dy, cd.width, cd.height); + ctx.restore(); + } + } + } + + ctx.restore(); +}; + +module.exports = BlitterCanvasRenderer; + + +/***/ }, + +/***/ 9403 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Blitter = __webpack_require__(6107); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); + +/** + * Creates a new Blitter Game Object and returns it. + * + * A Blitter is a highly efficient Game Object for rendering large numbers of Bob objects, all of which + * share the same texture. Unlike using individual Game Objects, a Blitter batches all of its Bobs into + * a single draw call, making it ideal for particle-like effects, crowds, bullet pools, or any scenario + * where you need many instances of the same image rendered with minimal overhead. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#blitter + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} config - The configuration object this Game Object will use to create itself. The `key` property identifies the texture to use, and the optional `frame` property identifies a specific frame within that texture. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectCreator.register('blitter', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var blitter = new Blitter(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, blitter, config); + + return blitter; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 12709 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Blitter = __webpack_require__(6107); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Blitter Game Object and adds it to the Scene. + * + * A Blitter is a special, highly optimized Game Object designed for rendering large numbers of + * identical or similar images with minimal overhead. Rather than creating individual Game Objects + * for each image, a Blitter manages a collection of lightweight `Bob` objects, all sharing the + * same texture. This makes it ideal for particle-like effects, crowds, bullet patterns, or any + * scenario where you need to display many copies of the same sprite at high performance. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#blitter + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - The default Frame children of the Blitter will use. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectFactory.register('blitter', function (x, y, texture, frame) +{ + return this.displayList.add(new Blitter(this.scene, x, y, texture, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 48011 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(99485); +} + +if (true) +{ + renderCanvas = __webpack_require__(72396); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 99485 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); + +var tempMatrix = new TransformMatrix(); +var tempTransformer = { + quad: new Float32Array(8) +}; +var tempTexturer = {}; +var tempTinter = {}; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var list = src.getRenderList(); + var camera = drawingContext.camera; + var alpha = src.alpha; + + if (list.length === 0 || alpha === 0) + { + // Nothing to see, so abort early + return; + } + + camera.addToRenderList(src); + + var calcMatrix = tempMatrix.copyWithScrollFactorFrom( + camera.getViewMatrix(!drawingContext.useCanvas), + camera.scrollX, camera.scrollY, + src.scrollFactorX, src.scrollFactorY + ); + + if (parentMatrix) + { + calcMatrix.multiply(parentMatrix); + } + + var blitterX = src.x; + var blitterY = src.y; + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + for (var i = 0; i < list.length; i++) + { + var bob = list[i]; + var frame = bob.frame; + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + var width = frame.width; + var height = frame.height; + + var x = blitterX + bob.x + frame.x; + var y = blitterY + bob.y + frame.y; + + if (bob.flipX) + { + width *= -1; + x += frame.width; + } + + if (bob.flipY) + { + height *= -1; + y += frame.height; + } + + calcMatrix.setQuad(x, y, x + width, y + height, tempTransformer.quad); + + tempTexturer.frame = frame; + tempTexturer.uvSource = frame; + + var tint = Utils.getTintAppendFloatAlpha(bob.tint, bobAlpha); + + tempTinter.tintTopLeft = tint; + tempTinter.tintBottomLeft = tint; + tempTinter.tintTopRight = tint; + tempTinter.tintBottomRight = tint; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext, + src, + parentMatrix, + 0, + tempTexturer, + tempTransformer, + tempTinter, + + // Optional normal map parameters. + undefined, + 0 + ); + } +}; + +module.exports = BlitterWebGLRenderer; + + +/***/ }, + +/***/ 46590 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Frame = __webpack_require__(4327); + +/** + * @classdesc + * A Bob Game Object. + * + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + * + * @class Bob + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. + * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param {(string|number)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param {boolean} visible - Should the Bob render visible or not to start with? + */ +var Bob = new Class({ + + initialize: + + function Bob (blitter, x, y, frame, visible) + { + /** + * The Blitter object that this Bob belongs to. + * + * @name Phaser.GameObjects.Bob#parent + * @type {Phaser.GameObjects.Blitter} + * @since 3.0.0 + */ + this.parent = blitter; + + /** + * The x position of this Bob, relative to the x position of the Blitter. + * + * @name Phaser.GameObjects.Bob#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of this Bob, relative to the y position of the Blitter. + * + * @name Phaser.GameObjects.Bob#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The frame that the Bob uses to render with. + * To change the frame use the `Bob.setFrame` method. + * + * @name Phaser.GameObjects.Bob#frame + * @type {Phaser.Textures.Frame} + * @protected + * @since 3.0.0 + */ + this.frame = frame; + + /** + * A blank object which can be used to store data related to this Bob in. + * + * @name Phaser.GameObjects.Bob#data + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.data = {}; + + /** + * The tint value of this Bob. + * + * @name Phaser.GameObjects.Bob#tint + * @type {number} + * @default 0xffffff + * @since 3.20.0 + */ + this.tint = 0xffffff; + + /** + * The visible state of this Bob. + * + * @name Phaser.GameObjects.Bob#_visible + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._visible = visible; + + /** + * The alpha value of this Bob. + * + * @name Phaser.GameObjects.Bob#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._alpha = 1; + + /** + * The horizontally flipped state of the Bob. + * A Bob that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Bob#flipX + * @type {boolean} + * @since 3.0.0 + */ + this.flipX = false; + + /** + * The vertically flipped state of the Bob. + * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Bob#flipY + * @type {boolean} + * @since 3.0.0 + */ + this.flipY = false; + + /** + * Private read-only property used to allow Bobs to have physics bodies. + * + * @name Phaser.GameObjects.Bob#hasTransformComponent + * @type {boolean} + * @private + * @readonly + * @since 3.60.0 + */ + this.hasTransformComponent = true; + }, + + /** + * Changes the Texture Frame being used by this Bob. + * The frame must be part of the Texture the parent Blitter is using. + * If no value is given it will use the default frame of the Blitter parent. + * + * @method Phaser.GameObjects.Bob#setFrame + * @since 3.0.0 + * + * @param {(string|number|Phaser.Textures.Frame)} [frame] - The frame to be used during rendering. + * + * @return {this} This Bob Game Object. + */ + setFrame: function (frame) + { + if (frame === undefined) + { + this.frame = this.parent.frame; + } + else if (frame instanceof Frame && frame.texture === this.parent.texture) + { + this.frame = frame; + } + else + { + this.frame = this.parent.texture.get(frame); + } + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + * + * @method Phaser.GameObjects.Bob#resetFlip + * @since 3.0.0 + * + * @return {this} This Bob Game Object. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + }, + + /** + * Resets this Bob. + * + * Changes the position to the values given, and optionally changes the frame. + * + * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. + * + * @method Phaser.GameObjects.Bob#reset + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinates are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinates are relative to the position of the Blitter object. + * @param {(string|number|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * + * @return {this} This Bob Game Object. + */ + reset: function (x, y, frame) + { + this.x = x; + this.y = y; + + this.flipX = false; + this.flipY = false; + + this._alpha = 1; + this._visible = true; + + this.parent.dirty = true; + + if (frame) + { + this.setFrame(frame); + } + + return this; + }, + + /** + * Changes the position of this Bob to the values given. + * + * @method Phaser.GameObjects.Bob#setPosition + * @since 3.20.0 + * + * @param {number} x - The x position of the Bob. Bob coordinates are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinates are relative to the position of the Blitter object. + * + * @return {this} This Bob Game Object. + */ + setPosition: function (x, y) + { + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Bob. + * + * @method Phaser.GameObjects.Bob#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Bob Game Object. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Bob#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Bob Game Object. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Bob#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The vertical flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Bob Game Object. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Sets the visibility of this Bob. + * + * An invisible Bob will skip rendering. + * + * @method Phaser.GameObjects.Bob#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {this} This Bob Game Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * A Bob with alpha 0 will skip rendering. + * + * @method Phaser.GameObjects.Bob#setAlpha + * @since 3.0.0 + * + * @param {number} value - The alpha value used for this Bob. Between 0 and 1. + * + * @return {this} This Bob Game Object. + */ + setAlpha: function (value) + { + this.alpha = value; + + return this; + }, + + /** + * Sets the tint color applied to this Bob when it is rendered. The tint is a hex color value + * that is multiplied with the Bob's texture, allowing you to colorize it without needing a + * separate texture. A value of `0xffffff` (white) applies no tint. A value of `0xff0000` will + * tint the Bob red. + * + * @method Phaser.GameObjects.Bob#setTint + * @since 3.20.0 + * + * @param {number} value - The tint value used for this Bob. Between 0 and 0xffffff. + * + * @return {this} This Bob Game Object. + */ + setTint: function (value) + { + this.tint = value; + + return this; + }, + + /** + * Destroys this Bob instance. + * Removes itself from the Blitter and clears the parent, frame and data properties. + * + * @method Phaser.GameObjects.Bob#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent.dirty = true; + + this.parent.children.remove(this); + + this.parent = undefined; + this.frame = undefined; + this.data = undefined; + }, + + /** + * The visible state of the Bob. + * + * An invisible Bob will skip rendering. + * + * @name Phaser.GameObjects.Bob#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this.parent.dirty |= (this._visible !== value); + this._visible = value; + } + + }, + + /** + * The alpha value of the Bob, between 0 and 1. + * + * A Bob with alpha 0 will skip rendering. + * + * @name Phaser.GameObjects.Bob#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + this.parent.dirty |= ((this._alpha > 0) !== (value > 0)); + this._alpha = value; + } + + } + +}); + +module.exports = Bob; + + +/***/ }, + +/***/ 43451 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DrawingContext = __webpack_require__(87774); +var DefaultQuadNodes = __webpack_require__(30529); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var CaptureFrameRender = __webpack_require__(36683); + +/** + * @classdesc + * A CaptureFrame is a special type of GameObject that allows you to + * capture the current state of the render. + * For example, if you place a CaptureFrame between two other objects, + * it will capture the first object to a texture, but not the second. + * This is useful for full-scene post-processing prior to render completion, + * such as a layer of water. + * + * This is a WebGL only feature and is not available in Canvas mode. + * + * You must activate the `forceComposite` property of the Camera, + * or otherwise use this object within a framebuffer, to use this feature. + * Examples of framebuffer situations include Filters, DynamicTexture, + * and a camera with alpha between 0 and 1. + * + * This object does not render anything. It simply captures a texture + * from the current framebuffer at the moment it 'renders'. + * If you add filters to this object, it will capture the clear, temporary + * framebuffer used for the filter, not the main framebuffer. + * If you add filters to a Container that contains this object, + * it will capture only objects within that Container. + * If you set `visible` to `false`, it will just stop capturing. + * + * @example + * // Within a Scene's `create` method: + * + * // This image will be captured: + * var image1 = this.add.image(0, 0, 'image1'); + * + * // Enable framebuffer usage: + * this.cameras.main.setForceComposite(true); + * + * // Set up a CaptureFrame: + * var captureFrame = this.add.captureFrame('myCaptureFrame'); + * + * // This image will not be captured, and can display the captured image: + * var image2 = this.add.image(0, 0, 'myCaptureFrame'); + * // Add filters to image2 to distort the captured image. + * + * @class CaptureFrame + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 4.0.0 + * @webglOnly + * + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this CaptureFrame belongs. + * @param {string} key - The key of the texture to create from this CaptureFrame. + */ +var CaptureFrame = new Class({ + Extends: GameObject, + + Mixins: [ + Components.BlendMode, + Components.Depth, + Components.RenderNodes, + Components.Visible, + CaptureFrameRender + ], + + initialize: function CaptureFrame (scene, key) + { + GameObject.call(this, scene, 'CaptureFrame'); + + var renderer = scene.renderer; + + /** + * The drawing context of this CaptureFrame. + * This contains the WebGL framebuffer and texture data. + * + * @name Phaser.GameObjects.CaptureFrame#drawingContext + * @type {Phaser.Renderer.WebGL.DrawingContext} + * @webglOnly + * @since 4.0.0 + */ + this.drawingContext = new DrawingContext(renderer, { + width: renderer.width, + height: renderer.height + }); + + /** + * A texture containing the captured frame. + * This is updated when the GameObject renders. + * + * @name Phaser.GameObjects.CaptureFrame#captureTexture + * @type {Phaser.Textures.Texture} + * @webglOnly + * @since 4.0.0 + */ + this.captureTexture = scene.sys.textures.addGLTexture(key, this.drawingContext.texture); + + this.initRenderNodes(this._defaultRenderNodesMap); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.CaptureFrame#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultQuadNodes; + } + }, + + /** + * Set the alpha value of this CaptureFrame. + * This has no effect and is only present for compatibility with other Game Objects. + * + * @method Phaser.GameObjects.CaptureFrame#setAlpha + * @since 4.0.0 + * @webglOnly + * @param {number} alpha - The alpha value (not used). + * @return {this} This Game Object instance, for method chaining. + */ + setAlpha: function (alpha) + { + return this; + }, + + /** + * Set the scroll factor of this CaptureFrame. + * This has no effect and is only present for compatibility with other Game Objects. + * + * @method Phaser.GameObjects.CaptureFrame#setScrollFactor + * @since 4.0.0 + * @webglOnly + * @param {number} x - The horizontal scroll factor (not used). + * @param {number} y - The vertical scroll factor (not used). + * @return {this} This Game Object instance, for method chaining. + */ + setScrollFactor: function (x, y) + { + return this; + } +}); + +module.exports = CaptureFrame; + + +/***/ }, + +/***/ 23675 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var CaptureFrame = __webpack_require__(43451); + +/** + * Creates a new CaptureFrame Game Object and returns it. + * + * A CaptureFrame is a special Game Object that captures the current state of the WebGL framebuffer + * at the point it is rendered in the display list. Objects rendered before it are captured to a + * named texture; objects rendered after it are not. This is useful for full-scene post-processing + * effects such as a layer of water or a distortion overlay. The captured texture can then be + * referenced by key and used on other Game Objects or filters. + * + * This is a WebGL-only feature and has no effect in Canvas mode. The Camera must have + * `forceComposite` enabled, or the CaptureFrame must be used within a framebuffer context + * (such as a Filter, DynamicTexture, or a Camera with alpha between 0 and 1). + * + * Note: This method will only be available if the CaptureFrame Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#captureFrame + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.GameObjectConfig} config - The configuration object this Game Object will use to create itself. CaptureFrame only uses the `key`, `visible`, `depth`, and `add` properties. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.CaptureFrame} The Game Object that was created. + */ +GameObjectCreator.register('captureFrame', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var depth = GetAdvancedValue(config, 'depth', 0); + var key = GetAdvancedValue(config, 'key', null); + var visible = GetAdvancedValue(config, 'visible', true); + + var captureFrame = new CaptureFrame(this.scene, key); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + // This method does not use BuildGameObject, because most of the properties + // are not settable on a CaptureFrame, and it doesn't render. + captureFrame + .setDepth(depth) + .setVisible(visible); + if (config.add) + { + this.scene.sys.displayList.add(captureFrame); + } + + return captureFrame; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 20421 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CaptureFrame = __webpack_require__(43451); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new CaptureFrame Game Object and adds it to the Scene. + * + * A CaptureFrame captures the current state of the WebGL framebuffer at the point it is rendered + * in the display list, storing the result as a texture identified by the given key. Other Game Objects + * can then reference this key to display or process the captured image. This is useful for + * full-scene post-processing effects such as water reflections or screen-space distortions. + * + * This is a WebGL only feature and will not work in Canvas mode. The Camera must have + * `forceComposite` enabled, or the CaptureFrame must be rendered within a framebuffer context + * (such as a Filter, DynamicTexture, or a Camera with a non-default alpha value). + * + * Note: This method will only be available if the CaptureFrame Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#captureFrame + * @since 4.0.0 + * + * @param {string} key - The key under which the captured texture will be stored. Other Game Objects can use this key to reference the captured frame. + * + * @return {Phaser.GameObjects.CaptureFrame} The Game Object that was created. + */ +GameObjectFactory.register('captureFrame', function (key) +{ + return this.displayList.add(new CaptureFrame(this.scene, key)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 36683 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(82237); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 82237 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var _warned = false; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.CaptureFrame#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.CaptureFrame} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + */ +var CaptureFrameWebGLRenderer = function (renderer, src, drawingContext) +{ + if (drawingContext.useCanvas) + { + // We can't derive a texture from the canvas. + + if (!_warned) + { + _warned = true; + console.warn('CaptureFrame: Cannot capture from main canvas. Activate `forceComposite` on the camera to use this feature. This warning will now mute.'); + } + + return; + } + + drawingContext.camera.addToRenderList(src); + + var width = drawingContext.width; + var height = drawingContext.height; + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + // Ensure capture drawing context is the same size as the current drawing context. + src.drawingContext.resize(width, height); + + src.drawingContext.use(); + + // Draw current FBO to capture frame. + (customRenderNodes.BatchHandler || defaultRenderNodes.BatchHandler).batch( + src.drawingContext, + + // Texture. + drawingContext.texture, + + // Transformed quad in order TL, BL, TR, BR. + 0, height, + 0, 0, + width, height, + width, 0, + + // Texture coordinates in X, Y, Width, Height. + 0, 0, + 1, 1, + + // Tint color: + false, + + // Tint colors in order TL, BL, TR, BR. + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + + // Render options: + {} + ); + + src.drawingContext.release(); +}; + +module.exports = CaptureFrameWebGLRenderer; + + +/***/ }, + +/***/ 16005 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + +/** + * Provides methods and properties for managing the alpha (opacity) of a Game Object. + * Alpha values range from 0 (fully transparent) to 1 (fully opaque). + * + * Under WebGL, alpha can be set independently for each of the four corners of the + * Game Object, allowing gradient transparency effects. Under Canvas, only a single + * global alpha value is used. + * + * This component is designed to be applied as a mixin to Game Objects and should + * not be used directly. + * + * @namespace Phaser.GameObjects.Components.Alpha + * @since 3.0.0 + */ + +var Alpha = { + + /** + * Private internal value. Holds the global alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alpha: 1, + + /** + * Private internal value. Holds the top-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTL: 1, + + /** + * Private internal value. Holds the top-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTR: 1, + + /** + * Private internal value. Holds the bottom-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBL: 1, + + /** + * Private internal value. Holds the bottom-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBR: 1, + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha + * @since 3.0.0 + * + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {this} This Game Object instance. + */ + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 1; } + + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) + { + this.alpha = topLeft; + } + else + { + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); + } + + return this; + }, + + /** + * The alpha value of the Game Object, between 0 (fully transparent) and 1 (fully opaque). + * + * This is a global value that impacts the entire Game Object. Setting it also updates + * all four corner alpha values (`alphaTopLeft`, `alphaTopRight`, `alphaBottomLeft`, + * `alphaBottomRight`) to the same value. The input is clamped to the range [0, 1]. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopRight: { + + get: function () + { + return this._alphaTR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + } + +}; + +module.exports = Alpha; + + +/***/ }, + +/***/ 88509 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + +/** + * Provides methods used for setting the alpha property of a Game Object. + * Unlike the full Alpha component, which supports individual alpha values for each corner + * of a Game Object, this component applies a single uniform alpha across the whole object. + * Should be applied as a mixin and not used directly. + * + * @namespace Phaser.GameObjects.Components.AlphaSingle + * @since 3.22.0 + */ + +var AlphaSingle = { + + /** + * Private internal value. Holds the global alpha value. + * + * @name Phaser.GameObjects.Components.AlphaSingle#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alpha: 1, + + /** + * Clears the alpha value associated with this Game Object. + * + * Immediately sets the alpha back to 1 (fully opaque). + * + * @method Phaser.GameObjects.Components.AlphaSingle#clearAlpha + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.GameObjects.Components.AlphaSingle#setAlpha + * @since 3.0.0 + * + * @param {number} [value=1] - The alpha value applied across the whole Game Object. + * + * @return {this} This Game Object instance. + */ + setAlpha: function (value) + { + if (value === undefined) { value = 1; } + + this.alpha = value; + + return this; + }, + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + * The value is clamped to the range [0, 1]. Setting alpha to 0 also clears the render + * flag, preventing the Game Object from being drawn until the alpha is raised above 0 again. + * + * @name Phaser.GameObjects.Components.AlphaSingle#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + } + +}; + +module.exports = AlphaSingle; + + +/***/ }, + +/***/ 90065 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BlendModes = __webpack_require__(10312); + +/** + * Provides methods used for setting the blend mode of a Game Object. + * Blend modes control how a Game Object is composited onto the display when rendered. + * They determine how the pixels of the object are blended with the pixels already on screen, + * enabling effects such as additive lighting, screen blending, and erasing. + * + * This component is designed to be applied as a mixin to Game Objects and should not be + * used directly. Any Game Object that mixes in this component gains the `blendMode` property + * and the `setBlendMode` method. + * + * @namespace Phaser.GameObjects.Components.BlendMode + * @since 3.0.0 + */ + +var BlendMode = { + + /** + * Private internal value. Holds the current blend mode. + * + * @name Phaser.GameObjects.Components.BlendMode#_blendMode + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency with which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(Phaser.BlendModes|string|number)} + * @since 3.0.0 + */ + blendMode: { + + get: function () + { + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= -1) + { + this._blendMode = value; + } + } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency with which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|Phaser.BlendModes|number)} value - The BlendMode value. Either a string, a CONST or a number. + * + * @return {this} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; + } + +}; + +module.exports = BlendMode; + + +/***/ }, + +/***/ 94215 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods used for calculating and setting the size of a non-Frame based Game Object. + * A non-Frame based Game Object is one that derives its dimensions from internal logic rather + * than from a texture frame, such as Graphics, Text, or BitmapText objects. + * + * The component exposes `width` and `height` as the native (un-scaled) dimensions, and + * `displayWidth` and `displayHeight` as the rendered dimensions after the scale factor is applied. + * + * Should be applied as a mixin and not used directly. + * + * @namespace Phaser.GameObjects.Components.ComputedSize + * @since 3.0.0 + */ + +var ComputedSize = { + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.ComputedSize#setSize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the `scaleX` and `scaleY` properties so that the Game Object + * is rendered at the specified pixel dimensions. It is the equivalent of setting the scale + * manually, but expressed in pixels rather than as a multiplier. + * + * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = ComputedSize; + + +/***/ }, + +/***/ 61683 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Crop component provides the ability to crop the texture frame of a Game Object during rendering. + * + * It is applied as a mixin to Game Objects such as Sprite and Image, adding the `setCrop` method and + * related properties. Cropping limits the visible rectangular region of a texture frame without altering + * the Game Object's size, position, physics body, or hit area — only the rendered output is affected. + * The crop region is always relative to the texture frame's top-left origin and is automatically scaled + * to account for the Game Object's scale. + * + * @namespace Phaser.GameObjects.Components.Crop + * @since 3.12.0 + */ + +var Crop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.Crop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates cannot exceed the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.Crop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} [width] - The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param {number} [height] - The height of the crop rectangle in pixels. Cannot exceed the Frame height. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.Crop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = Crop; + + +/***/ }, + +/***/ 89272 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @namespace Phaser.GameObjects.Components.Depth + * @since 3.0.0 + */ + +var ArrayUtils = __webpack_require__(37105); + +var Depth = { + + /** + * Private internal value. Holds the depth of the Game Object. + * + * @name Phaser.GameObjects.Components.Depth#_depth + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _depth: 0, + + /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + if (this.displayList) + { + this.displayList.queueDepthSort(); + } + + this._depth = value; + } + + }, + + /** + * Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * A Game Object with a higher depth value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {number} value - The depth of this Game Object. Ensure this value is only ever a number data-type. + * + * @return {this} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + }, + + /** + * Sets this Game Object to be at the top of the display list, or the top of its parent container. + * + * Being at the top means it will render on top of everything else. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. + * + * @method Phaser.GameObjects.Components.Depth#setToTop + * @since 3.85.0 + * + * @return {this} This Game Object instance. + */ + setToTop: function () + { + var list = this.getDisplayList(); + + if (list) + { + ArrayUtils.BringToTop(list, this); + } + + return this; + }, + + /** + * Sets this Game Object to the back of the display list, or the back of its parent container. + * + * Being at the back means it will render below everything else. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. + * + * @method Phaser.GameObjects.Components.Depth#setToBack + * @since 3.85.0 + * + * @return {this} This Game Object instance. + */ + setToBack: function () + { + var list = this.getDisplayList(); + + if (list) + { + ArrayUtils.SendToBack(list, this); + } + + return this; + }, + + /** + * Move this Game Object so that it appears above the given Game Object. + * + * This means it will render immediately after the other object in the display list. + * + * Both objects must belong to the same display list, or parent container. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. + * + * @method Phaser.GameObjects.Components.Depth#setAbove + * @since 3.85.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that this Game Object will be moved to be above. + * + * @return {this} This Game Object instance. + */ + setAbove: function (gameObject) + { + var list = this.getDisplayList(); + + if (list && gameObject) + { + ArrayUtils.MoveAbove(list, this, gameObject); + } + + return this; + }, + + /** + * Move this Game Object so that it appears below the given Game Object. + * + * This means it will render immediately under the other object in the display list. + * + * Both objects must belong to the same display list, or parent container. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. + * + * @method Phaser.GameObjects.Components.Depth#setBelow + * @since 3.85.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that this Game Object will be moved to be below. + * + * @return {this} This Game Object instance. + */ + setBelow: function (gameObject) + { + var list = this.getDisplayList(); + + if (list && gameObject) + { + ArrayUtils.MoveBelow(list, this, gameObject); + } + + return this; + } + +}; + +module.exports = Depth; + + +/***/ }, + +/***/ 3248 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods for managing an elapse timer on a Game Object. + * The timer is used to drive animations and other time-based effects. + * + * This is not necessary for normal animations. + * It is intended to drive shader effects that require a time value. + * + * If you are adding this component to a Game Object, + * ensure that you register a preUpdate method on the Game Object, e.g.: + * + * ```javascript + * // Overrides Game Object method + * addedToScene: function () + * { + * this.scene.sys.updateList.add(this); + * }, + * + * // Overrides Game Object method + * removedFromScene: function () + * { + * this.scene.sys.updateList.remove(this); + * }, + * + * preUpdate: function (time, delta) + * { + * this.updateTimer(time, delta); + * } + * ``` + * + * @namespace Phaser.GameObjects.Components.ElapseTimer + * @since 4.0.0 + */ +var ElapseTimer = { + + /** + * The time elapsed since timer initialization, in milliseconds. + * + * @name Phaser.GameObjects.Components.ElapseTimer#timeElapsed + * @type {number} + * @since 4.0.0 + */ + timeElapsed: 0, + + /** + * The time after which `timeElapsed` will reset, in milliseconds. + * By default, this is 1 hour. + * If you use the timer for animations, you can set this to a period + * that matches the animation durations. + * + * This is necessary for the timer to avoid floating-point precision issues + * in shaders. + * A float32 can represent a few hours of milliseconds accurately, + * but the precision decreases as the value increases. + * + * @name Phaser.GameObjects.Components.ElapseTimer#timeElapsedResetPeriod + * @type {number} + * @since 4.0.0 + * @default 3600000 + */ + timeElapsedResetPeriod: 60 * 60 * 1000, + + /** + * Whether the elapse timer is paused. + * + * @name Phaser.GameObjects.Components.ElapseTimer#timePaused + * @type {boolean} + * @since 4.0.0 + * @default false + */ + timePaused: false, + + /** + * Set the reset period for the elapse timer for this game object. + * + * @method Phaser.GameObjects.Components.ElapseTimer#setTimerResetPeriod + * @since 4.0.0 + * @param {number} period - The time after which `timeElapsed` will reset, in milliseconds. + * @return {this} This game object. + */ + setTimerResetPeriod: function (period) + { + this.timeElapsedResetPeriod = period; + + return this; + }, + + /** + * Pauses or resumes the elapse timer for this game object. + * + * @method Phaser.GameObjects.Components.ElapseTimer#setTimerPaused + * @since 4.0.0 + * @param {boolean} [paused] - Pause state (`true` to pause, `false` to unpause). If not specified, the timer will unpause. + * @return {this} This game object. + */ + setTimerPaused: function (paused) + { + this.timePaused = !!paused; + + return this; + }, + + /** + * Reset the elapse timer for this game object. + * + * @method Phaser.GameObjects.Components.ElapseTimer#resetTimer + * @since 4.0.0 + * @param {number} [ms=0] - The time to reset the timer to, in milliseconds. + * @return {this} This game object. + */ + resetTimer: function (ms) + { + if (ms === undefined) { ms = 0; } + this.timeElapsed = ms; + + return this; + }, + + /** + * Update the elapse timer for this game object. + * This should be called automatically by the preUpdate method. + * + * Override this method to create more advanced time management, + * or set it to a NOOP function to disable the timer update. + * If you want to control animations with a tween or input system, + * disabling the timer update could be useful. + * + * @method Phaser.GameObjects.Components.ElapseTimer#updateTimer + * @since 4.0.0 + * @param {number} time - The current time in milliseconds. + * @param {number} delta - The time since the last update, in milliseconds. + * @return {this} This game object. + */ + updateTimer: function (time, delta) + { + if (!this.timePaused) + { + this.timeElapsed += delta; + + if (this.timeElapsed >= this.timeElapsedResetPeriod) + { + this.timeElapsed -= this.timeElapsedResetPeriod; + } + } + + return this; + } +}; + +module.exports = ElapseTimer; + + +/***/ }, + +/***/ 53427 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Barrel = __webpack_require__(10189); +var Blend = __webpack_require__(16762); +var Blocky = __webpack_require__(37597); +var Blur = __webpack_require__(88344); +var Bokeh = __webpack_require__(47564); +var ColorMatrix = __webpack_require__(77011); +var CombineColorMatrix = __webpack_require__(95200); +var Displacement = __webpack_require__(16898); +var Glow = __webpack_require__(42652); +var GradientMap = __webpack_require__(43927); +var ImageLight = __webpack_require__(84714); +var Key = __webpack_require__(51890); +var Mask = __webpack_require__(97797); +var NormalTools = __webpack_require__(37911); +var PanoramaBlur = __webpack_require__(6379); +var Pixelate = __webpack_require__(29861); +var Quantize = __webpack_require__(14366); +var Sampler = __webpack_require__(63785); +var Shadow = __webpack_require__(62229); +var Threshold = __webpack_require__(99534); +var Vignette = __webpack_require__(20263); +var Wipe = __webpack_require__(90002); + +/** + * @classdesc + * A list of filters being applied to a {@link Phaser.Cameras.Scene2D.Camera}. + * + * Filters can apply special effects and masks. + * They are only available in WebGL. + * Use `gameObject.enableFilters()` to apply them to Game Objects. + * + * Filters include the following: + * + * * Barrel Distortion + * * Blend + * * Blocky + * * Blur + * * Bokeh / Tilt Shift + * * Color Matrix + * * Displacement + * * Glow + * * Key + * * Mask + * * Parallel Filters + * * Pixelate + * * Sampler + * * Shadow + * * Threshold + * + * This list is either 'internal' or 'external'. + * Internal filters apply to things within the camera. + * External filters apply to the camera itself, in its rendering context. + * A complete list of rendering steps for a Camera goes: + * + * 1. Objects render to a texture the size of the camera. + * 2. Internal filters draw that texture to new textures, applying effects. + * These are usually the same size, but may expand to accommodate blur. + * 3. The texture is drawn to a texture the size of the context where the camera + * will be drawn, accounting for transformation of the camera itself. + * 4. External filters draw that texture to new textures, + * again applying effects and expanding where necessary. + * 5. The final texture draws the filtered camera contents to the context. + * + * For example, consider a game object which is rotated 45 degrees. + * Apply a horizontal blur filter. + * If the filter is internal, the blur will appear at 45 degrees, + * because it is applied before the object is rotated. + * If the filter is external, the blur will appear horizontal, + * because it is applied after the object is rotated. + * + * You should use internal filters wherever possible, + * because they apply only to the region of the camera/game object. + * External filters are full-screen and can be more expensive. + * + * Filters can be stacked. The order of the list is the order of application. + * + * As you can appreciate, some effects are more expensive than others. For example, a bloom effect is going to be more + * expensive than a simple color matrix effect, so please consider using them wisely and performance test your target + * platforms early on in production. + * + * This FilterList is created internally and does not need to be instantiated directly. + * + * In Phaser 3, Filters were known as FX. + * + * @class FilterList + * @memberof Phaser.GameObjects.Components + * @constructor + * @since 4.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that owns this list. + */ +var FilterList = new Class({ + initialize: function FilterList (camera) + { + /** + * The Camera that owns this list. + * + * @name Phaser.GameObjects.Components.FilterList#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 4.0.0 + */ + this.camera = camera; + + /** + * The list of filters. + * + * This list can be manipulated directly. + * If you want to add or remove filters, + * please use the appropriate methods to ensure they are handled correctly. + * Moving filters around in the list is safe. + * + * @name Phaser.GameObjects.Components.FilterList#list + * @type {Phaser.Filters.Controller[]} + * @default [] + * @since 4.0.0 + */ + this.list = []; + }, + + /** + * Destroys and removes all filters in this list. + * + * @method Phaser.GameObjects.Components.FilterList#clear + * @since 4.0.0 + * @return {this} This FilterList instance. + */ + clear: function () + { + for (var i = 0; i < this.list.length; i++) + { + var filter = this.list[i]; + if (!filter.ignoreDestroy) + { + filter.destroy(); + } + } + + this.list.length = 0; + + return this; + }, + + /** + * Adds a filter to this list. + * + * @method Phaser.GameObjects.Components.FilterList#add + * @since 4.0.0 + * + * @param {Phaser.Filters.Controller} filter - The filter to add. + * @param {number} [index] - The index to insert the filter at. If not given, the filter is added to the end of the list. If negative, it is inserted from the end. + * + * @return {Phaser.Filters.Controller} The filter that was added. + */ + add: function (filter, index) + { + if (index === undefined) + { + this.list.push(filter); + } + else + { + this.list.splice(index, 0, filter); + } + + return filter; + }, + + /** + * Removes a filter from this list, then destroys it. + * + * @method Phaser.GameObjects.Components.FilterList#remove + * @since 4.0.0 + * + * @param {Phaser.Filters.Controller} filter - The filter to remove. + * @param {boolean} [forceDestroy=false] - If `true`, the filter will be destroyed even if it has the `ignoreDestroy` flag set. + * + * @return {this} This FilterList instance. + */ + remove: function (filter, forceDestroy) + { + var index = this.list.indexOf(filter); + + if (index !== -1) + { + this.list.splice(index, 1); + if (!filter.ignoreDestroy || forceDestroy) + { + filter.destroy(); + } + } + + return this; + }, + + /** + * Returns all active filters in this list. + * + * @method Phaser.GameObjects.Components.FilterList#getActive + * @since 4.0.0 + * @return {Phaser.Filters.Controller[]} The active filters in this list. + */ + getActive: function () + { + return this.list.filter(isActive); + }, + + /** + * Adds a Barrel effect. + * + * A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to + * a Game Object. The amount of the effect can be modified in real-time. + * + * @method Phaser.GameObjects.Components.FilterList#addBarrel + * @since 4.0.0 + * @param {number} [amount=1] - The amount of distortion applied to the barrel effect. A value of 1 is no distortion. Typically keep this within +- 1. + * @return {Phaser.Filters.Barrel} The new Barrel filter controller. + */ + addBarrel: function (amount) + { + return this.add(new Barrel(this.camera, amount)); + }, + + /** + * Adds a Blend effect. + * + * A blend effect allows you to apply another texture to the view + * using a specific blend mode. + * This supports blend modes not otherwise available in WebGL. + * + * @method Phaser.GameObjects.Components.FilterList#addBlend + * @since 4.0.0 + * @param {string} [texture='__WHITE'] - The texture to apply to the view. + * @param {Phaser.BlendModes} [blendMode=Phaser.BlendModes.NORMAL] - The blend mode to apply to the view. + * @param {number} [amount=1] - The amount of the blend effect to apply to the view. At 0, the original image is preserved. At 1, the blend texture is fully applied. The expected range is 0 to 1, but you can go outside that range for different effects. + * @param {number[]} [color=[1, 1, 1, 1]] - The color to apply to the blend texture. Each value corresponds to a color channel in RGBA. The expected range is 0 to 1, but you can go outside that range for different effects. + * @return {Phaser.Filters.Blend} The new Blend filter controller. + */ + addBlend: function (texture, blendMode, amount, color) + { + return this.add(new Blend( + this.camera, + texture, + blendMode, + amount, + color + )); + }, + + /** + * Adds a Blocky effect. + * + * This filter controller manages a blocky effect. + * + * The blocky effect works by taking the central pixel of a block of pixels + * and using it to fill the entire block, creating a pixelated effect. + * + * It reduces the resolution of an image, + * creating a pixelated or blocky appearance. + * This is often used for stylistic purposes, such as pixel art. + * One technique is to render the game at a higher resolution, + * scaled up by a factor of N, + * and then apply the blocky effect at size N. + * This creates large, visible pixels, suitable for further stylization. + * The effect can also be used to obscure certain elements within the game, + * such as during a transition or to censor specific content. + * + * Blocky works best on games with no anti-aliasing, + * so it can read unfiltered pixel colors from the original image. + * It preserves the colors of the original art, instead of blending them + * like the Pixelate filter. + * + * @method Phaser.GameObjects.Components.FilterList#addBlocky + * @since 4.0.0 + * @param {Phaser.Types.Filters.BlockyConfig} [config] - The configuration object for the Blocky effect. + * @return {Phaser.Filters.Blocky} The new Blocky filter controller. + */ + addBlocky: function (config) + { + return this.add(new Blocky(this.camera, config)); + }, + + /** + * Adds a Blur effect. + * + * A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect, + * typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a + * smooth blur resembling that of viewing the image through a translucent screen, distinctly different + * from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination. + * + * @method Phaser.GameObjects.Components.FilterList#addBlur + * @since 4.0.0 + * + * @param {number} [quality=0] - The quality of the blur effect. Can be either 0 for Low Quality, 1 for Medium Quality or 2 for High Quality. + * @param {number} [x=2] - The horizontal offset of the blur effect. + * @param {number} [y=2] - The vertical offset of the blur effect. + * @param {number} [strength=1] - The strength of the blur effect. + * @param {number} [color=0xffffff] - The color of the blur, as a hex value. + * @param {number} [steps=4] - The number of steps to run the blur effect for. This value should always be an integer. + * + * @return {Phaser.Filters.Blur} The new Blur filter controller. + */ + addBlur: function (quality, x, y, strength, color, steps) + { + return this.add(new Blur( + this.camera, + quality, + x, + y, + strength, + color, + steps + )); + }, + + /** + * Adds a Bokeh effect. + * + * Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field. + * This effect is used to emphasize the game's main subject or action, by blurring the background or foreground + * elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering + * techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics. + * + * See also Tilt Shift. + * + * @method Phaser.GameObjects.Components.FilterList#addBokeh + * @since 4.0.0 + * + * @param {number} [radius=0.5] - The radius of the bokeh effect. + * @param {number} [amount=1] - The amount of the bokeh effect. + * @param {number} [contrast=0.2] - The color contrast of the bokeh effect. + * + * @return {Phaser.Filters.Bokeh} The new Bokeh filter controller. + */ + addBokeh: function (radius, amount, contrast) + { + return this.add(new Bokeh( + this.camera, + radius, + amount, + contrast + )); + }, + + /** + * Adds a Color Matrix effect. + * + * The color matrix effect is a visual technique that involves manipulating the colors of an image + * or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, + * allowing developers to create various stylistic appearances or mood settings within the game. + * Common applications include simulating different lighting conditions, applying color filters, + * or achieving a specific visual style. + * + * @method Phaser.GameObjects.Components.FilterList#addColorMatrix + * @since 4.0.0 + * @return {Phaser.Filters.ColorMatrix} The new ColorMatrix filter controller. + */ + addColorMatrix: function () + { + return this.add(new ColorMatrix(this.camera)); + }, + + /** + * Adds a Combine Color Matrix effect. + * + * This filter combines channels from two textures. + * There are many possibilities with this. + * However, a significant purpose is to manipulate alpha channels. + * Use `setupAlphaTransfer` to configure common options, + * or set the `colorMatrixSelf` and `colorMatrixTransfer` properties + * directly. + * + * @method Phaser.GameObjects.Components.FilterList#addCombineColorMatrix + * @since 4.0.0 + * @param {string | Phaser.Textures.Texture} [texture='__WHITE'] - The texture or texture key to use for the transfer texture. + * @return {Phaser.Filters.CombineColorMatrix} The new CombineColorMatrix filter controller. + */ + addCombineColorMatrix: function (texture) + { + return this.add(new CombineColorMatrix(this.camera, texture)); + }, + + /** + * Adds a Displacement effect. + * + * The displacement effect is a visual technique that alters the position of pixels in an image + * or texture based on the values of a displacement map. This effect is used to create the illusion + * of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to + * characters, objects, or backgrounds to enhance realism, convey movement, or achieve various + * stylistic appearances. + * + * @method Phaser.GameObjects.Components.FilterList#addDisplacement + * @since 4.0.0 + * + * @param {string} [texture='__WHITE'] - The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. + * @param {number} [x=0.005] - The amount of horizontal displacement to apply. A very small float number, such as 0.005. + * @param {number} [y=0.005] - The amount of vertical displacement to apply. A very small float number, such as 0.005. + * + * @return {Phaser.Filters.Displacement} The new Displacement filter controller. + */ + addDisplacement: function (texture, x, y) + { + return this.add(new Displacement( + this.camera, + texture, + x, + y + )); + }, + + /** + * Adds a Glow effect. + * + * The glow effect is a visual technique that creates a soft, luminous halo around game objects, + * characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal, + * or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on + * the inside of the edge. The color and strength of the glow can be modified. + * + * @method Phaser.GameObjects.Components.FilterList#addGlow + * @since 4.0.0 + * + * @param {number} [color=0xffffff] - The color of the glow effect as a number value. + * @param {number} [outerStrength=4] - The strength of the glow outward from the edge of textures. + * @param {number} [innerStrength=0] - The strength of the glow inward from the edge of textures. + * @param {number} [scale=1] - The scale of the glow effect. This multiplies the fixed distance. + * @param {boolean} [knockout=false] - If `true` only the glow is drawn, not the texture itself. + * @param {number} [quality=10] - The quality of the glow effect. This cannot be changed after the filter has been created. + * @param {number} [distance=10] - The distance of the glow effect. This cannot be changed after the filter has been created. + * + * @return {Phaser.Filters.Glow} The new Glow filter controller. + */ + addGlow: function (color, outerStrength, innerStrength, scale, knockout, quality, distance) + { + return this.add(new Glow( + this.camera, + color, + outerStrength, + innerStrength, + scale, + knockout, + quality, + distance + )); + }, + + /** + * Adds a GradientMap effect. + * + * GradientMap recolors an image using a ColorRamp. + * The image is converted to a progress value at each point, + * and that progress is evaluated as a color along the ramp. + * + * The progress value is normally the brightness of the image. + * You can use the `colorFactor` and `color` properties to customize it. + * + * @method Phaser.GameObjects.Components.FilterList#addGradientMap + * @since 4.0.0 + * + * @param {Phaser.Types.Filters.GradientMapConfig} [config] - The configuration object for the GradientMap effect. + * + * @return {Phaser.Filters.GradientMap} The new GradientMap filter controller. + */ + addGradientMap: function (config) + { + return this.add(new GradientMap(this.camera, config)); + }, + + /** + * Adds an ImageLight effect. + * + * ImageLight is a filter for image based lighting (IBL). + * It is used to simulate the lighting of an image + * using an environment map and a normal map. + * + * The environment map is an image that describes the lighting of the scene. + * This filter uses a single panorama image as the environment map. + * The top of the image is the sky, the bottom is the ground, + * and the X axis covers a full rotation. + * This kind of image is distorted towards the top and bottom, + * as the X axis is stretched wider and wider, + * so be careful if you're creating your own environment maps. + * + * Cube maps are not supported by Phaser at the time of writing. + * + * The effect is basically a reflection of the environment at infinite range. + * A sharp environment map will produce a sharp reflection, + * while a blurry environment map will produce a diffuse reflection. + * Use the PanoramaBlur filter to create correctly blurred environment maps. + * Use the NormalTools filter to manipulate the normal map if necessary, + * using a DynamicTexture to capture the output. + * + * @method Phaser.GameObjects.Components.FilterList#addImageLight + * @since 4.0.0 + * + * @param {Phaser.Types.Filters.ImageLightConfig} config - The configuration object for the ImageLight effect. + * @return {Phaser.Filters.ImageLight} The new ImageLight filter controller. + */ + addImageLight: function (config) + { + return this.add(new ImageLight(this.camera, config)); + }, + + /** + * Adds a Key effect. + * + * The Key effect removes or isolates a specific color from an image. + * It can be used to remove a background color from an image, + * or to isolate a specific color for further processing. + * + * By default, Key will remove pixels that match the key color. + * You can instead keep only the matching pixels by setting `isolate`. + * + * The threshold and feather settings control how closely the key color matches. + * A match is measured by "distance between color vectors"; + * that is, how close the RGB values of the pixel are to the RGB values of the key color. + * + * @method Phaser.GameObjects.Components.FilterList#addKey + * @since 4.0.0 + * + * @param {Phaser.Types.Filters.KeyConfig} [config] - The configuration object for the Key effect. + * + * @return {Phaser.Filters.Key} The new Key filter controller. + */ + addKey: function (config) + { + return this.add(new Key(this.camera, config)); + }, + + /** + * Adds a Mask effect. + * + * A mask uses a texture to hide parts of an input. + * It multiplies the color and alpha of the input + * by the alpha of the mask in the corresponding texel. + * + * Masks can be inverted, which switches what they hide and what they show. + * + * Masks can use either a texture or a GameObject. + * If a GameObject is used, the mask will render the GameObject + * to a DynamicTexture and use that. + * The mask will automatically update when the GameObject changes, + * unless the `autoUpdate` flag is set to `false`. + * + * When the mask filter is used as an internal filter, + * the mask will match the object/view being filtered. + * This is useful for creating effects that follow the object, + * such as effects intended to match an animated sprite. + * + * When the mask filter is used as an external filter, + * the mask will match the context of the camera. + * This is useful for creating effects that cover the entire view. + * + * An optional `viewCamera` can be specified when creating the mask. + * If not used, mask objects will be viewed through a default camera. + * Set the `viewCamera` to the scene's main camera (`this.cameras.main`) + * to view the mask through the main camera. + * + * @method Phaser.GameObjects.Components.FilterList#addMask + * @since 4.0.0 + * + * @param {string|Phaser.GameObjects.GameObject} [mask='__WHITE'] - The source of the mask. This can be a unique string-based key of the texture to use for the mask, which must exist in the Texture Manager. Or it can be a GameObject, in which case the mask will render the GameObject to a DynamicTexture and use that. + * @param {boolean} [invert=false] - Whether to invert the mask. + * @param {Phaser.Cameras.Scene2D.Camera} [viewCamera] - The Camera to use when rendering the mask with a GameObject. If not specified, uses the scene's `main` camera. + * @param {'local'|'world'} [viewTransform='world'] - The transform to use when rendering the mask with a GameObject. 'local' uses the GameObject's own properties. 'world' uses the GameObject's `parentContainer` value to compute a world position. + * @param {number} [scaleFactor=1] - The scale factor to apply to the underlying mask texture. Can be used to balance memory usage and needed mask precision. This just adjusts the size of the texture; you must also adjust mask size to match, e.g. if scaleFactor is 0.5, your mask might be a Container with scale 0.5. It's easy to make things complicated when combining scale factor, object transform, and camera transform, so try to be precise when using this option. + * + * @return {Phaser.Filters.Mask} The new Mask filter controller. + */ + addMask: function (mask, invert, viewCamera, viewTransform, scaleFactor) + { + return this.add(new Mask( + this.camera, + mask, + invert, + viewCamera, + viewTransform, + scaleFactor + )); + }, + + /** + * Adds a NormalTools effect. + * + * NormalTools is a filter for manipulating the normals of a normal map. + * It has several functions: + * + * - Rotate or reorient the normal map. + * - Change how strongly the normals face the camera. + * - Output a grayscale texture showing how strongly the normals face the camera, or some other vector. + * + * The output can be used for various purposes, such as: + * + * - Editing a normal map for special applications. + * - Altering the apparent visual depth of a normal map by manipulating the facing power. + * - Creating a base for other effects, such as a mask for a gradient or other effect. + * + * You can even use the output as a normal map for regular lighting. + * Ordinarily, normal maps are loaded alongside the main texture, + * but you can edit this. + * + * ```js + * // Given a dynamic texture `dyn` where the filter output is drawn, + * // and a texture `spiderTex` with lighting enabled, + * // we can inject the WebGL texture straight into the scene lighting as a normal map. + * const dynTex = dyn.getWebGLTexture(); + * const dynSource = new Phaser.Textures.TextureSource(spiderTex, dynTex); + * spiderTex.dataSource[0] = dynSource; // This is where the normal map is located. + * ``` + * + * @method Phaser.GameObjects.Components.FilterList#addNormalTools + * @since 4.0.0 + * + * @param {Phaser.Types.Filters.NormalToolsConfig} config - The configuration object for the NormalTools effect. + * @return {Phaser.Filters.NormalTools} The new NormalTools filter controller. + */ + addNormalTools: function (config) + { + return this.add(new NormalTools(this.camera, config)); + }, + + /** + * Adds a PanoramaBlur effect. + * + * PanoramaBlur is a filter for blurring a panorama image. + * This is intended for use with filters like ImageLight that use a panorama image as the environment map. + * The blur treats a rectangular map as a sphere, + * and applies heavy distortion close to the poles to get a correct result. + * You should not use it for general purpose blurring. + * + * The effect can be very slow, as it uses a grid of samples. + * Total samples equals samplesX * samplesY. This can get very high, + * very quickly, so be careful when increasing these values. + * They don't need to be too high for good results. + * + * By default, the blur is fully diffuse, sampling an entire hemisphere per point. + * If you reduce the radius, the effect will be more focused. + * Use this to control different levels of glossiness in objects using environment maps. + * + * @method Phaser.GameObjects.Components.FilterList#addPanoramaBlur + * @since 4.0.0 + * + * @param {Phaser.Types.Filters.PanoramaBlurConfig} config - The configuration object for the PanoramaBlur effect. + * + * @return {Phaser.Filters.PanoramaBlur} The new PanoramaBlur filter controller. + */ + addPanoramaBlur: function (config) + { + return this.add(new PanoramaBlur(this.camera, config)); + }, + + // For technical reasons, addParallelFilters is not coded here. + // ParallelFilters has a circular reference to FilterList. + // It registers its own `addParallelFilters` method to fix this, + // which is documented as a part of FilterList. + + /** + * Adds a Pixelate effect. + * + * The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image, + * creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic + * purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as + * during a transition or to censor specific content. + * + * @method Phaser.GameObjects.Components.FilterList#addPixelate + * @since 4.0.0 + * + * @param {number} [amount] - The amount of pixelation. A higher value creates a more pronounced effect. + * + * @return {Phaser.Filters.Pixelate} The new Pixelate filter controller. + */ + addPixelate: function (amount) + { + return this.add(new Pixelate( + this.camera, + amount + )); + }, + + /** + * Adds a Quantize effect. + * + * Quantization reduces the unique number of colors in an image, + * based on some limited number of steps per color channel. + * This is good for creating a retro or stylized effect. + * + * Basic quantization breaks each channel up into a number of `steps`. + * These steps are normally regular. You can bias them towards the top or bottom + * by changing that channel's `gamma` value. + * You can adjust the lowest step, thus all subsequent steps, with the `offset`. + * + * Quantization is done in either RGBA or HSVA space. + * The steps, gamma, and offset always apply in the same order, + * but depending on color mode, they are either applied to + * `[ red, green, blue, alpha ]` or `[ hue, saturation, value, alpha ]`. + * + * The output may optionally be dithered, to eliminate banding + * and create the illusion that there are many more colors in use. + * + * @method Phaser.GameObjects.Components.FilterList#addQuantize + * @since 4.0.0 + * + * @param {Phaser.Types.Filters.QuantizeConfig} [config] - The configuration object for the Quantize effect. + * + * @return {this} The new Quantize filter controller. + */ + addQuantize: function (config) + { + return this.add(new Quantize(this.camera, config)); + }, + + /** + * Adds a Sampler effect. + * + * This controller manages a sampler. + * It doesn't actually render anything, and leaves the image unaltered. + * It is used to sample a region of the camera view, and pass the results to a callback. + * This is useful for extracting data from the camera view. + * + * This operation is expensive, so use sparingly. + * + * @method Phaser.GameObjects.Components.FilterList#addSampler + * @since 4.0.0 + * + * @param {Phaser.Types.Renderer.Snapshot.SnapshotCallback} callback - The callback to call with the results of the sampler. + * @param {null|Phaser.Types.Math.Vector2Like|Phaser.Geom.Rectangle} [region=null] - The region to sample. If `null`, the entire camera view is sampled. If a `Phaser.Types.Math.Vector2Like`, a point is sampled. If a `Phaser.Geom.Rectangle`, the region is sampled. + * + * @return {Phaser.Filters.Sampler} The new Sampler filter controller. + */ + addSampler: function (callback, region) + { + return this.add(new Sampler( + this.camera, + callback, + region + )); + }, + + /** + * Adds a Shadow effect. + * + * The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker, + * offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows + * help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional. + * + * @method Phaser.GameObjects.Components.FilterList#addShadow + * @since 4.0.0 + * + * @param {number} [x=0] - The horizontal offset of the shadow effect. + * @param {number} [y=0] - The vertical offset of the shadow effect. + * @param {number} [decay=0.1] - The amount of decay for the shadow effect. + * @param {number} [power=1] - The power of the shadow effect. + * @param {number} [color=0x000000] - The color of the shadow, as a hex value. + * @param {number} [samples=6] - The number of samples that the shadow effect will run for. + * @param {number} [intensity=1] - The intensity of the shadow effect. + * + * @return {Phaser.Filters.Shadow} The new Shadow filter controller. + */ + addShadow: function (x, y, decay, power, color, samples, intensity) + { + return this.add(new Shadow( + this.camera, + x, + y, + decay, + power, + color, + samples, + intensity + )); + }, + + /** + * Adds a Threshold effect. + * + * Input values are compared to a threshold value or range. + * Values below the threshold are set to 0, and values above the threshold are set to 1. + * Values within the range are linearly interpolated between 0 and 1. + * + * This is useful for creating effects such as sharp edges from gradients, + * or for creating binary effects. + * + * The threshold is stored as a range, with two edges. + * Each edge has a value for each channel, between 0 and 1. + * If the two edges are the same, the threshold has no interpolation, + * and will output either 0 or 1. + * Each channel can also be inverted. + * + * @method Phaser.GameObjects.Components.FilterList#addThreshold + * @since 4.0.0 + * + * @param {number|number[]} [edge1=0.5] - The first edge of the threshold. This may be an array of the RGBA channels, or a single number for all 4 channels. + * @param {number|number[]} [edge2=0.5] - The second edge of the threshold. This may be an array of the RGBA channels, or a single number for all 4 channels. + * @param {boolean|boolean[]} [invert=false] - Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean for all 4 channels. + * + * @return {Phaser.Filters.Threshold} The new Threshold filter controller. + */ + addThreshold: function (edge1, edge2, invert) + { + return this.add(new Threshold( + this.camera, + edge1, + edge2, + invert + )); + }, + + /** + * Adds a Tilt Shift effect. + * + * This Bokeh effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature + * effect by blurring everything except a small area of the image. This effect is achieved by blurring the + * top and bottom elements, while keeping the center area in focus. + * + * See also Bokeh. + * + * @method Phaser.GameObjects.Components.FilterList#addTiltShift + * @since 4.0.0 + * + * @param {number} [radius] - The radius of the bokeh effect. + * @param {number} [amount] - The amount of the bokeh effect. + * @param {number} [contrast] - The color contrast of the bokeh effect. + * @param {number} [blurX] - The amount of horizontal blur. + * @param {number} [blurY] - The amount of vertical blur. + * @param {number} [strength] - The strength of the blur. + * + * @return {Phaser.Filters.Bokeh} The new Bokeh filter controller. + */ + addTiltShift: function (radius, amount, contrast, blurX, blurY, strength) + { + return this.add(new Bokeh( + this.camera, + radius, + amount, + contrast, + true, + blurX, + blurY, + strength + )); + }, + + /** + * Adds a Vignette effect. + * + * The vignette effect is a visual technique where the edges of the screen, + * or a Game Object, gradually darken or blur, + * creating a frame-like appearance. This effect is used to draw the player's + * focus towards the central action or subject, enhance immersion, + * and provide a cinematic or artistic quality to the game's visuals. + * + * This filter supports colored borders, and a limited set of blend modes, + * to increase its stylistic power. + * + * @method Phaser.GameObjects.Components.FilterList#addVignette + * @since 4.0.0 + * + * @param {number} [x=0.5] - The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. + * @param {number} [y=0.5] - The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. + * @param {number} [radius=0.5] - The radius of the vignette effect. This value is normalized to the range 0 to 1. + * @param {number} [strength=0.5] - The strength of the vignette effect. + * @param {number | string | Phaser.Types.Display.InputColorObject | Phaser.Display.Color} [color=0x000000] - The color of the vignette effect, as a hex code or Color object. + * @param {number} [blendMode=Phaser.BlendModes.NORMAL] - The blend mode to use with the vignette. Only NORMAL, ADD, MULTIPLY, and SCREEN are supported. + * + * @return {Phaser.Filters.Vignette} The new Vignette filter controller. + */ + addVignette: function (x, y, radius, strength, color, blendMode) + { + return this.add(new Vignette(this.camera, x, y, radius, strength, color, blendMode)); + }, + + /** + * Adds a Wipe effect. + * + * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements + * in the game, such as images, text, or scene transitions. This effect is often used to create + * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition + * between game states. + * + * You can set both the direction and the axis of the wipe effect. The following combinations are possible: + * + * * left to right: direction 0, axis 0 + * * right to left: direction 1, axis 0 + * * top to bottom: direction 0, axis 1 + * * bottom to top: direction 1, axis 1 + * + * It is up to you to set the `progress` value yourself, e.g. via a Tween, in order to transition the effect. + * + * @method Phaser.GameObjects.Components.FilterList#addWipe + * @since 4.0.0 + * + * @param {number} [wipeWidth=0.1] - The width of the wipe effect. This value is normalized in the range 0 to 1. + * @param {number} [direction=0] - The direction of the wipe effect. Either 0 (left to right, or top to bottom) or 1 (right to left, or bottom to top). Set in conjunction with the axis property. + * @param {number} [axis=0] - The axis of the wipe effect. Either 0 (X) or 1 (Y). Set in conjunction with the direction property. + * @param {number} [reveal=0] - Is this a reveal (1) or a fade (0) effect? Reveal shows the input in wiped areas; fade shows the input in unwiped areas. + * @param {string | Phaser.Textures.Texture} [wipeTexture='__DEFAULT'] - Texture or texture key to use where the input texture is not shown. The default texture is blank. Use another texture for a wipe transition. + * + * @return {Phaser.Filters.Wipe} - The new Wipe filter instance. + */ + addWipe: function (wipeWidth, direction, axis, reveal, wipeTexture) + { + return this.add(new Wipe(this.camera, wipeWidth, direction, axis, reveal, wipeTexture)); + }, + + /** + * Destroys this FilterList. + * + * @method Phaser.GameObjects.Components.FilterList#destroy + * @since 4.0.0 + */ + destroy: function () + { + this.clear(); + + this.camera = null; + } +}); + +function isActive (filter) +{ + return filter.active; +} + +module.exports = FilterList; + + +/***/ }, + +/***/ 43102 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Camera = null; // Lazy loaded. +var Vector2 = __webpack_require__(26099); +var TransformMatrix = __webpack_require__(61340); + +/** + * Provides methods used for setting the filters properties of a Game Object. + * These apply special effects, post-processing and masks to the object. + * Should be applied as a mixin and not used directly. + * + * Filters work by rendering the object to a texture. + * The texture is then rendered again for each filter, using a shader. + * See {@link Phaser.GameObjects.Components.FilterList} for more information. + * + * Enable filters with `enableFilters()`. + * Each object with filters enabled, and any filters active, + * makes a new draw call, plus one or more per active filter. + * This can be expensive. Use sparingly. + * + * --- + * + * ## Camera + * + * Filters has a `filterCamera` property, which is a Camera. + * The Camera does most of the hard work, including the filters. + * + * The Camera automatically focuses on the Game Object, + * so you should not need to adjust it manually. + * If you do want to adjust it, you can use `focusFiltersOverride`. + * + * --- + * + * ## Framebuffer Coverage + * + * Filters are rendered to a framebuffer, which is a texture. + * Anything outside the bounds of the framebuffer is not rendered. + * Think of it as a window into another world. + * + * To ensure that the game object fits into the framebuffer, + * the internal camera is transformed to match the object. + * The object can transform normally, and the camera will follow + * while `filtersAutoFocus` is enabled. + * + * @namespace Phaser.GameObjects.Components.Filters + * @since 4.0.0 + */ +var Filters = {}; + +if (true) +{ + Filters = + { + /** + * The Camera used for filters. + * You can use this to alter the perspective of filters. + * It is not necessary to use this camera for ordinary rendering. + * + * This is only available if you use the `enableFilters` method. + * + * @name Phaser.GameObjects.Components.Filters#filterCamera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 4.0.0 + * @webglOnly + */ + filterCamera: null, + + /** + * The filter lists for this Game Object. + * This is an object with `internal` and `external` properties. + * Each list is a {@link Phaser.GameObjects.Components.FilterList} object. + * + * This is only available if you use the `enableFilters` method. + * + * @name Phaser.GameObjects.Components.Filters#filters + * @type {Phaser.Types.GameObjects.FiltersInternalExternal|null} + * @readonly + * @since 4.0.0 + * @webglOnly + */ + filters: { + get: function () + { + if (this.filterCamera) + { + return this.filterCamera.filters; + } + return null; + } + }, + + /** + * Whether any filters should be rendered on this Game Object. + * This is `true` by default, even if there are no filters yet. + * Disable this to skip filter rendering. + * + * Use `willRenderFilters()` to see if there are any active filters. + * + * @name Phaser.GameObjects.Components.Filters#renderFilters + * @type {boolean} + * @default true + * @since 4.0.0 + * @webglOnly + */ + renderFilters: true, + + /** + * The maximum size of the base filter texture. + * Filters may use a larger texture after the base texture is rendered. + * The maximum texture size is at least 4096 in WebGL, based on the hardware. + * You may set this lower to save memory or prevent resizing. + * + * @name Phaser.GameObjects.Components.Filters#maxFilterSize + * @type {Phaser.Math.Vector2} + * @since 4.0.0 + * @webglOnly + */ + maxFilterSize: null, + + /** + * Whether `filterCamera` should update every frame + * to focus on the Game Object. + * Disable this if you want to manually control the camera. + * + * @name Phaser.GameObjects.Components.Filters#filtersAutoFocus + * @type {boolean} + * @default true + * @since 4.0.0 + * @webglOnly + */ + filtersAutoFocus: true, + + /** + * Whether the filters should focus on the context, + * rather than attempt to focus on the Game Object. + * This is enabled automatically when enabling filters on objects + * which don't have well-defined bounds. + * + * This effectively sets the internal filters to render the same way + * as the external filters. + * + * This is only used if `filtersAutoFocus` is enabled. + * + * The "context" is the framebuffer to which the Game Object is rendered. + * This is usually the main framebuffer, but might be another framebuffer. + * It can even be several different framebuffers if the Game Object is + * rendered multiple times. + * + * @name Phaser.GameObjects.Components.Filters#filtersFocusContext + * @type {boolean} + * @default false + * @since 4.0.0 + * @webglOnly + */ + filtersFocusContext: false, + + /** + * Whether the Filters component should always draw to a framebuffer, + * even if there are no active filters. + * + * @name Phaser.GameObjects.Components.Filters#filtersForceComposite + * @type {boolean} + * @default false + * @since 4.0.0 + * @webglOnly + */ + filtersForceComposite: false, + + /** + * A transform matrix used to render the filters. + * It holds the transform of the Game Object. + * + * This is only available if you use the `enableFilters` method. + * + * @name Phaser.GameObjects.Components.Filters#_filtersMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 4.0.0 + * @webglOnly + */ + _filtersMatrix: null, + + /** + * A transform matrix used to render the filters. + * It holds the view matrix for the filter camera, adjusted for the Game Object. + * + * This is only available if you use the `enableFilters` method. + * + * @name Phaser.GameObjects.Components.Filters#_filtersViewMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 4.0.0 + * @webglOnly + */ + _filtersViewMatrix: null, + + /** + * Whether this Game Object will render filters. + * This is true if it has active filters, + * and if the `renderFilters` property is also true. + * + * @method Phaser.GameObjects.Components.Filters#willRenderFilters + * @since 4.0.0 + * @webglOnly + * @return {boolean} Whether the Game Object will render filters. + */ + willRenderFilters: function () + { + return this.renderFilters && + this.filters && + ( + this.filters.internal.getActive().length > 0 || + this.filters.external.getActive().length > 0 || + this.filtersForceComposite + ); + }, + + /** + * Enable this Game Object to have filters. + * + * You need to call this method if you want to use the `filterCamera` + * and `filters` properties. It sets up the necessary data structures. + * You may disable filter rendering with the `renderFilters` property. + * + * This is a WebGL only feature. It will return early if not available. + * + * @method Phaser.GameObjects.Components.Filters#enableFilters + * @since 4.0.0 + * @webglOnly + * @return {this} + */ + enableFilters: function () + { + if (this.filterCamera || !this.scene.renderer.gl) + { + return this; + } + + var scene = this.scene; + + if (!Camera) + { + // Lazy load the camera class to avoid circular dependencies. + Camera = __webpack_require__(38058); + } + + this.filterCamera = new Camera(0, 0, 1, 1).setScene(scene, false); + + // Set up the filter camera to compute an inverse matrix for the object. + this.filterCamera.isObjectInversion = true; + + if (scene.game.config.roundPixels) + { + this.filterCamera.roundPixels = true; + } + + if (!this.maxFilterSize) + { + var maxTextureSize = scene.renderer.getMaxTextureSize(); + this.maxFilterSize = new Vector2(maxTextureSize, maxTextureSize); + } + + this._filtersMatrix = new TransformMatrix(); + this._filtersViewMatrix = new TransformMatrix(); + + // Check whether the object is poorly bounded, and needs to focus on the context. + if ( + !this.getBounds || + this.width === undefined || + this.height === undefined || + this.width === 0 || + this.height === 0 + ) + { + this.filtersFocusContext = true; + } + + // Add filters as a render step, + // immediately prior to the main renderWebGL step. + var renderWebGLIndex = this._renderSteps.indexOf(this.renderWebGL); + this.addRenderStep(this.renderWebGLFilters, renderWebGLIndex); + + return this; + }, + + /** + * Render this object using filters. + * + * This function's scope is not guaranteed, so it doesn't refer to `this`. + * + * @method Phaser.GameObjects.Components.Filters#renderWebGLFilters + * @webglOnly + * @since 4.0.0 + * @type {Phaser.Types.GameObjects.RenderWebGLStep} + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to render with. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - The parent matrix of the Game Object, if it has one. + * @param {number} [renderStep=0] - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + */ + renderWebGLFilters: function ( + renderer, + gameObject, + drawingContext, + parentMatrix, + renderStep + ) + { + if (!gameObject.willRenderFilters()) + { + gameObject.renderWebGLStep( + renderer, + gameObject, + drawingContext, + parentMatrix, + renderStep + 1 + ); + return; + } + + var camera = drawingContext.camera; + + // Ordinarily, we would add the game object to the camera's render list here. + // But because child objects are added to the filter camera's render list, + // we wait for the object to be rendered, + // and then take its filter camera's render list + // and add it to the drawingContext's render list. + + var filtersAutoFocus = gameObject.filtersAutoFocus; + var filtersFocusContext = gameObject.filtersFocusContext; + + if (filtersAutoFocus) + { + if (filtersFocusContext) + { + gameObject.focusFiltersOnCamera(camera); + } + else + { + gameObject.focusFilters(); + } + } + + var filterCamera = gameObject.filterCamera; + filterCamera.preRender(); + + // Set the camera roundPixels property to reflect desired rounding. + // This is necessary to avoid blurring from antialiasing + // if coordinates are not integer. + var filterCameraRoundPixels = filterCamera.roundPixels; + filterCamera.roundPixels = gameObject.willRoundVertices( + filterCamera, + (gameObject.rotation % (Math.PI * 2) === 0) && + (gameObject.scaleX === 1, gameObject.scaleY === 1) + ); + + if (filtersAutoFocus && filtersFocusContext) + { + var parent = gameObject.parentContainer; + if (parent) + { + // Apply the game object's parent world transform to the filter camera. + var parentWorldMatrix = parent.getWorldTransformMatrix(); + filterCamera.matrix.multiply(parentWorldMatrix); + } + } + + // Get transform. + var transformMatrix = gameObject._filtersMatrix; + var cameraMatrix = gameObject._filtersViewMatrix.copyWithScrollFactorFrom( + camera.getViewMatrix(!drawingContext.useCanvas), + camera.scrollX, camera.scrollY, + gameObject.scrollFactorX, gameObject.scrollFactorY + ); + + if (parentMatrix) + { + cameraMatrix.multiply(parentMatrix); + } + + if (filtersFocusContext) + { + transformMatrix.loadIdentity(); + } + else + { + if (gameObject.type === 'Layer') + { + transformMatrix.loadIdentity(); + } + else + { + var flipX = gameObject.flipX ? -1 : 1; + var flipY = gameObject.flipY ? -1 : 1; + transformMatrix.applyITRS( + gameObject.x, + gameObject.y, + gameObject.rotation, + gameObject.scaleX * flipX, + gameObject.scaleY * flipY + ); + } + + // Offset origin. + var width = filterCamera.width; + var height = filterCamera.height; + transformMatrix.translate( + -width * filterCamera.originX, + -height * filterCamera.originY + ); + + cameraMatrix.multiply(transformMatrix, transformMatrix); + } + + // Set object scrollFactor to default. + // We can't accurately focus the camera on the object if it has a scrollFactor, + // because the camera needs to be set further away, + // going to infinity at scrollFactor 0. + // The scroll factor is baked into the transformMatrix, above. + var scrollX = gameObject.scrollFactorX; + var scrollY = gameObject.scrollFactorY; + gameObject.scrollFactorX = 1; + gameObject.scrollFactorY = 1; + + // Now we have the transform for the game object. + // Render game object to framebuffer. + renderer.cameraRenderNode.run( + drawingContext, + [ gameObject ], + filterCamera, + transformMatrix, + true, + renderStep + 1 + ); + + // Restore scrollFactor. + gameObject.scrollFactorX = scrollX; + gameObject.scrollFactorY = scrollY; + + // Restore camera roundPixels. + filterCamera.roundPixels = filterCameraRoundPixels; + + // Add the game object's filter camera's render list + // to the drawingContext's render list. + var filterRenderListLength = filterCamera.renderList.length; + for (var i = 0; i < filterRenderListLength; i++) + { + camera.addToRenderList(filterCamera.renderList[i]); + } + }, + + /** + * Focus the filter camera. + * This sets the size and position of the filter camera to match the GameObject. + * This is called automatically on render if `filtersAutoFocus` is enabled. + * + * This will focus on the GameObject's raw dimensions if available. + * If the GameObject has no dimensions, this will focus on the context: + * the camera belonging to the DrawingContext used to render the GameObject. + * Context focus occurs during rendering, + * as the context is not known until then. + * + * @method Phaser.GameObjects.Components.Filters#focusFilters + * @webglOnly + * @since 4.0.0 + * @return {this} + */ + focusFilters: function () + { + var posX = this.x; + var posY = this.y; + var originX = this.originX; + var originY = this.originY; + var width = this.width; + var height = this.height; + + if ( + this.type === 'Layer' || + isNaN(posX) || isNaN(posY) || + isNaN(width) || isNaN(height) || + isNaN(originX) || isNaN(originY) || + width === 0 || height === 0 + ) + { + this.filtersFocusContext = true; + return this; + } + + var rotation = this.rotation; + var scaleX = this.scaleX; + var scaleY = this.scaleY; + + // Handle flip. + if (this.flipX) + { + scaleX *= -1; + originX = 1 - originX; + } + if (this.flipY) + { + scaleY *= -1; + originY = 1 - originY; + } + + var centerX = posX + width * (0.5 - originX); + var centerY = posY + height * (0.5 - originY); + + // Set the filter camera size to match the object. + this.setFilterSize(width, height); + + // Set the filter camera to match the object. + this.filterCamera + .centerOn(centerX, centerY) + .setRotation(-rotation) + .setOrigin(originX, originY) + .setZoom(1 / scaleX, 1 / scaleY); + + return this; + }, + + /** + * Focus the filter camera on a specific camera. + * This is used internally when `filtersFocusContext` is enabled. + * + * @method Phaser.GameObjects.Components.Filters#focusFiltersOnCamera + * @webglOnly + * @since 4.0.0 + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to focus on. + * @return {this} + */ + focusFiltersOnCamera: function (camera) + { + var width = camera.width; + var height = camera.height; + var posX = camera.scrollX; + var posY = camera.scrollY; + var rotation = camera.rotation; + var zoomX = camera.zoomX; + var zoomY = camera.zoomY; + + // Set the filter camera size to match the object. + this.setFilterSize(width, height); + + this.filterCamera.setScroll(posX, posY); + this.filterCamera.setRotation(rotation); + this.filterCamera.setZoom(zoomX, zoomY); + + return this; + }, + + /** + * Manually override the focus of the filter camera. + * This allows you to set the size and position of the filter camera manually. + * It deactivates `filtersAutoFocus` when called. + * + * The camera will set scroll to place the game object at the + * given position within a rectangle of the given width and height. + * For example, calling `focusFiltersOverride(400, 200, 800, 600)` + * will focus the camera to place the object's center + * 100 pixels above the center of the camera (which is at 400x300). + * + * @method Phaser.GameObjects.Components.Filters#focusFiltersOverride + * @webglOnly + * @since 4.0.0 + * @param {number} [x] - The x-coordinate of the focus point, relative to the filter size. Default is the center. + * @param {number} [y] - The y-coordinate of the focus point, relative to the filter size. Default is the center. + * @param {number} [width] - The width of the focus area. Default is the filter width. + * @param {number} [height] - The height of the focus area. Default is the filter height. + * @return {this} + */ + focusFiltersOverride: function (x, y, width, height) + { + var filterCamera = this.filterCamera; + + // Maintain size. + if (width === undefined) + { + width = filterCamera.width; + } + if (height === undefined) + { + height = filterCamera.height; + } + + // Default to center. + if (x === undefined) + { + x = width / 2; + } + if (y === undefined) + { + y = height / 2; + } + + var objectX = this.x; + var objectY = this.y; + + this.setFilterSize(width, height); + filterCamera.setScroll(objectX - x, objectY - y); + + var originX = x / width; + var originY = y / height; + + filterCamera.setOrigin(originX, originY); + + // Stop automatic focus. + this.filtersAutoFocus = false; + + return this; + }, + + /** + * Set the base size of the filter camera. + * This is the size of the texture that internal filters will be drawn to. + * External filters are drawn to the size of the context (usually the game canvas). + * + * This is typically the size of the GameObject. + * It is set automatically when the Game Object is rendered + * and `filtersAutoFocus` is enabled. + * Turn off auto focus to set it manually. + * + * Technically, larger framebuffers may be used to provide padding. + * This is the size of the final framebuffer used for "internal" rendering. + * + * @method Phaser.GameObjects.Components.Filters#setFilterSize + * @webglOnly + * @since 4.0.0 + * @param {number} width - Base width of the filter texture. + * @param {number} height - Base height of the filter texture. + * @return {this} + */ + setFilterSize: function (width, height) + { + // Sanitize inputs. + width = Math.max(1, Math.min(Math.ceil(width), this.maxFilterSize.x)); + height = Math.max(1, Math.min(Math.ceil(height), this.maxFilterSize.y)); + + var filterCamera = this.filterCamera; + if (!filterCamera) + { + return this; + } + filterCamera.setSize(width, height); + + return this; + }, + + /** + * Sets whether the filter camera should automatically re-focus on the Game Object every frame. + * Sets the `filtersAutoFocus` property. + * + * @method Phaser.GameObjects.Components.Filters#setFiltersAutoFocus + * @webglOnly + * @since 4.0.0 + * @param {boolean} value - Whether filters should be updated every frame. + * @return {this} + */ + setFiltersAutoFocus: function (value) + { + this.filtersAutoFocus = value; + + return this; + }, + + /** + * Set whether the filters should focus on the context. + * Sets the `filtersFocusContext` property. + * + * @method Phaser.GameObjects.Components.Filters#setFiltersFocusContext + * @webglOnly + * @since 4.0.0 + * @param {boolean} value - Whether the filters should focus on the context. + * @return {this} + */ + setFiltersFocusContext: function (value) + { + this.filtersFocusContext = value; + + return this; + }, + + /** + * Set whether the filters should always draw to a framebuffer. + * Sets the `filtersForceComposite` property. + * + * @method Phaser.GameObjects.Components.Filters#setFiltersForceComposite + * @webglOnly + * @since 4.0.0 + * @param {boolean} value - Whether the object should always draw to a framebuffer, even if there are no active filters. + * @return {this} + */ + setFiltersForceComposite: function (value) + { + this.filtersForceComposite = value; + + return this; + }, + + /** + * Set whether the filters should be rendered. + * Sets the `renderFilters` property. + * + * @method Phaser.GameObjects.Components.Filters#setRenderFilters + * @webglOnly + * @since 4.0.0 + * @param {boolean} value - Whether the filters should be rendered. + * @return {this} + */ + setRenderFilters: function (value) + { + this.renderFilters = value; + + return this; + } + }; +} + +module.exports = Filters; + + +/***/ }, + +/***/ 54434 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods used for visually flipping a Game Object along its horizontal and/or vertical axes. + * + * Flipping mirrors the rendered texture without altering the Game Object's scale, position, or physics body. + * The flip always pivots from the centre of the texture. This component is intended to be mixed in to + * Game Object classes and should not be used directly. + * + * @namespace Phaser.GameObjects.Components.Flip + * @since 3.0.0 + */ + +var Flip = { + + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inverted on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inverted on the vertical axis (i.e. upside down). + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inverted on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * A Game Object that is flipped vertically will render inverted on the vertical axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inverted on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * A Game Object that is flipped vertically will render inverted on the vertical axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * A Game Object that is flipped will render inverted on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The vertical flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } + +}; + +module.exports = Flip; + + +/***/ }, + +/***/ 8004 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); +var RotateAround = __webpack_require__(11520); +var Vector2 = __webpack_require__(26099); + +/** + * Provides methods used for obtaining the bounds of a Game Object, including + * its corners, edge midpoints, center point, and overall axis-aligned bounding + * rectangle. All methods account for the Game Object's rotation and display + * size, and can optionally factor in any parent Container transforms. + * Should be applied as a mixin and not used directly. + * + * @namespace Phaser.GameObjects.Components.GetBounds + * @since 3.0.0 + */ + +var GetBounds = { + + /** + * Processes the bounds output vector before returning it. + * + * @method Phaser.GameObjects.Components.GetBounds#prepareBoundsOutput + * @private + * @since 3.18.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} output - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + prepareBoundsOutput: function (output, includeParent) + { + if (includeParent === undefined) { includeParent = false; } + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + if (includeParent && this.parentContainer) + { + var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); + + parentMatrix.transformPoint(output.x, output.y, output); + } + + return output; + }, + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getCenter + * @since 3.0.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getCenter: function (output, includeParent) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getTopLeft + * @since 3.0.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getTopLeft: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX); + output.y = this.y - (this.displayHeight * this.originY); + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getTopCenter + * @since 3.18.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getTopCenter: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY); + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getTopRight + * @since 3.0.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getTopRight: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; + output.y = this.y - (this.displayHeight * this.originY); + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getLeftCenter + * @since 3.18.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getLeftCenter: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX); + output.y = (this.y - (this.displayHeight * this.originY)) + (this.displayHeight / 2); + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getRightCenter + * @since 3.18.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getRightCenter: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; + output.y = (this.y - (this.displayHeight * this.originY)) + (this.displayHeight / 2); + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft + * @since 3.0.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getBottomLeft: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX); + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomCenter + * @since 3.18.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getBottomCenter: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + (this.displayWidth / 2); + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomRight + * @since 3.0.0 + * + * @generic {Phaser.Types.Math.Vector2Like} O - [output,$return] + * + * @param {Phaser.Types.Math.Vector2Like} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? + * + * @return {Phaser.Types.Math.Vector2Like} The values stored in the output object. + */ + getBottomRight: function (output, includeParent) + { + if (!output) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; + + return this.prepareBoundsOutput(output, includeParent); + }, + + /** + * Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin. + * + * The bounding rectangle is computed by retrieving all four corner positions of the + * Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation + * and parent Container transforms, and then calculating the smallest axis-aligned + * rectangle that fully encloses all four points. + * + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * + * @method Phaser.GameObjects.Components.GetBounds#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [output,$return] + * + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + // We can use the output object to temporarily store the x/y coords in: + + var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; + + // Instead of doing a check if parent container is + // defined per corner we only do it once. + if (this.parentContainer) + { + var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); + + this.getTopLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BRx = output.x; + BRy = output.y; + } + else + { + this.getTopLeft(output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + + BRx = output.x; + BRy = output.y; + } + + output.x = Math.min(TLx, TRx, BLx, BRx); + output.y = Math.min(TLy, TRy, BLy, BRy); + output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; + output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; + + return output; + } + +}; + +module.exports = GetBounds; + + +/***/ }, + +/***/ 73629 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods for enabling WebGL-based per-pixel lighting effects on a Game Object, + * using normal maps to simulate surface depth under dynamic light sources. + * + * When lighting is enabled, the Game Object will respond to lights added to the scene + * via the Lights plugin. This component also supports self-shadowing, which creates + * contact shadows on the surface based on the object's normal map. + * + * This component should only be applied to Game Objects that have RenderNodes, and + * requires the WebGL renderer. It has no effect in Canvas rendering mode. + * + * @namespace Phaser.GameObjects.Components.Lighting + * @webglOnly + * @since 4.0.0 + */ +var Lighting = { + + /** + * Controls whether this Game Object participates in the WebGL lighting system. + * When `true`, the object will respond to dynamic lights added via the Lights plugin, + * using normal maps to calculate per-pixel diffuse lighting. + * + * This flag is used to select the appropriate WebGL shader at render time. + * + * @name Phaser.GameObjects.Components.Lighting#lighting + * @type {boolean} + * @webglOnly + * @since 4.0.0 + * @default false + * @readonly + */ + lighting: false, + + /** + * Configuration object controlling self-shadowing for this Game Object. + * Self-shadowing causes surfaces to cast contact shadows on themselves based on + * the normal map, giving the appearance of depth. It is only active when + * `lighting` is also enabled. + * + * If `enabled` is `null`, the value from the game config option `render.selfShadow` + * is used instead. + * + * This object is used to select and configure the appropriate WebGL shader at render time. + * + * @name Phaser.GameObjects.Components.Lighting#selfShadow + * @type {{ enabled: boolean, penumbra: number, diffuseFlatThreshold: number }} + * @webglOnly + * @since 4.0.0 + */ + selfShadow: { + enabled: null, + penumbra: 0.5, + diffuseFlatThreshold: 1 / 3 + }, + + /** + * Enables or disables WebGL-based per-pixel lighting for this Game Object. + * When enabled, the object will respond to dynamic lights added to the scene + * via the Lights plugin, using a normal map for lighting calculations. + * Disabling lighting restores the standard unlit rendering path. + * + * @method Phaser.GameObjects.Components.Lighting#setLighting + * @webglOnly + * @since 4.0.0 + * @param {boolean} enable - `true` to use lighting, or `false` to disable it. + * @return {this} This GameObject instance. + */ + setLighting: function (enable) + { + this.lighting = enable; + + return this; + }, + + /** + * Configures the self-shadowing properties of this Game Object. + * Self-shadowing uses the normal map to cast contact shadows on the surface itself, + * giving the impression of depth and raised detail. It is only active when + * `lighting` is also enabled on this Game Object. + * + * Parameters that are `undefined` are left unchanged, allowing partial updates. + * + * @method Phaser.GameObjects.Components.Lighting#setSelfShadow + * @webglOnly + * @since 4.0.0 + * @param {?boolean} [enabled] - `true` to use self-shadowing, `false` to disable it, `null` to use the game default from `config.render.selfShadow`, or `undefined` to keep the setting. + * @param {number} [penumbra] - The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5. + * @param {number} [diffuseFlatThreshold] - The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3. + * @return {this} This GameObject instance. + */ + setSelfShadow: function (enabled, penumbra, diffuseFlatThreshold) + { + if (enabled !== undefined) + { + if (enabled === null) + { + this.selfShadow.enabled = this.scene.sys.game.config.selfShadow; + } + else + { + this.selfShadow.enabled = enabled; + } + } + + if (penumbra !== undefined) + { + this.selfShadow.penumbra = penumbra; + } + + if (diffuseFlatThreshold !== undefined) + { + this.selfShadow.diffuseFlatThreshold = diffuseFlatThreshold; + } + + return this; + } +}; + +module.exports = Lighting; + + +/***/ }, + +/***/ 8573 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(8054); +var GeometryMask = __webpack_require__(80661); + +/** + * Provides methods used for setting, clearing, and creating masks on a Game Object. + * + * A mask clips the rendered output of a Game Object to the shape defined by a Graphics + * or Shape Game Object. Only pixels that fall within the mask geometry are drawn to the screen. + * Masks have no effect on physics or input detection; they are purely a visual rendering tool. + * + * This component only works under the Canvas Renderer. + * For WebGL, see {@link Phaser.GameObjects.Components.FilterList#addMask}. + * + * @namespace Phaser.GameObjects.Components.Mask + * @since 3.0.0 + */ + +var Mask = { + + /** + * The Mask this Game Object is using during render, or `null` if no mask has been set. + * + * @name Phaser.GameObjects.Components.Mask#mask + * @type {Phaser.Display.Masks.GeometryMask} + * @since 3.0.0 + */ + mask: null, + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and must be a GeometryMask. + * This only works in the Canvas Renderer. + * In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}). + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * + * @method Phaser.GameObjects.Components.Mask#setMask + * @since 3.6.2 + * + * @param {Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. + * + * @return {this} This Game Object instance. + */ + setMask: function (mask) + { + if (this.scene.renderer.type === CONST.WEBGL) + { + console.warn('Phaser.GameObjects.Components.Mask.setMask: This method is not supported in WebGL. Create a Mask filter instead.'); + return this; + } + + this.mask = mask; + + return this; + }, + + /** + * Clears the mask that this Game Object was using. + * + * This only works in the Canvas Renderer. + * In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}). + * + * @method Phaser.GameObjects.Components.Mask#clearMask + * @since 3.6.2 + * + * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? + * + * @return {this} This Game Object instance. + */ + clearMask: function (destroyMask) + { + if (destroyMask === undefined) { destroyMask = false; } + + if (destroyMask && this.mask) + { + this.mask.destroy(); + } + + this.mask = null; + + return this; + }, + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * + * This only works in the Canvas Renderer. + * In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}). + * + * @method Phaser.GameObjects.Components.Mask#createGeometryMask + * @since 3.6.2 + * + * @generic {Phaser.GameObjects.Graphics} G + * @generic {Phaser.GameObjects.Shape} S + * @genericUse {(G|S)} [graphics] + * + * @param {Phaser.GameObjects.Graphics|Phaser.GameObjects.Shape} [graphics] - A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * + * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. + */ + createGeometryMask: function (graphics) + { + if (graphics === undefined && (this.type === 'Graphics' || this.geom)) + { + // eslint-disable-next-line consistent-this + graphics = this; + } + + return new GeometryMask(this.scene, graphics); + } + +}; + +module.exports = Mask; + + +/***/ }, + +/***/ 27387 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + * + * @namespace Phaser.GameObjects.Components.Origin + * @since 3.0.0 + */ + +var Origin = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Origin#_originComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _originComponent: true, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + * + * @name Phaser.GameObjects.Components.Origin#originX + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originX: 0.5, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + * + * @name Phaser.GameObjects.Components.Origin#originY + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originY: 0.5, + + // private + read only + _displayOriginX: 0, + _displayOriginY: 0, + + /** + * The horizontal display origin of this Game Object, expressed in pixels. + * Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the + * calculated pixel offset derived from the Game Object's width multiplied by its `originX` value. + * Setting this property updates `originX` accordingly. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginX + * @type {number} + * @since 3.0.0 + */ + displayOriginX: { + + get: function () + { + return this._displayOriginX; + }, + + set: function (value) + { + this._displayOriginX = value; + this.originX = value / this.width; + } + + }, + + /** + * The vertical display origin of this Game Object, expressed in pixels. + * Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the + * calculated pixel offset derived from the Game Object's height multiplied by its `originY` value. + * Setting this property updates `originY` accordingly. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginY + * @type {number} + * @since 3.0.0 + */ + displayOriginY: { + + get: function () + { + return this._displayOriginY; + }, + + set: function (value) + { + this._displayOriginY = value; + this.originY = value / this.height; + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.Components.Origin#setOrigin + * @since 3.0.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + * If the Frame has a custom pivot point defined, the origin is set to match it. + * If the Frame does not have a custom pivot, this method falls back to `setOrigin()`, + * resetting the origin to the default value of 0.5 for both axes. + * + * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + setOriginFromFrame: function () + { + if (!this.frame || !this.frame.customPivot) + { + return this.setOrigin(); + } + else + { + this.originX = this.frame.pivotX; + this.originY = this.frame.pivotY; + } + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * + * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal display origin value. + * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setDisplayOrigin: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.displayOriginX = x; + this.displayOriginY = y; + + return this; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._displayOriginX = this.originX * this.width; + this._displayOriginY = this.originY * this.height; + + return this; + } + +}; + +module.exports = Origin; + + +/***/ }, + +/***/ 37640 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DegToRad = __webpack_require__(39506); +var GetBoolean = __webpack_require__(57355); +var GetValue = __webpack_require__(35154); +var TWEEN_CONST = __webpack_require__(86353); +var Vector2 = __webpack_require__(26099); + +/** + * Provides methods for making a Game Object follow a {@link Phaser.Curves.Path} at a configurable speed. + * The follower uses an internal Tween to animate progress along the path, and can optionally rotate + * the Game Object to face the direction of travel. This component is mixed in to Game Objects such as + * {@link Phaser.GameObjects.PathFollower} and should be applied as a mixin rather than used directly. + * + * @namespace Phaser.GameObjects.Components.PathFollower + * @since 3.17.0 + */ + +var PathFollower = { + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + * + * @name Phaser.GameObjects.Components.PathFollower#path + * @type {Phaser.Curves.Path} + * @since 3.0.0 + */ + path: null, + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + * + * @name Phaser.GameObjects.Components.PathFollower#rotateToPath + * @type {boolean} + * @default false + * @since 3.0.0 + */ + rotateToPath: false, + + /** + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.Components.PathFollower#rotateToPath) + * this value is added to the rotation value, in degrees. This allows you to rotate objects to a path but control + * the angle of the rotation as well. + * + * @name Phaser.GameObjects.Components.PathFollower#pathRotationOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + pathRotationOffset: 0, + + /** + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. + * + * @name Phaser.GameObjects.PathFollower#pathOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + pathOffset: null, + + /** + * A Vector2 that stores the current point of the path the follower is on. + * + * @name Phaser.GameObjects.PathFollower#pathVector + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + pathVector: null, + + /** + * The distance the follower has traveled from the previous point to the current one, at the last update. + * + * @name Phaser.GameObjects.PathFollower#pathDelta + * @type {Phaser.Math.Vector2} + * @since 3.23.0 + */ + pathDelta: null, + + /** + * The Tween used for following the Path. + * + * @name Phaser.GameObjects.PathFollower#pathTween + * @type {Phaser.Tweens.Tween} + * @since 3.0.0 + */ + pathTween: null, + + /** + * Settings for the PathFollower. + * + * @name Phaser.GameObjects.PathFollower#pathConfig + * @type {?Phaser.Types.GameObjects.PathFollower.PathConfig} + * @default null + * @since 3.0.0 + */ + pathConfig: null, + + /** + * Records the direction of the follower so it can change direction. + * + * @name Phaser.GameObjects.PathFollower#_prevDirection + * @type {number} + * @private + * @since 3.0.0 + */ + _prevDirection: TWEEN_CONST.PLAYING_FORWARD, + + /** + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link Phaser.Types.GameObjects.PathFollower.PathConfig} settings. + * + * @method Phaser.GameObjects.Components.PathFollower#setPath + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {(number|Phaser.Types.GameObjects.PathFollower.PathConfig|Phaser.Types.Tweens.NumberTweenBuilderConfig)} [config] - Settings for the PathFollower. + * + * @return {this} This Game Object. + */ + setPath: function (path, config) + { + if (config === undefined) { config = this.pathConfig; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + this.path = path; + + if (config) + { + this.startFollow(config); + } + + return this; + }, + + /** + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * + * @method Phaser.GameObjects.Components.PathFollower#setRotateToPath + * @since 3.0.0 + * + * @param {boolean} value - Whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param {number} [offset=0] - Rotation offset in degrees. + * + * @return {this} This Game Object. + */ + setRotateToPath: function (value, offset) + { + if (offset === undefined) { offset = 0; } + + this.rotateToPath = value; + + this.pathRotationOffset = offset; + + return this; + }, + + /** + * Is this PathFollower actively following a Path or not? + * + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * + * @method Phaser.GameObjects.Components.PathFollower#isFollowing + * @since 3.0.0 + * + * @return {boolean} `true` if this PathFollower is actively following a Path, otherwise `false`. + */ + isFollowing: function () + { + var tween = this.pathTween; + + return (tween && tween.isPlaying()); + }, + + /** + * Starts this PathFollower following its given Path. + * + * @method Phaser.GameObjects.Components.PathFollower#startFollow + * @since 3.3.0 + * + * @param {(number|Phaser.Types.GameObjects.PathFollower.PathConfig|Phaser.Types.Tweens.NumberTweenBuilderConfig)} [config={}] - The duration of the follow, or a PathFollower config object. + * @param {number} [startAt=0] - Optional start position of the follow, between 0 and 1. + * + * @return {this} This Game Object. + */ + startFollow: function (config, startAt) + { + if (config === undefined) { config = {}; } + if (startAt === undefined) { startAt = 0; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + if (typeof config === 'number') + { + config = { duration: config }; + } + + // Override in case they've been specified in the config + config.from = GetValue(config, 'from', 0); + config.to = GetValue(config, 'to', 1); + + var positionOnPath = GetBoolean(config, 'positionOnPath', false); + + this.rotateToPath = GetBoolean(config, 'rotateToPath', false); + this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); + + // This works, but it's not an ideal way of doing it as the follower jumps position + var seek = GetValue(config, 'startAt', startAt); + + if (seek) + { + config.onStart = function (tween) + { + var tweenData = tween.data[0]; + tweenData.progress = seek; + tweenData.elapsed = tweenData.duration * seek; + var v = tweenData.ease(tweenData.progress); + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + tweenData.setTargetValue(); + }; + } + + if (!this.pathOffset) + { + this.pathOffset = new Vector2(this.x, this.y); + } + + if (!this.pathVector) + { + this.pathVector = new Vector2(); + } + + if (!this.pathDelta) + { + this.pathDelta = new Vector2(); + } + + this.pathDelta.reset(); + + config.persist = true; + + this.pathTween = this.scene.sys.tweens.addCounter(config); + + // The starting point of the path, relative to this follower + this.path.getStartPoint(this.pathOffset); + + if (positionOnPath) + { + this.x = this.pathOffset.x; + this.y = this.pathOffset.y; + } + + this.pathOffset.x = this.x - this.pathOffset.x; + this.pathOffset.y = this.y - this.pathOffset.y; + + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + + if (this.rotateToPath) + { + // Set the rotation now (in case the tween has a delay on it, etc) + var nextPoint = this.path.getPoint(0.1); + + this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); + } + + this.pathConfig = config; + + return this; + }, + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + * + * @method Phaser.GameObjects.Components.PathFollower#pauseFollow + * @since 3.3.0 + * + * @return {this} This Game Object. + */ + pauseFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.pause(); + } + + return this; + }, + + /** + * Resumes a previously paused PathFollower. + * + * If the PathFollower was not paused this has no effect. + * + * @method Phaser.GameObjects.Components.PathFollower#resumeFollow + * @since 3.3.0 + * + * @return {this} This Game Object. + */ + resumeFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPaused()) + { + tween.resume(); + } + + return this; + }, + + /** + * Stops this PathFollower from following the path any longer. + * + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * + * @method Phaser.GameObjects.Components.PathFollower#stopFollow + * @since 3.3.0 + * + * @return {this} This Game Object. + */ + stopFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + return this; + }, + + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + * + * @method Phaser.GameObjects.Components.PathFollower#pathUpdate + * @since 3.17.0 + */ + pathUpdate: function () + { + var tween = this.pathTween; + + if (tween && tween.data) + { + var tweenData = tween.data[0]; + var pathDelta = this.pathDelta; + var pathVector = this.pathVector; + + pathDelta.copy(pathVector).negate(); + + if (tweenData.state === TWEEN_CONST.COMPLETE) + { + this.path.getPoint(tweenData.end, pathVector); + + pathDelta.add(pathVector); + pathVector.add(this.pathOffset); + + this.setPosition(pathVector.x, pathVector.y); + + return; + } + else if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) + { + // If delayed, etc then bail out + return; + } + + this.path.getPoint(tween.getValue(), pathVector); + + pathDelta.add(pathVector); + pathVector.add(this.pathOffset); + + var oldX = this.x; + var oldY = this.y; + + this.setPosition(pathVector.x, pathVector.y); + + var speedX = this.x - oldX; + var speedY = this.y - oldY; + + if (speedX === 0 && speedY === 0) + { + // Bail out early + return; + } + + if (tweenData.state !== this._prevDirection) + { + // We've changed direction, so don't do a rotate this frame + this._prevDirection = tweenData.state; + + return; + } + + if (this.rotateToPath) + { + this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); + } + } + } + +}; + +module.exports = PathFollower; + + +/***/ }, + +/***/ 68680 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DeepCopy = __webpack_require__(62644); + +/** + * Provides methods for configuring WebGL render nodes on a Game Object. Render nodes are modular units responsible for different phases of the rendering pipeline (submitting draw calls, transforming vertices, handling textures). Each Game Object has a set of default render nodes, but you can override them with custom nodes for advanced rendering effects. This component is WebGL only. + * + * @namespace Phaser.GameObjects.Components.RenderNodes + * @webglOnly + * @since 4.0.0 + */ +var RenderNodes = { + /** + * Customized WebGL render nodes of this Game Object. + * RenderNodes are responsible for managing the rendering process of this Game Object. + * A default set of RenderNodes is coded into the engine, + * but the renderer will check this object first to see if a custom node has been set. + * + * @name Phaser.GameObjects.Components.RenderNodes#customRenderNodes + * @type {object} + * @webglOnly + * @since 4.0.0 + */ + customRenderNodes: null, + + /** + * The default RenderNodes for this Game Object. + * RenderNodes are responsible for managing the rendering process of this Game Object. + * These are the nodes that are used if no custom ones are set. + * + * RenderNodes are identified by a unique key for their role. + * + * Common role keys include: + * + * - 'Submitter': responsible for running other node roles for each element. + * - 'Transformer': responsible for providing vertex coordinates for an element. + * - 'Texturer': responsible for handling textures for an element. + * + * @name Phaser.GameObjects.Components.RenderNodes#defaultRenderNodes + * @type {object} + * @webglOnly + * @since 4.0.0 + */ + defaultRenderNodes: null, + + /** + * An object to store render node specific data in, to be read by the render nodes this Game Object uses. + * + * Render nodes store their data under their own name, not their role. + * + * @name Phaser.GameObjects.Components.RenderNodes#renderNodeData + * @type {object} + * @webglOnly + * @since 4.0.0 + */ + renderNodeData: null, + + /** + * Initializes the render nodes for this Game Object. + * + * This method is called when the Game Object is added to the Scene. + * It is responsible for setting up the default render nodes + * this Game Object will use. + * + * @method Phaser.GameObjects.Components.RenderNodes#initRenderNodes + * @webglOnly + * @since 4.0.0 + * @param {Map} defaultNodes - The default render nodes to set for this Game Object. + */ + initRenderNodes: function (defaultNodes) + { + this.customRenderNodes = {}; + this.defaultRenderNodes = {}; + this.renderNodeData = {}; + + var renderer = this.scene.sys.renderer; + + if (!renderer) + { + return; + } + + var manager = renderer.renderNodes; + + if (!(manager && defaultNodes)) + { + return; + } + + var defaultRenderNodes = this.defaultRenderNodes; + defaultNodes.each(function (role, node) + { + defaultRenderNodes[role] = manager.getNode(node); + }); + }, + + /** + * Sets the RenderNode for a given role. + * + * Also sets the relevant render node data object, if specified. + * + * If the node cannot be set, no changes are made. + * + * @method Phaser.GameObjects.Components.RenderNodes#setRenderNodeRole + * @webglOnly + * @since 4.0.0 + * @param {string} key - The key of the role to set the render node for. + * @param {string|Phaser.Renderer.WebGL.RenderNodes.RenderNode|null} renderNode - The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data. + * @param {object} [renderNodeData] - An object to store render node specific data in, to be read by the render nodes this Game Object uses. + * @param {boolean} [copyData=false] - Should the data be copied from the `renderNodeData` object? + * @return {this} This Game Object instance. + */ + setRenderNodeRole: function (key, renderNode, renderNodeData, copyData) + { + var renderer = this.scene.sys.renderer; + + if (!renderer) + { + return this; + } + + var manager = renderer.renderNodes; + + if (!manager) + { + return this; + } + + if (renderNode !== null) + { + if (typeof renderNode === 'string') + { + renderNode = manager.getNode(renderNode); + } + if (!renderNode) + { + return this; + } + this.customRenderNodes[key] = renderNode; + + if (renderNodeData) + { + this.renderNodeData[renderNode.name] = copyData ? DeepCopy(renderNodeData) : renderNodeData; + } + else + { + this.renderNodeData[renderNode.name] = {}; + } + } + else + { + var node = this.customRenderNodes[key]; + if (node) + { + delete this.renderNodeData[node.name]; + delete this.customRenderNodes[key]; + } + } + + return this; + }, + + /** + * Sets or removes a property in the data object for a specific render node within `renderNodeData`. + * + * If `key` is not set, it is created. If it is set, it is updated. + * + * If `value` is undefined and `key` exists, the key is removed. + * + * @method Phaser.GameObjects.Components.RenderNodes#setRenderNodeData + * @webglOnly + * @since 4.0.0 + * @param {string|Phaser.Renderer.WebGL.RenderNodes.RenderNode} renderNode - The render node to set the data for. If a string, it should be the name of the render node. + * @param {string} key - The key of the property to set. + * @param {*} value - The value to set the property to. + * @return {this} This Game Object instance. + */ + setRenderNodeData: function (renderNode, key, value) + { + var name = renderNode; + if (typeof renderNode !== 'string') + { + name = renderNode.name; + } + var data = this.renderNodeData[name]; + + if (value === undefined) + { + delete data[key]; + } + else + { + data[key] = value; + } + + return this; + } +}; + +module.exports = RenderNodes; + + +/***/ }, + +/***/ 86038 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Handles render steps for a Game Object. + * The render step is a point in the render process that allows you to inject your own logic. + * + * @namespace Phaser.GameObjects.Components.RenderSteps + * @webglOnly + * @since 4.0.0 + */ +var RenderSteps = {}; + +if (true) +{ + RenderSteps = { + /** + * The list of steps to run when this Game Object is rendered. + * This is used by `renderWebGLStep` to kick off rendering. + * The functions in this list are responsible for invoking any + * subsequent functions. + * + * @name Phaser.GameObjects.Components.RenderSteps#_renderSteps + * @private + * @webglOnly + * @since 4.0.0 + * @type {Phaser.Types.GameObjects.RenderWebGLStep[]} + */ + _renderSteps: null, + + /** + * Run a step in the render process. + * This is called automatically by the Render module. + * + * In most cases, it just runs the `renderWebGL` function. + * + * When `_renderSteps` has more than one entry, + * such as when Filters are enabled for this object, + * it allows those processes to defer `renderWebGL` + * and otherwise manage the flow of rendering. + * + * @method Phaser.GameObjects.Components.RenderSteps#renderWebGLStep + * @webglOnly + * @since 4.0.0 + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to render with. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - The parent matrix of the Game Object, if it has one. + * @param {number} [renderStep=0] - Which step of the rendering process should be run? + * @param {Phaser.GameObjects.GameObject[]} [displayList] - The display list which is currently being rendered. If not provided, it will be created with the Game Object. + * @param {number} [displayListIndex=0] - The index of the Game Object within the display list. + */ + renderWebGLStep: function ( + renderer, + gameObject, + drawingContext, + parentMatrix, + renderStep, + displayList, + displayListIndex + ) + { + if (renderStep === undefined) + { + renderStep = 0; + } + + var fn = gameObject._renderSteps[renderStep]; + + if (!fn) + { + return; + } + + if (!displayList) + { + displayList = [ gameObject ]; + displayListIndex = 0; + } + else if (displayListIndex === undefined) + { + displayListIndex = 0; + } + + fn(renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex); + }, + + /** + * Adds a render step function to this Game Object's WebGL render pipeline. + * + * The first render step in `_renderSteps` is run first. + * It should call the next render step in the list. + * This allows render steps to control the rendering flow. + * + * @method Phaser.GameObjects.Components.RenderSteps#addRenderStep + * @param {Phaser.Types.GameObjects.RenderWebGLStep} fn - The render step function to add. + * @param {number} [index] - The index in the render list to add the step to. Omit to add to the end. + * + * @return {this} This Game Object instance. + */ + addRenderStep: function (fn, index) + { + if (!this._renderSteps) + { + this._renderSteps = []; + } + + if (index === undefined) + { + this._renderSteps.push(fn); + return this; + } + + this._renderSteps.splice(index, 0, fn); + + return this; + } + }; +} + +module.exports = RenderSteps; + + +/***/ }, + +/***/ 80227 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods used for setting the Scroll Factor of a Game Object. + * + * @namespace Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 + */ + +var ScrollFactor = { + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken into consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken into consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the horizontal and vertical scroll factor of this Game Object. If only the `x` value is + * provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX` + * and `scrollFactorY` in a single call. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken into consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } + +}; + +module.exports = ScrollFactor; + + +/***/ }, + +/***/ 16736 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods used for getting and setting the size of a Game Object. + * + * This component distinguishes between two size concepts. The native size (`width` and `height`) + * is the un-scaled logical size, typically derived from the Game Object's texture frame. The + * display size (`displayWidth` and `displayHeight`) is the actual rendered size in pixels, which + * factors in the Game Object's scale. Setting the display size adjusts the scale automatically, + * while setting the native size does not affect rendering directly. + * + * This component is mixed into Game Objects such as Sprites and Images by the Phaser Game Object + * Factory and is not intended to be used standalone. + * + * @namespace Phaser.GameObjects.Components.Size + * @since 3.0.0 + */ + +var Size = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Size#_sizeComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _sizeComponent: true, + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.Size#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.Size#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return Math.abs(this.scaleX * this.frame.realWidth); + }, + + set: function (value) + { + this.scaleX = value / this.frame.realWidth; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return Math.abs(this.scaleY * this.frame.realHeight); + }, + + set: function (value) + { + this.scaleY = value / this.frame.realHeight; + } + + }, + + /** + * Sets the size of this Game Object to be that of the given Frame or the current Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input with a custom hit area, changing the size of the Game Object will _not_ change the + * size of the hit area. If you wish to do this, you should adjust the `input.hitArea` object directly. + * If you have enabled this Game Object for input without a custom hit area, the hit area will be automatically resized to match the size of the selected Frame. + * + * @method Phaser.GameObjects.Components.Size#setSizeToFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame} [frame] - The frame to base the size of this Game Object on. The default is the current frame of the Game Object. + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function (frame) + { + if (!frame) { frame = this.frame; } + + this.width = frame.realWidth; + this.height = frame.realHeight; + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = this.width; + input.hitArea.height = this.height; + } + + return this; + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display (rendered) size of this Game Object in pixels. + * + * Unlike `setSize`, which changes the native logical dimensions without affecting rendering, + * this method adjusts the `scaleX` and `scaleY` properties so that the Game Object appears + * at exactly the given pixel dimensions in-game. It is equivalent to calculating and setting + * the scale manually, but more convenient when you want to work in pixel values directly. + * + * @method Phaser.GameObjects.Components.Size#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = Size; + + +/***/ }, + +/***/ 43520 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Provides methods used for modifying the stencil buffer. + * This component is mixed in to Game Objects that can modify the stencil buffer, + * such as Stencil and StencilReference. + * + * StencilModifier objects are assumed to draw to the stencil buffer. + * The `isStencilModifier` property is checked to determine whether + * extra compositing steps are necessary within other StencilModifier objects. + * + * @namespace Phaser.GameObjects.Components.StencilModifier + * @since 4.2.0 + */ + +var StencilModifier = { + /** + * The mode to use when rendering the stencil. + * + * - 'addLayer' - Add a stencil layer. + * - 'subtractLayer' - Subtract a stencil layer. + * - 'clear' - Clear the stencil buffer. + * - 'clearRegion' - Clear a region of the stencil buffer. + * + * @name Phaser.GameObjects.Components.StencilModifier#stencilLayerMode + * @since 4.2.0 + * @type {Phaser.Types.GameObjects.Stencil.StencilLayerMode} + * @default 'addLayer' + */ + stencilLayerMode: 'addLayer', + + /** + * Whether to invert the stencil, using an extra draw call. + * + * @name Phaser.GameObjects.Components.StencilModifier#stencilInvert + * @since 4.2.0 + * @type {boolean} + * @default false + */ + stencilInvert: false, + + /** + * The alpha strategy to use when rendering the stencil. + * This is usually set to `dither`, or the default game config setting. + * + * @name Phaser.GameObjects.Components.StencilModifier#stencilAlphaStrategy + * @since 4.2.0 + * @type {Phaser.Types.Renderer.WebGL.AlphaStrategy} + * @default 'dither' + */ + stencilAlphaStrategy: 'dither', + + /** + * Whether to composite the contents of the stencil to a framebuffer. + * This is necessary when the stencil contains stencils. + * It requires extra draw calls to composite. + * You should set this to `false` or `true` if you know the answer, + * or `auto` to have Phaser automatically determine the best option. + * + * This will set `filtersForceComposite` to `true` during rendering. + * + * @name Phaser.GameObjects.Components.StencilModifier#stencilCompositeCheck + * @since 4.2.0 + * @type {boolean|'auto'} + * @default 'auto' + */ + stencilCompositeCheck: 'auto', + + /** + * The value to clear the stencil buffer to, + * if the `stencilLayerMode` is `clear` or `clearRegion`. + * Should be between 0 and 255, as the buffer is 8 bits. + * + * @name Phaser.GameObjects.Components.StencilModifier#stencilClearValue + * @since 4.2.0 + * @type {number} + * @default 0 + */ + stencilClearValue: 0, + + /** + * Whether to wrap the value in the stencil buffer when it overflows or underflows + * when using the `addLayer` or `subtractLayer` mode. + * This is useful when defining stencils with subtraction, + * and you don't want to underflow from 0 to 255. + * + * @name Phaser.GameObjects.Components.StencilModifier#stencilValueWrap + * @since 4.2.0 + * @type {boolean} + * @default true + */ + stencilValueWrap: true, + + /** + * Whether this Game Object is a stencil modifier. + * Do not edit this property. It is used internally. + * + * Any object with `isStencilModifier` set to `true` is a positive result + * for `hasStencilChildren`, and can affect stencil compositing. + * + * @name Phaser.GameObjects.Components.StencilModifier#isStencilModifier + * @since 4.2.0 + * @type {boolean} + * @readonly + * @default true + */ + isStencilModifier: { + get: function() { + return true; + }, + set: function(value) { + // Do nothing + } + }, + + /** + * Sets the alpha strategy to use when rendering the stencil. + * + * @method Phaser.GameObjects.Components.StencilModifier#setStencilAlphaStrategy + * @since 4.2.0 + * @param {Phaser.Types.Renderer.WebGL.AlphaStrategy} stencilAlphaStrategy - The alpha strategy to use when rendering the stencil. + * @returns {this} This Game Object instance. + */ + setStencilAlphaStrategy: function (stencilAlphaStrategy) + { + this.stencilAlphaStrategy = stencilAlphaStrategy; + return this; + }, + + /** + * Sets the value to clear the stencil to, + * if the `stencilLayerMode` is `clear` or `clearRegion`. + * Should be between 0 and 255, as the buffer is 8 bits. + * + * @method Phaser.GameObjects.Components.StencilModifier#setStencilClearValue + * @since 4.2.0 + * @param {number} stencilClearValue - The value to clear the stencil buffer to. + * @returns {this} This Game Object instance. + */ + setStencilClearValue: function (stencilClearValue) + { + this.stencilClearValue = stencilClearValue; + return this; + }, + + /** + * Sets whether to composite the contents of the stencil to a framebuffer. + * While `auto` is default, it must run extra checks, + * so you should set it to `true` or `false` if you know the answer. + * + * - `true` - Composite the contents of the stencil to a framebuffer. + * - `false` - Do not composite the contents of the stencil to a framebuffer. + * - `'auto'` - Automatically determine whether to composite the contents of the stencil to a framebuffer. + * + * @method Phaser.GameObjects.Components.StencilModifier#setStencilCompositeCheck + * @since 4.2.0 + * @param {boolean|'auto'} stencilCompositeCheck - The check mode to use. + * @returns {this} This Game Object instance. + */ + setStencilCompositeCheck: function (stencilCompositeCheck) + { + this.stencilCompositeCheck = stencilCompositeCheck; + return this; + }, + + /** + * Sets whether to invert the stencil, using an extra draw call. + * + * @method Phaser.GameObjects.Components.StencilModifier#setStencilInvert + * @since 4.2.0 + * @param {boolean} stencilInvert - Whether to invert the stencil. + * @returns {this} This Game Object instance. + */ + setStencilInvert: function (stencilInvert) + { + this.stencilInvert = stencilInvert; + return this; + }, + + /** + * Sets the mode to use when rendering the stencil. + * + * - 'addLayer' - Add a stencil layer. + * - 'subtractLayer' - Subtract a stencil layer. + * - 'clear' - Clear the whole stencil buffer. + * - 'clearRegion' - Clear a specific region of the stencil buffer. + * You can also use this to fill a region with a specific value. + * + * @method Phaser.GameObjects.Components.StencilModifier#setStencilLayerMode + * @since 4.2.0 + * @param {Phaser.Types.GameObjects.Stencil.StencilLayerMode} stencilLayerMode - The mode which the Stencil should run in. + * @returns {this} This Game Object instance. + */ + setStencilLayerMode: function (stencilLayerMode) + { + this.stencilLayerMode = stencilLayerMode; + return this; + }, + + /** + * Sets whether to wrap the value in the stencil buffer when it overflows or underflows. + * This is useful when defining stencils with subtraction, + * and you don't want to underflow from 0 to 255. + * + * @method Phaser.GameObjects.Components.StencilModifier#setStencilValueWrap + * @since 4.2.0 + * @param {boolean} stencilValueWrap - Whether to wrap the value in the stencil buffer when it overflows or underflows. + * @returns {this} This Game Object instance. + */ + setStencilValueWrap: function (stencilValueWrap) + { + this.stencilValueWrap = stencilValueWrap; + return this; + } +}; + +module.exports = StencilModifier; + + +/***/ }, + +/***/ 37726 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Frame = __webpack_require__(4327); + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for setting the texture and frame of a Game Object. + * + * This component is mixed in to Game Objects that support texture-based rendering, + * such as Sprites and Images. It allows a Game Object to reference a texture stored + * in the Texture Manager by key, and optionally a specific frame within that texture, + * as used with texture atlases and sprite sheets. Changing the texture or frame will + * automatically update the Game Object's size and origin to match. + * + * @namespace Phaser.GameObjects.Components.Texture + * @since 3.0.0 + */ + +var Texture = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * Internal flag. Not to be set by this Game Object. + * + * @name Phaser.GameObjects.Components.Texture#isCropped + * @type {boolean} + * @private + * @since 3.11.0 + */ + isCropped: false, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setTexture + * @since 3.0.0 + * + * @param {(string|Phaser.Textures.Texture)} key - The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param {(string|number)} [frame] - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call change the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame, updateSize, updateOrigin) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame, updateSize, updateOrigin); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setFrame + * @since 3.0.0 + * + * @param {(string|number|Phaser.Textures.Frame)} frame - The name or index of the frame within the Texture, or a Frame instance. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + if (frame instanceof Frame) + { + this.texture = this.scene.sys.textures.get(frame.texture.key); + + this.frame = frame; + } + else + { + this.frame = this.texture.get(frame); + } + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + return this; + } + +}; + +module.exports = Texture; + + +/***/ }, + +/***/ 79812 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Frame = __webpack_require__(4327); + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object, with integrated support for cropping. This is used by Game Objects like Image and Sprite that need both texture management and crop functionality in a single mixin. + * + * @namespace Phaser.GameObjects.Components.TextureCrop + * @since 3.0.0 + */ + +var TextureCrop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.TextureCrop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.TextureCrop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} [width] - The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param {number} [height] - The height of the crop rectangle in pixels. Cannot exceed the Frame height. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.TextureCrop#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|number)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.TextureCrop#setFrame + * @since 3.0.0 + * + * @param {(string|number|Phaser.Textures.Frame)} frame - The name or index of the frame within the Texture, or a Frame instance. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + if (frame instanceof Frame) + { + this.texture = this.scene.sys.textures.get(frame.texture.key); + + this.frame = frame; + } + else + { + this.frame = this.texture.get(frame); + } + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + if (this.isCropped) + { + this.frame.updateCropUVs(this._crop, this.flipX, this.flipY); + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.TextureCrop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = TextureCrop; + + +/***/ }, + +/***/ 27472 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var TintModes = __webpack_require__(84322); + +/** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @namespace Phaser.GameObjects.Components.Tint + * @webglOnly + * @since 3.0.0 + */ + +var Tint = { + + /** + * The tint value being applied to the top-left vertex of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tintTopLeft + * @type {number} + * @default 0xffffff + * @since 3.0.0 + */ + tintTopLeft: 0xffffff, + + /** + * The tint value being applied to the top-right vertex of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tintTopRight + * @type {number} + * @default 0xffffff + * @since 3.0.0 + */ + tintTopRight: 0xffffff, + + /** + * The tint value being applied to the bottom-left vertex of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomLeft + * @type {number} + * @default 0xffffff + * @since 3.0.0 + */ + tintBottomLeft: 0xffffff, + + /** + * The tint value being applied to the bottom-right vertex of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomRight + * @type {number} + * @default 0xffffff + * @since 3.0.0 + */ + tintBottomRight: 0xffffff, + + /** + * The secondary tint value being applied to the top-left vertex of the Game Object. + * Used in two-color tint modes. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tint2TopLeft + * @type {number} + * @default 0x000000 + * @since 4.2.0 + */ + tint2TopLeft: 0x000000, + + /** + * The secondary tint value being applied to the top-right vertex of the Game Object. + * Used in two-color tint modes. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tint2TopRight + * @type {number} + * @default 0x000000 + * @since 4.2.0 + */ + tint2TopRight: 0x000000, + + /** + * The secondary tint value being applied to the bottom-left vertex of the Game Object. + * Used in two-color tint modes. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tint2BottomLeft + * @type {number} + * @default 0x000000 + * @since 4.2.0 + */ + tint2BottomLeft: 0x000000, + + /** + * The secondary tint value being applied to the bottom-right vertex of the Game Object. + * Used in two-color tint modes. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.Components.Tint#tint2BottomRight + * @type {number} + * @default 0x000000 + * @since 4.2.0 + */ + tint2BottomRight: 0x000000, + + /** + * The tint mode to use when applying the tint to the texture. + * + * Available modes are: + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * - Phaser.TintModes.MULTIPLY_TWO + * + * Note that in Phaser 3, tint mode and color were set at the same time. + * In Phaser 4 they are separate settings. + * + * @name Phaser.GameObjects.Components.Tint#tintMode + * @type {Phaser.TintModes} + * @default Phaser.TintModes.MULTIPLY + * @since 4.0.0 + */ + tintMode: TintModes.MULTIPLY, + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint mode to `MULTIPLY`, + * which results in no visible change to the texture. + * + * @method Phaser.GameObjects.Components.Tint#clearTint + * @webglOnly + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + this.setTint2(0x000000); + this.setTintMode(TintModes.MULTIPLY); + + return this; + }, + + /** + * Sets the tint color on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * combining it with the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight`, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * The tint color is combined according to the tint mode. + * By default, this is `MULTIPLY`. + * + * Note that, in Phaser 3, this would also swap the tint mode if it was set + * to fill. In Phaser 4, the tint mode is separate: use `setTintMode`. + * + * @method Phaser.GameObjects.Components.Tint#setTint + * @webglOnly + * @since 3.0.0 + * + * @param {number} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. + * @param {number} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {number} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {number} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0xffffff; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this.tintTopLeft = topLeft; + this.tintTopRight = topRight; + this.tintBottomLeft = bottomLeft; + this.tintBottomRight = bottomRight; + + return this; + }, + + /** + * Sets the secondary tint color on this Game Object. + * This is used in two-color tint modes. + * See {@link Phaser.GameObjects.Components.Tint#setTint} for more information. + * + * @method Phaser.GameObjects.Components.Tint#setTint2 + * @webglOnly + * @since 4.2.0 + * + * @param {number} [topLeft=0xffffff] - The secondary tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. + * @param {number} [topRight] - The secondary tint being applied to the top-right of the Game Object. + * @param {number} [bottomLeft] - The secondary tint being applied to the bottom-left of the Game Object. + * @param {number} [bottomRight] - The secondary tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTint2: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0x000000; } + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this.tint2TopLeft = topLeft; + this.tint2TopRight = topRight; + this.tint2BottomLeft = bottomLeft; + this.tint2BottomRight = bottomRight; + + return this; + }, + + /** + * Sets the tint mode to use when applying the tint to the texture. + * + * Note that, in Phaser 3, tint mode and color were set at the same time. + * In Phaser 4 they are separate settings. + * + * @method Phaser.GameObjects.Components.Tint#setTintMode + * @webglOnly + * @since 4.0.0 + * + * @param {number | Phaser.TintModes} mode - The tint mode to use. + * @return {this} This Game Object instance. + */ + setTintMode: function (mode) + { + this.tintMode = mode; + return this; + }, + + /** + * Deprecated method which does nothing. + * In Phaser 3, this would set the tint color, and set the tint mode to fill. + * In Phaser 4, use `gameObject.setTint(color).setTintMode(Phaser.TintModes.FILL)` instead. + * + * @method Phaser.GameObjects.Components.Tint#setTintFill + * @webglOnly + * @since 3.11.0 + * @deprecated + */ + setTintFill: function () + { + // eslint-disable-next-line no-console + console.error('`setTintFill(color)` is removed as of Phaser 4. Use setTint(color).setTintMode(Phaser.TintModes.FILL)` instead.'); + }, + + /** + * The tint value being applied to the whole of the Game Object. + * Returns the value of `tintTopLeft` when read. When written, the same + * color value is applied to all four corner tint properties (`tintTopLeft`, + * `tintTopRight`, `tintBottomLeft`, and `tintBottomRight`) simultaneously. + * + * @name Phaser.GameObjects.Components.Tint#tint + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + tint: { + + get: function () + { + return this.tintTopLeft; + }, + + set: function (value) + { + this.setTint(value, value, value, value); + } + }, + + /** + * Does this Game Object have a tint applied? + * + * Returns `true` if any of the four corner tint values differ from 0xffffff, + * or if the `tintMode` property is set to anything other than `MULTIPLY`, + * or if any of the four secondary corner tint values differ from 0x000000. + * Returns `false` in the default untinted state. + * + * @name Phaser.GameObjects.Components.Tint#isTinted + * @type {boolean} + * @webglOnly + * @readonly + * @since 3.11.0 + */ + isTinted: { + + get: function () + { + var white = 0xffffff; + var black = 0x000000; + + return ( + this.tintMode !== TintModes.MULTIPLY || + this.tintTopLeft !== white || + this.tintTopRight !== white || + this.tintBottomLeft !== white || + this.tintBottomRight !== white || + this.tint2TopLeft !== black || + this.tint2TopRight !== black || + this.tint2BottomLeft !== black || + this.tint2BottomRight !== black + ); + } + + } + +}; + +module.exports = Tint; + + +/***/ }, + +/***/ 53774 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Build a JSON representation of the given Game Object. + * + * This is typically extended further by Game Object specific implementations. + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. + * + * @return {Phaser.Types.GameObjects.JSONGameObject} A JSON representation of the Game Object. + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; + + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + + return out; +}; + +module.exports = ToJSON; + + +/***/ }, + +/***/ 16901 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MATH_CONST = __webpack_require__(36383); +var TransformMatrix = __webpack_require__(61340); +var TransformXY = __webpack_require__(85955); +var WrapAngle = __webpack_require__(86554); +var WrapAngleDegrees = __webpack_require__(30954); +var Vector2 = __webpack_require__(26099); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +/** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * + * @namespace Phaser.GameObjects.Components.Transform + * @since 3.0.0 + */ + +var Transform = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Transform#hasTransformComponent + * @type {boolean} + * @readonly + * @default true + * @since 3.60.0 + */ + hasTransformComponent: true, + + /** + * Private internal value. Holds the horizontal scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleX + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleX: 1, + + /** + * Private internal value. Holds the vertical scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleY + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleY: 1, + + /** + * Private internal value. Holds the rotation value in radians. + * + * @name Phaser.GameObjects.Components.Transform#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. + * + * @name Phaser.GameObjects.Components.Transform#scale + * @type {number} + * @default 1 + * @since 3.18.0 + */ + scale: { + + get: function () + { + return (this._scaleX + this._scaleY) / 2; + }, + + set: function (value) + { + this._scaleX = value; + this._scaleY = value; + + if (value === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (value === 0) + { + this.renderFlags &= ~_FLAG; + } + else if (this._scaleY !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (value === 0) + { + this.renderFlags &= ~_FLAG; + } + else if (this._scaleX !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 0 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Copies an object's coordinates to this Game Object's position. + * + * @method Phaser.GameObjects.Components.Transform#copyPosition + * @since 3.50.0 + * + * @param {(Phaser.Types.Math.Vector2Like|Phaser.Types.Math.Vector3Like|Phaser.Types.Math.Vector4Like)} source - An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * + * @return {this} This Game Object instance. + */ + copyPosition: function (source) + { + if (source.x !== undefined) { this.x = source.x; } + if (source.y !== undefined) { this.y = source.y; } + if (source.z !== undefined) { this.z = source.z; } + if (source.w !== undefined) { this.w = source.w; } + + return this; + }, + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * + * @method Phaser.GameObjects.Components.Transform#setRandomPosition + * @since 3.8.0 + * + * @param {number} [x=0] - The x position of the top-left of the random area. + * @param {number} [y=0] - The y position of the top-left of the random area. + * @param {number} [width] - The width of the random area. + * @param {number} [height] - The height of the random area. + * + * @return {this} This Game Object instance. + */ + setRandomPosition: function (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.scale.width; } + if (height === undefined) { height = this.scene.sys.scale.height; } + + this.x = x + (Math.random() * width); + this.y = y + (Math.random() * height); + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {this} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {this} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} [x=1] - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + }, + + /** + * Gets the local transform matrix for this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getLocalTransformMatrix: function (tempMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + }, + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * + * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values during the calculations. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getWorldTransformMatrix: function (tempMatrix, parentMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + var parent = this.parentContainer; + + if (!parent) + { + return this.getLocalTransformMatrix(tempMatrix); + } + + var destroyParentMatrix = false; + + if (!parentMatrix) + { + parentMatrix = new TransformMatrix(); + + destroyParentMatrix = true; + } + + tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + + while (parent) + { + parentMatrix.applyITRS(parent.x, parent.y, parent._rotation, parent._scaleX, parent._scaleY); + + parentMatrix.multiply(tempMatrix, tempMatrix); + + parent = parent.parentContainer; + } + + if (destroyParentMatrix) + { + parentMatrix.destroy(); + } + + return tempMatrix; + }, + + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. + * + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * + * @method Phaser.GameObjects.Components.Transform#getLocalPoint + * @since 3.50.0 + * + * @param {number} x - The x position to translate. + * @param {number} y - The y position to translate. + * @param {Phaser.Math.Vector2} [point] - A Vector2, or point-like object, to store the results in. + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera which is being tested against. If not given will use the Scene default camera. + * + * @return {Phaser.Math.Vector2} The translated point. + */ + getLocalPoint: function (x, y, point, camera) + { + if (!point) { point = new Vector2(); } + if (!camera) { camera = this.scene.sys.cameras.main; } + + var csx = camera.scrollX; + var csy = camera.scrollY; + + var px = x + (csx * this.scrollFactorX) - csx; + var py = y + (csy * this.scrollFactorY) - csy; + + if (this.parentContainer) + { + this.getWorldTransformMatrix().applyInverse(px, py, point); + } + else + { + TransformXY(px, py, this.x, this.y, this.rotation, this.scaleX, this.scaleY, point); + } + + // Normalize origin + if (this._originComponent) + { + point.x += this._displayOriginX; + point.y += this._displayOriginY; + } + + return point; + }, + + /** + * Gets the world position of this Game Object, factoring in any parent Containers. + * + * @method Phaser.GameObjects.Components.Transform#getWorldPoint + * @since 3.88.0 + * + * @param {Phaser.Math.Vector2} [point] - A Vector2, or point-like object, to store the result in. + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - A temporary matrix to hold the Game Object's values. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values. + * + * @return {Phaser.Math.Vector2} The world position of this Game Object. + */ + getWorldPoint: function (point, tempMatrix, parentMatrix) + { + if (point === undefined) { point = new Vector2(); } + + var parent = this.parentContainer; + + if (!parent) + { + point.x = this.x; + point.y = this.y; + + return point; + } + + var worldTransform = this.getWorldTransformMatrix(tempMatrix, parentMatrix); + + point.x = worldTransform.tx; + point.y = worldTransform.ty; + + return point; + }, + + /** + * Gets the sum total rotation of all of this Game Object's parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. + * + * @method Phaser.GameObjects.Components.Transform#getParentRotation + * @since 3.18.0 + * + * @return {number} The sum total rotation, in radians, of all parent containers of this Game Object. + */ + getParentRotation: function () + { + var rotation = 0; + + var parent = this.parentContainer; + + while (parent) + { + rotation += parent.rotation; + + parent = parent.parentContainer; + } + + return rotation; + } + +}; + +module.exports = Transform; + + +/***/ }, + +/***/ 61340 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var MATH_CONST = __webpack_require__(36383); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A TransformMatrix is a 3x3 affine transformation matrix used to encode + * the position, rotation, scale, and skew of a Game Object for rendering. + * + * It is used internally by Phaser during the render pipeline to accumulate + * parent-child transform chains and apply camera transformations. You will + * typically interact with it when writing custom renderers or working with + * the camera or display list transform pipeline. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` + * + * @class TransformMatrix + * @memberof Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - The Scale X value. + * @param {number} [b=0] - The Skew Y value. + * @param {number} [c=0] - The Skew X value. + * @param {number} [d=1] - The Scale Y value. + * @param {number} [tx=0] - The Translate X value. + * @param {number} [ty=0] - The Translate Y value. + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * The matrix values. + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * The decomposed matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + + /** + * The temporary quad value cache. + * + * @name Phaser.GameObjects.Components.TransformMatrix#quad + * @type {Float32Array} + * @since 3.60.0 + */ + this.quad = new Float32Array(8); + }, + + /** + * The Scale X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#a + * @type {number} + * @since 3.4.0 + */ + a: { + + get: function () + { + return this.matrix[0]; + }, + + set: function (value) + { + this.matrix[0] = value; + } + + }, + + /** + * The Skew Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#b + * @type {number} + * @since 3.4.0 + */ + b: { + + get: function () + { + return this.matrix[1]; + }, + + set: function (value) + { + this.matrix[1] = value; + } + + }, + + /** + * The Skew X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#c + * @type {number} + * @since 3.4.0 + */ + c: { + + get: function () + { + return this.matrix[2]; + }, + + set: function (value) + { + this.matrix[2] = value; + } + + }, + + /** + * The Scale Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#d + * @type {number} + * @since 3.4.0 + */ + d: { + + get: function () + { + return this.matrix[3]; + }, + + set: function (value) + { + this.matrix[3] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#e + * @type {number} + * @since 3.11.0 + */ + e: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#f + * @type {number} + * @since 3.11.0 + */ + f: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#tx + * @type {number} + * @since 3.4.0 + */ + tx: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#ty + * @type {number} + * @since 3.4.0 + */ + ty: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The rotation of the Matrix. Value is in radians. + * + * @name Phaser.GameObjects.Components.TransformMatrix#rotation + * @type {number} + * @readonly + * @since 3.4.0 + */ + rotation: { + + get: function () + { + return Math.acos(this.a / this.scaleX) * ((Math.atan(-this.c / this.a) < 0) ? -1 : 1); + } + + }, + + /** + * The rotation of the Matrix, normalized to be within the Phaser right-handed + * clockwise rotation space. Value is in radians. + * + * @name Phaser.GameObjects.Components.TransformMatrix#rotationNormalized + * @type {number} + * @readonly + * @since 3.19.0 + */ + rotationNormalized: { + + get: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + if (a || b) + { + // var r = Math.sqrt(a * a + b * b); + + return (b > 0) ? Math.acos(a / this.scaleX) : -Math.acos(a / this.scaleX); + } + else if (c || d) + { + // var s = Math.sqrt(c * c + d * d); + + return MATH_CONST.PI_OVER_2 - ((d > 0) ? Math.acos(-c / this.scaleY) : -Math.acos(c / this.scaleY)); + } + else + { + return 0; + } + } + + }, + + /** + * The decomposed horizontal scale of the Matrix. This value is always positive. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleX + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleX: { + + get: function () + { + return Math.sqrt((this.a * this.a) + (this.b * this.b)); + } + + }, + + /** + * The decomposed vertical scale of the Matrix. This value is always positive. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleY + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleY: { + + get: function () + { + return Math.sqrt((this.c * this.c) + (this.d * this.d)); + } + + }, + + /** + * Reset the Matrix to an identity matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * Translate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - The horizontal translation value. + * @param {number} y - The vertical translation value. + * + * @return {this} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * Scale the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale value. + * @param {number} y - The vertical scale value. + * + * @return {this} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * Rotate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} angle - The angle of rotation in radians. + * + * @return {this} This TransformMatrix. + */ + rotate: function (angle) + { + var sin = Math.sin(angle); + var cos = Math.cos(angle); + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + matrix[0] = a * cos + c * sin; + matrix[1] = b * cos + d * sin; + matrix[2] = a * -sin + c * cos; + matrix[3] = b * -sin + d * cos; + + return this; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by. + * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in. + * + * @return {(this|Phaser.GameObjects.Components.TransformMatrix)} Either this TransformMatrix, or the `out` Matrix, if given in the arguments. + */ + multiply: function (rhs, out) + { + var matrix = this.matrix; + var source = rhs.matrix; + + var localA = matrix[0]; + var localB = matrix[1]; + var localC = matrix[2]; + var localD = matrix[3]; + var localE = matrix[4]; + var localF = matrix[5]; + + var sourceA = source[0]; + var sourceB = source[1]; + var sourceC = source[2]; + var sourceD = source[3]; + var sourceE = source[4]; + var sourceF = source[5]; + + var destinationMatrix = (out === undefined) ? matrix : out.matrix; + + destinationMatrix[0] = (sourceA * localA) + (sourceB * localC); + destinationMatrix[1] = (sourceA * localB) + (sourceB * localD); + destinationMatrix[2] = (sourceC * localA) + (sourceD * localC); + destinationMatrix[3] = (sourceC * localB) + (sourceD * localD); + destinationMatrix[4] = (sourceE * localA) + (sourceF * localC) + localE; + destinationMatrix[5] = (sourceE * localB) + (sourceF * localD) + localF; + + return destinationMatrix; + }, + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetX * b + offsetY * d + ty`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} offsetX - Horizontal offset to factor in to the multiplication. + * @param {number} offsetY - Vertical offset to factor in to the multiplication. + * + * @return {this} This TransformMatrix. + */ + multiplyWithOffset: function (src, offsetX, offsetY) + { + var matrix = this.matrix; + var otherMatrix = src.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var pse = offsetX * a0 + offsetY * c0 + tx0; + var psf = offsetX * b0 + offsetY * d0 + ty0; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + pse; + matrix[5] = tx1 * b0 + ty1 * d0 + psf; + + return this; + }, + + /** + * Transform the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * Transform a point in to the local space of this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to transform. + * @param {number} y - The y coordinate of the point to transform. + * @param {Phaser.Types.Math.Vector2Like} [point] - Optional Point object to store the transformed coordinates in. + * + * @return {Phaser.Types.Math.Vector2Like} The Point containing the transformed coordinates. + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * Invert the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the matrix given. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * + * @return {this} This TransformMatrix. + */ + copyFrom: function (src) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + matrix[4] = src.e; + matrix[5] = src.f; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray + * @since 3.11.0 + * + * @param {array} src - The array of values to set into this matrix. + * + * @return {this} This TransformMatrix. + */ + copyFromArray: function (src) + { + var matrix = this.matrix; + + matrix[0] = src[0]; + matrix[1] = src[1]; + matrix[2] = src[2]; + matrix[3] = src[3]; + matrix[4] = src[4]; + matrix[5] = src[5]; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the matrix given, + * combined with a camera scroll factor. + * + * This is used in many render functions. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyWithScrollFactorFrom + * @since 4.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} scrollX - The horizontal scroll value to factor in. + * @param {number} scrollY - The vertical scroll value to factor in. + * @param {number} scrollFactorX - The horizontal scroll factor to apply. + * @param {number} scrollFactorY - The vertical scroll factor to apply. + * + * @return {this} This TransformMatrix. + */ + copyWithScrollFactorFrom: function (src, scrollX, scrollY, scrollFactorX, scrollFactorY) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + + var sx = scrollX * (1.0 - scrollFactorX); + var sy = scrollY * (1.0 - scrollFactorY); + + matrix[4] = src.a * sx + src.c * sy + src.e; + matrix[5] = src.b * sx + src.d * sy + src.f; + + return this; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + copyToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + setToContext: function (ctx) + { + // using old way for old browser compatibility #6965 + ctx.setTransform(this.a, this.b, this.c, this.d, this.e, this.f); + + return ctx; + }, + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray + * @since 3.12.0 + * + * @param {array} [out] - The array to copy the matrix values in to. + * + * @return {array} An array where elements 0 to 5 contain the values from this matrix. + */ + copyToArray: function (out) + { + var matrix = this.matrix; + + if (out === undefined) + { + out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ]; + } + else + { + out[0] = matrix[0]; + out[1] = matrix[1]; + out[2] = matrix[2]; + out[3] = matrix[3]; + out[4] = matrix[4]; + out[5] = matrix[5]; + } + + return out; + }, + + /** + * Set the values of this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. + * + * The result must be applied in the following order to reproduce the current matrix: + * + * translate -> rotate -> scale + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.DecomposeMatrixResults} The decomposed Matrix. + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + // a = scale X (1) + // b = shear Y (0) + // c = shear X (0) + // d = scale Y (1) + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var determ = a * d - b * c; + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + if (a || b) + { + var r = Math.sqrt(a * a + b * b); + + decomposedMatrix.rotation = (b > 0) ? Math.acos(a / r) : -Math.acos(a / r); + decomposedMatrix.scaleX = r; + decomposedMatrix.scaleY = determ / r; + } + else if (c || d) + { + var s = Math.sqrt(c * c + d * d); + + decomposedMatrix.rotation = Math.PI * 0.5 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s)); + decomposedMatrix.scaleX = determ / s; + decomposedMatrix.scaleY = s; + } + else + { + decomposedMatrix.rotation = 0; + decomposedMatrix.scaleX = 0; + decomposedMatrix.scaleY = 0; + } + + return decomposedMatrix; + }, + + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - The horizontal translation. + * @param {number} y - The vertical translation. + * @param {number} rotation - The angle of rotation in radians. + * @param {number} scaleX - The horizontal scale. + * @param {number} scaleY - The vertical scale. + * + * @return {this} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = radianCos * scaleX; + matrix[1] = radianSin * scaleX; + matrix[2] = -radianSin * scaleY; + matrix[3] = radianCos * scaleY; + + return this; + }, + + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyInverse + * @since 3.12.0 + * + * @param {number} x - The x position to translate. + * @param {number} y - The y position to translate. + * @param {Phaser.Math.Vector2} [output] - A Vector2, or point-like object, to store the results in. + * + * @return {Phaser.Math.Vector2} The coordinates, inverse-transformed through this matrix. + */ + applyInverse: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id); + + return output; + }, + + /** + * Performs the 8 calculations required to create the vertices of + * a quad based on this matrix and the given vertex coordinates. + * + * The result is stored in `TransformMatrix.quad`, which is returned + * from this method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setQuad + * @since 3.60.0 + * + * @param {number} x - The x value of the top-left vertex of the quad. + * @param {number} y - The y value of the top-left vertex of the quad. + * @param {number} xw - The x value of the bottom-right vertex of the quad. This is the x + width. + * @param {number} yh - The y value of the bottom-right vertex of the quad. This is the y + height. + * @param {Float32Array} [quad] - Optional Float32Array to store the results in. Otherwise uses the local quad array. + * + * @return {Float32Array} The quad Float32Array. + */ + setQuad: function (x, y, xw, yh, quad) + { + if (quad === undefined) { quad = this.quad; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var e = matrix[4]; + var f = matrix[5]; + + quad[0] = x * a + y * c + e; + quad[1] = x * b + y * d + f; + + quad[2] = x * a + yh * c + e; + quad[3] = x * b + yh * d + f; + + quad[4] = xw * a + yh * c + e; + quad[5] = xw * b + yh * d + f; + + quad[6] = xw * a + y * c + e; + quad[7] = xw * b + y * d + f; + + return quad; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getX + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated x value. + */ + getX: function (x, y) + { + return x * this.a + y * this.c + this.e; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getY + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated y value. + */ + getY: function (x, y) + { + return x * this.b + y * this.d + this.f; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * + * This is the same as `x * a + y * c + e`, optionally passing via `Math.round`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getXRound + * @since 3.50.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * @param {boolean} [round=false] - Math.round the resulting value? + * + * @return {number} The calculated x value. + */ + getXRound: function (x, y, round) + { + var v = this.getX(x, y); + + if (round) + { + v = Math.floor(v + 0.5); + } + + return v; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * + * This is the same as `x * b + y * d + f`, optionally passing via `Math.round`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getYRound + * @since 3.50.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * @param {boolean} [round=false] - Math.round the resulting value? + * + * @return {number} The calculated y value. + */ + getYRound: function (x, y, round) + { + var v = this.getY(x, y); + + if (round) + { + v = Math.floor(v + 0.5); + } + + return v; + }, + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix + * @since 3.12.0 + * + * @return {string} A string containing the CSS Transform matrix values. + */ + getCSSMatrix: function () + { + var m = this.matrix; + + return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')'; + }, + + /** + * Destroys this Transform Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#destroy + * @since 3.4.0 + */ + destroy: function () + { + this.matrix = null; + this.quad = null; + this.decomposedMatrix = null; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }, + +/***/ 59715 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * The Visible component is mixed into Game Objects to give them a `visible` boolean property + * and a `setVisible` method. Visibility is tracked via a bitmask flag on `renderFlags`, so + * toggling it is a fast bitwise operation. An invisible Game Object is excluded from the + * render pass entirely, but its `update` logic continues to run normally each frame. + * Should be applied as a mixin and not used directly. + * + * @namespace Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + /** + * Private internal value. Holds the visible value. + * + * @name Phaser.GameObjects.Components.Visible#_visible + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {this} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }, + +/***/ 31401 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Components + */ + +module.exports = { + + Alpha: __webpack_require__(16005), + AlphaSingle: __webpack_require__(88509), + BlendMode: __webpack_require__(90065), + ComputedSize: __webpack_require__(94215), + Crop: __webpack_require__(61683), + Depth: __webpack_require__(89272), + ElapseTimer: __webpack_require__(3248), + FilterList: __webpack_require__(53427), + Filters: __webpack_require__(43102), + Flip: __webpack_require__(54434), + GetBounds: __webpack_require__(8004), + Lighting: __webpack_require__(73629), + Mask: __webpack_require__(8573), + Origin: __webpack_require__(27387), + PathFollower: __webpack_require__(37640), + RenderNodes: __webpack_require__(68680), + RenderSteps: __webpack_require__(86038), + ScrollFactor: __webpack_require__(80227), + Size: __webpack_require__(16736), + StencilModifier: __webpack_require__(43520), + Texture: __webpack_require__(37726), + TextureCrop: __webpack_require__(79812), + Tint: __webpack_require__(27472), + ToJSON: __webpack_require__(53774), + Transform: __webpack_require__(16901), + TransformMatrix: __webpack_require__(61340), + Visible: __webpack_require__(59715) + +}; + + +/***/ }, + +/***/ 31559 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ArrayUtils = __webpack_require__(37105); +var BlendModes = __webpack_require__(10312); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Events = __webpack_require__(51708); +var GameObject = __webpack_require__(95643); +var Rectangle = __webpack_require__(87841); +var Render = __webpack_require__(29959); +var Union = __webpack_require__(36899); +var Vector2 = __webpack_require__(26099); +var Layer = __webpack_require__(93595); + +var tempTransformMatrix = new Components.TransformMatrix(); + +/** + * @classdesc + * A Container Game Object. + * + * A Container, as the name implies, can 'contain' other types of Game Object. + * When a Game Object is added to a Container, the Container becomes responsible for the rendering of it. + * By default it will be removed from the Display List and instead added to the Containers own internal list. + * + * The position of the Game Object automatically becomes relative to the position of the Container. + * + * The transform point of a Container is 0x0 (in local space) and that cannot be changed. The children you add to the + * Container should be positioned with this value in mind. I.e. you should treat 0x0 as being the center of + * the Container, and position children positively and negative around it as required. + * + * When the Container is rendered, all of its children are rendered as well, in the order in which they exist + * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. + * + * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will + * automatically influence all children as well. + * + * Containers can include other Containers for deeply nested transforms. + * + * Containers can have masks set on them and can be used as a mask too. + * Because masks are filters, the container's children can also have masks, + * and the Container's mask will be applied over the top. + * In Canvas rendering, only the Container's mask will be applied. + * + * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them + * to use as their hit area. Container children can also be enabled for input, independent of the Container. + * + * If input enabling a _child_ you should not set both the `origin` and a **negative** scale factor on the child, + * or the input area will become misaligned. + * + * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, + * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, + * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children + * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure + * your game to work around this. + * + * It's important to understand the impact of using Containers. They add additional processing overhead into + * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true + * for input events. You also lose the ability to set the display depth of Container children in the same + * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost + * every time you create one, try to structure your game around avoiding that where possible. + * + * @class Container + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.4.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. + */ +var Container = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Mask, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function Container (scene, x, y, children) + { + GameObject.call(this, scene, 'Container'); + + /** + * An array holding the children of this Container. + * + * @name Phaser.GameObjects.Container#list + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.4.0 + */ + this.list = []; + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @name Phaser.GameObjects.Container#exclusive + * @type {boolean} + * @default true + * @since 3.4.0 + */ + this.exclusive = true; + + /** + * Containers can have an optional maximum size. If set to anything above 0 it + * will constrict the addition of new Game Objects into the Container, capping off + * the maximum limit the Container can grow in size to. + * + * @name Phaser.GameObjects.Container#maxSize + * @type {number} + * @default -1 + * @since 3.4.0 + */ + this.maxSize = -1; + + /** + * An internal cursor position used for iterating through the Container's children + * via methods such as `first`, `next`, `previous` and `last`. + * + * @name Phaser.GameObjects.Container#position + * @type {number} + * @since 3.4.0 + */ + this.position = 0; + + /** + * Internal Transform Matrix used for local space conversion. + * + * @name Phaser.GameObjects.Container#localTransform + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.4.0 + */ + this.localTransform = new Components.TransformMatrix(); + + /** + * The property key to sort by. + * + * @name Phaser.GameObjects.Container#_sortKey + * @type {string} + * @private + * @since 3.4.0 + */ + this._sortKey = ''; + + /** + * A reference to the Scene Systems Event Emitter. + * + * @name Phaser.GameObjects.Container#_sysEvents + * @type {Phaser.Events.EventEmitter} + * @private + * @since 3.9.0 + */ + this._sysEvents = scene.sys.events; + + /** + * The horizontal scroll factor of this Container. + * + * The scroll factor controls the influence of the movement of a Camera upon this Container. + * + * When a camera scrolls it will change the location at which this Container is rendered on-screen. + * It does not change the Containers actual position values. + * + * For a Container, setting this value will only update the Container itself, not its children. + * If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Container. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Container#scrollFactorX + * @type {number} + * @default 1 + * @since 3.4.0 + */ + this.scrollFactorX = 1; + + /** + * The vertical scroll factor of this Container. + * + * The scroll factor controls the influence of the movement of a Camera upon this Container. + * + * When a camera scrolls it will change the location at which this Container is rendered on-screen. + * It does not change the Containers actual position values. + * + * For a Container, setting this value will only update the Container itself, not its children. + * If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Container. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Container#scrollFactorY + * @type {number} + * @default 1 + * @since 3.4.0 + */ + this.scrollFactorY = 1; + + this.setPosition(x, y); + + this.setBlendMode(BlendModes.SKIP_CHECK); + + if (children) + { + this.add(children); + } + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originX + * @type {number} + * @readonly + * @override + * @since 3.4.0 + */ + originX: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originY + * @type {number} + * @readonly + * @override + * @since 3.4.0 + */ + originY: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginX + * @type {number} + * @readonly + * @override + * @since 3.4.0 + */ + displayOriginX: { + + get: function () + { + return this.width * 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginY + * @type {number} + * @readonly + * @override + * @since 3.4.0 + */ + displayOriginY: { + + get: function () + { + return this.height * 0.5; + } + + }, + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @method Phaser.GameObjects.Container#setExclusive + * @since 3.4.0 + * + * @param {boolean} [value=true] - The exclusive state of this Container. + * + * @return {this} This Container. + */ + setExclusive: function (value) + { + if (value === undefined) { value = true; } + + this.exclusive = value; + + return this; + }, + + /** + * Gets the bounds of this Container. It works by iterating all children of the Container, + * getting their respective bounds, and then working out a min-max rectangle from that. + * It does not factor in if the children render or not, all are included. + * + * Some children are unable to return their bounds, such as Graphics objects, in which case + * they are skipped. + * + * Depending on the quantity of children in this Container it could be a really expensive call, + * so cache it and only poll it as needed. + * + * The values are stored and returned in a Rectangle object. + * + * @method Phaser.GameObjects.Container#getBounds + * @since 3.4.0 + * + * @param {Phaser.Geom.Rectangle} [output] - A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + output.setTo(this.x, this.y, 0, 0); + + if (this.parentContainer) + { + var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); + var transformedPosition = parentMatrix.transformPoint(this.x, this.y); + + output.setTo(transformedPosition.x, transformedPosition.y, 0, 0); + } + + if (this.list.length > 0) + { + var children = this.list; + var tempRect = new Rectangle(); + var hasSetFirst = false; + + output.setEmpty(); + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.getBounds) + { + entry.getBounds(tempRect); + + if (!hasSetFirst) + { + output.setTo(tempRect.x, tempRect.y, tempRect.width, tempRect.height); + hasSetFirst = true; + } + else + { + Union(tempRect, output, output); + } + } + } + } + + return output; + }, + + /** + * Internal add handler. + * + * @method Phaser.GameObjects.Container#addHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to this Container. + */ + addHandler: function (gameObject) + { + gameObject.once(Events.DESTROY, this.onChildDestroyed, this); + + if (this.exclusive) + { + if (gameObject.parentContainer) + { + gameObject.parentContainer.remove(gameObject); + } + + gameObject.parentContainer = this; + + gameObject.removeFromDisplayList(); + + gameObject.addedToScene(); + } + }, + + /** + * Internal remove handler. + * + * @method Phaser.GameObjects.Container#removeHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just removed from this Container. + */ + removeHandler: function (gameObject) + { + gameObject.off(Events.DESTROY, this.remove, this); + + if (this.exclusive) + { + gameObject.parentContainer = null; + + gameObject.removedFromScene(); + + gameObject.addToDisplayList(); + } + }, + + /** + * Takes a Point-like object, such as a Vector2, or object with public x and y properties, + * and transforms it into the space of this Container, then returns it in the output object. + * + * @method Phaser.GameObjects.Container#pointToContainer + * @since 3.4.0 + * + * @param {Phaser.Types.Math.Vector2Like} source - The Source Point to be transformed. + * @param {Phaser.Types.Math.Vector2Like} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned. + * + * @return {Phaser.Types.Math.Vector2Like} The transformed point. + */ + pointToContainer: function (source, output) + { + if (output === undefined) { output = new Vector2(); } + + if (this.parentContainer) + { + this.parentContainer.pointToContainer(source, output); + } + else + { + output.x = source.x; + output.y = source.y; + } + + var tempMatrix = tempTransformMatrix; + + // No need to loadIdentity because applyITRS overwrites every value anyway + tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY); + + tempMatrix.invert(); + + tempMatrix.transformPoint(source.x, source.y, output); + + return output; + }, + + /** + * Returns the world transform matrix as used for Bounds checks. + * + * The returned matrix is temporary and shouldn't be stored. + * + * @method Phaser.GameObjects.Container#getBoundsTransformMatrix + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The world transform matrix. + */ + getBoundsTransformMatrix: function () + { + return this.getWorldTransformMatrix(tempTransformMatrix, this.localTransform); + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container. + * + * Each Game Object must be unique within the Container. + * + * If you try to add a Layer, it will throw an error. + * + * @method Phaser.GameObjects.Container#add + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {(T|T[])} - [child] + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * + * @return {this} This Container instance. + */ + add: function (child) + { + if (Array.isArray(child)) + { + child.forEach(function (value) + { + if (value && value instanceof Layer) + { + throw new Error('Tried to add a Layer to a Container: this is not allowed'); + } + }); + } + else if (child && child instanceof Layer) + { + throw new Error('Tried to add a Layer to a Container: this is not allowed'); + } + + ArrayUtils.Add(this.list, child, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. + * + * Existing Game Objects in the Container are shifted up. + * + * Each Game Object must be unique within the Container. + * + * @method Phaser.GameObjects.Container#addAt + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {(T|T[])} - [child] + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * @param {number} [index=0] - The position to insert the Game Object/s at. + * + * @return {this} This Container instance. + */ + addAt: function (child, index) + { + ArrayUtils.AddAt(this.list, child, index, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Returns the Game Object at the given position in this Container. + * + * @method Phaser.GameObjects.Container#getAt + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [$return] + * + * @param {number} index - The position to get the Game Object from. + * + * @return {?Phaser.GameObjects.GameObject} The Game Object at the specified index, or `null` if none found. + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * Returns the index of the given Game Object in this Container. + * + * @method Phaser.GameObjects.Container#getIndex + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to search for in this Container. + * + * @return {number} The index of the Game Object in this Container, or -1 if not found. + */ + getIndex: function (child) + { + return this.list.indexOf(child); + }, + + /** + * Sort the contents of this Container so the items are in order based on the given property. + * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. + * + * @method Phaser.GameObjects.Container#sort + * @since 3.4.0 + * + * @param {string} property - The property to lexically sort by. + * @param {function} [handler] - Provide your own custom handler function. Will receive 2 children which it should compare and return a negative, zero, or positive number. + * + * @return {this} This Container instance. + */ + sort: function (property, handler) + { + if (!property) + { + return this; + } + + if (handler === undefined) + { + handler = function (childA, childB) + { + return childA[property] - childB[property]; + }; + } + + ArrayUtils.StableSort(this.list, handler); + + return this; + }, + + /** + * Searches for the first instance of a child with its `name` property matching the given argument. + * Should more than one child have the same name only the first is returned. + * + * @method Phaser.GameObjects.Container#getByName + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [$return] + * + * @param {string} name - The name to search for. + * + * @return {?Phaser.GameObjects.GameObject} The first child with a matching name, or `null` if none were found. + */ + getByName: function (name) + { + return ArrayUtils.GetFirst(this.list, 'name', name); + }, + + /** + * Returns a random Game Object from this Container. + * + * @method Phaser.GameObjects.Container#getRandom + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [$return] + * + * @param {number} [startIndex=0] - An optional start index. + * @param {number} [length] - An optional length, the total number of elements (from the startIndex) to choose from. + * + * @return {?Phaser.GameObjects.GameObject} A random child from the Container, or `null` if the Container is empty. + */ + getRandom: function (startIndex, length) + { + return ArrayUtils.GetRandom(this.list, startIndex, length); + }, + + /** + * Gets the first Game Object in this Container. + * + * You can also specify a property and value to search for, in which case it will return the first + * Game Object in this Container with a matching property and / or value. + * + * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. + * + * You can limit the search to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#getFirst + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [$return] + * + * @param {string} property - The property to test on each Game Object in the Container. + * @param {*} value - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {number} [startIndex=0] - An optional start index to search from. + * @param {number} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {?Phaser.GameObjects.GameObject} The first matching Game Object, or `null` if none was found. + */ + getFirst: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetFirst(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns all Game Objects in this Container. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('body')` would return only Game Objects that have a body property. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#getAll + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T[]} - [$return] + * + * @param {string} [property] - The property to test on each Game Object in the Container. + * @param {any} [value] - If property is set then the `property` must strictly equal this value to be included in the results. + * @param {number} [startIndex=0] - An optional start index to search from. + * @param {number} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {Phaser.GameObjects.GameObject[]} An array of matching Game Objects from this Container. + */ + getAll: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns the total number of Game Objects in this Container that have a property + * matching the given value. + * + * For example: `count('visible', true)` would count all the elements that have their visible property set. + * + * You can optionally limit the operation to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#count + * @since 3.4.0 + * + * @param {string} property - The property to check. + * @param {any} value - The value to check. + * @param {number} [startIndex=0] - An optional start index to search from. + * @param {number} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {number} The total number of Game Objects in this Container with a property matching the given value. + */ + count: function (property, value, startIndex, endIndex) + { + return ArrayUtils.CountAllMatching(this.list, property, value, startIndex, endIndex); + }, + + /** + * Swaps the position of two Game Objects in this Container. + * Both Game Objects must belong to this Container. + * + * @method Phaser.GameObjects.Container#swap + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child1,child2] + * + * @param {Phaser.GameObjects.GameObject} child1 - The first Game Object to swap. + * @param {Phaser.GameObjects.GameObject} child2 - The second Game Object to swap. + * + * @return {this} This Container instance. + */ + swap: function (child1, child2) + { + ArrayUtils.Swap(this.list, child1, child2); + + return this; + }, + + /** + * Moves a Game Object to a new position within this Container. + * + * The Game Object must already be a child of this Container. + * + * The Game Object is removed from its old position and inserted into the new one. + * Therefore the Container size does not change. Other children will change position accordingly. + * + * @method Phaser.GameObjects.Container#moveTo + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to move. + * @param {number} index - The new position of the Game Object in this Container. + * + * @return {this} This Container instance. + */ + moveTo: function (child, index) + { + ArrayUtils.MoveTo(this.list, child, index); + + return this; + }, + + /** + * Moves a Game Object above another one within this Container. + * If the Game Object is already above the other, it isn't moved. + * + * These 2 Game Objects must already be children of this Container. + * + * @method Phaser.GameObjects.Container#moveAbove + * @since 3.55.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child1,child2] + * + * @param {Phaser.GameObjects.GameObject} child1 - The Game Object to move above base Game Object. + * @param {Phaser.GameObjects.GameObject} child2 - The base Game Object. + * + * @return {this} This Container instance. + */ + moveAbove: function (child1, child2) + { + ArrayUtils.MoveAbove(this.list, child1, child2); + + return this; + }, + + /** + * Moves a Game Object below another one within this Container. + * If the Game Object is already below the other, it isn't moved. + * + * These 2 Game Objects must already be children of this Container. + * + * @method Phaser.GameObjects.Container#moveBelow + * @since 3.55.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child1,child2] + * + * @param {Phaser.GameObjects.GameObject} child1 - The Game Object to move below base Game Object. + * @param {Phaser.GameObjects.GameObject} child2 - The base Game Object. + * + * @return {this} This Container instance. + */ + moveBelow: function (child1, child2) + { + ArrayUtils.MoveBelow(this.list, child1, child2); + + return this; + }, + + /** + * Removes the given Game Object, or array of Game Objects, from this Container. + * + * The Game Objects must already be children of this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#remove + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {(T|T[])} - [child] + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to be removed from the Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each child successfully removed from this Container. + * + * @return {this} This Container instance. + */ + remove: function (child, destroyChild) + { + var removed = ArrayUtils.Remove(this.list, child, this.removeHandler, this); + + if (destroyChild && removed) + { + if (!Array.isArray(removed)) + { + removed = [ removed ]; + } + + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes the Game Object at the given position in this Container. + * + * You can also optionally call `destroy` on the Game Object, if one is found. + * + * @method Phaser.GameObjects.Container#removeAt + * @since 3.4.0 + * + * @param {number} index - The index of the Game Object to be removed. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {this} This Container instance. + */ + removeAt: function (index, destroyChild) + { + var removed = ArrayUtils.RemoveAt(this.list, index, this.removeHandler, this); + + if (destroyChild && removed) + { + removed.destroy(); + } + + return this; + }, + + /** + * Removes the Game Objects between the given positions in this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeBetween + * @since 3.4.0 + * + * @param {number} [startIndex=0] - An optional start index to search from. + * @param {number} [endIndex=Container.length] - An optional end index to search up to (but not included) + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {this} This Container instance. + */ + removeBetween: function (startIndex, endIndex, destroyChild) + { + var removed = ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeHandler, this); + + if (destroyChild) + { + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes all Game Objects from this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeAll + * @since 3.4.0 + * + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {this} This Container instance. + */ + removeAll: function (destroyChild) + { + var list = this.list; + + if (destroyChild) + { + for (var i = 0; i < list.length; i++) + { + if (list[i] && list[i].scene) + { + list[i].off(Events.DESTROY, this.onChildDestroyed, this); + + list[i].destroy(); + } + } + + this.list = []; + } + else + { + ArrayUtils.RemoveBetween(list, 0, list.length, this.removeHandler, this); + } + + return this; + }, + + /** + * Brings the given Game Object to the top of this Container. + * This will cause it to render on-top of any other objects in the Container. + * + * @method Phaser.GameObjects.Container#bringToTop + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to bring to the top of the Container. + * + * @return {this} This Container instance. + */ + bringToTop: function (child) + { + ArrayUtils.BringToTop(this.list, child); + + return this; + }, + + /** + * Sends the given Game Object to the bottom of this Container. + * This will cause it to render below any other objects in the Container. + * + * @method Phaser.GameObjects.Container#sendToBack + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to send to the bottom of the Container. + * + * @return {this} This Container instance. + */ + sendToBack: function (child) + { + ArrayUtils.SendToBack(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object up one place in this Container, unless it's already at the top. + * + * @method Phaser.GameObjects.Container#moveUp + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {this} This Container instance. + */ + moveUp: function (child) + { + ArrayUtils.MoveUp(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object down one place in this Container, unless it's already at the bottom. + * + * @method Phaser.GameObjects.Container#moveDown + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {this} This Container instance. + */ + moveDown: function (child) + { + ArrayUtils.MoveDown(this.list, child); + + return this; + }, + + /** + * Reverses the order of all Game Objects in this Container. + * + * @method Phaser.GameObjects.Container#reverse + * @since 3.4.0 + * + * @return {this} This Container instance. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * Shuffles all Game Objects in this Container using the Fisher-Yates implementation. + * + * @method Phaser.GameObjects.Container#shuffle + * @since 3.4.0 + * + * @return {this} This Container instance. + */ + shuffle: function () + { + ArrayUtils.Shuffle(this.list); + + return this; + }, + + /** + * Replaces a Game Object in this Container with the new Game Object. + * The new Game Object cannot already be a child of this Container. + * + * @method Phaser.GameObjects.Container#replace + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [oldChild,newChild] + * + * @param {Phaser.GameObjects.GameObject} oldChild - The Game Object in this Container that will be replaced. + * @param {Phaser.GameObjects.GameObject} newChild - The Game Object to be added to this Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {this} This Container instance. + */ + replace: function (oldChild, newChild, destroyChild) + { + var moved = ArrayUtils.Replace(this.list, oldChild, newChild); + + if (moved) + { + this.addHandler(newChild); + this.removeHandler(oldChild); + + if (destroyChild) + { + oldChild.destroy(); + } + } + + return this; + }, + + /** + * Returns `true` if the given Game Object is a direct child of this Container. + * + * This check does not scan nested Containers. + * + * @method Phaser.GameObjects.Container#exists + * @since 3.4.0 + * + * @generic {Phaser.GameObjects.GameObject} T + * @genericUse {T} - [child] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to check for within this Container. + * + * @return {boolean} True if the Game Object is an immediate child of this Container, otherwise false. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property to the given value on all Game Objects in this Container. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#setAll + * @since 3.4.0 + * + * @param {string} property - The property that must exist on the Game Object. + * @param {any} value - The value to set the property to. + * @param {number} [startIndex=0] - An optional start index to search from. + * @param {number} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {this} This Container instance. + */ + setAll: function (property, value, startIndex, endIndex) + { + ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); + + return this; + }, + + /** + * @callback EachContainerCallback + * @generic I - [item] + * + * @param {*} item - The child Game Object of the Container. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + + /** + * Passes all Game Objects in this Container to the given callback. + * + * A copy of the Container is made before passing each entry to your callback. + * This protects against the callback itself modifying the Container. + * + * If you know for sure that the callback will not change the size of this Container + * then you can use the more performant `Container.iterate` method instead. + * + * @method Phaser.GameObjects.Container#each + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {this} This Container instance. + */ + each: function (callback, context) + { + var args = [ null ]; + var i; + var temp = this.list.slice(); + var len = temp.length; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < len; i++) + { + args[0] = temp[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Passes all Game Objects in this Container to the given callback. + * + * Only use this method when you absolutely know that the Container will not be modified during + * the iteration, i.e. by removing or adding to its contents. + * + * @method Phaser.GameObjects.Container#iterate + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {this} This Container instance. + */ + iterate: function (callback, context) + { + var args = [ null ]; + var i; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Sets the scroll factor of this Container and optionally all of its children. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @method Phaser.GameObjects.Container#setScrollFactor + * @since 3.4.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * @param {boolean} [updateChildren=false] - Apply this scrollFactor to all Container children as well? + * + * @return {this} This Game Object instance. + */ + setScrollFactor: function (x, y, updateChildren) + { + if (y === undefined) { y = x; } + if (updateChildren === undefined) { updateChildren = false; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + if (updateChildren) + { + ArrayUtils.SetAll(this.list, 'scrollFactorX', x); + ArrayUtils.SetAll(this.list, 'scrollFactorY', y); + } + + return this; + }, + + /** + * The number of Game Objects inside this Container. + * + * @name Phaser.GameObjects.Container#length + * @type {number} + * @readonly + * @since 3.4.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * Returns the first Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#first + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the last Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#last + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the next Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#next + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the previous Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#previous + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Container#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.removeAll(!!this.exclusive); + + this.localTransform.destroy(); + + this.list = []; + }, + + /** + * Internal handler, called when a child is destroyed. + * + * @method Phaser.GameObjects.Container#onChildDestroyed + * @protected + * @since 3.80.0 + */ + onChildDestroyed: function (gameObject) + { + ArrayUtils.Remove(this.list, gameObject); + + if (this.exclusive) + { + gameObject.parentContainer = null; + + gameObject.removedFromScene(); + } + } + +}); + +module.exports = Container; + + +/***/ }, + +/***/ 53584 +(module) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderCanvas + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ContainerCanvasRenderer = function (renderer, container, camera, parentMatrix) +{ + camera.addToRenderList(container); + + var children = container.list; + + if (children.length === 0) + { + return; + } + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = container._alpha; + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + if (container.mask) + { + container.mask.preRenderCanvas(renderer, null, camera); + } + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child.alpha; + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + if (!containerHasBlendMode && child.blendMode !== renderer.currentBlendMode) + { + // If Container doesn't have its own blend mode, then a child can have one + renderer.setBlendMode(child.blendMode); + } + + // Set parent values + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + child.setAlpha(childAlpha * alpha); + + // Render + child.renderCanvas(renderer, child, camera, transformMatrix); + + // Restore original values + child.setAlpha(childAlpha); + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + } + + if (container.mask) + { + container.mask.postRenderCanvas(renderer); + } +}; + +module.exports = ContainerCanvasRenderer; + + +/***/ }, + +/***/ 77143 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var Container = __webpack_require__(31559); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetFastValue = __webpack_require__(95540); + +/** + * Creates a new Container Game Object and returns it. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#container + * @since 3.4.0 + * + * @param {Phaser.Types.GameObjects.Container.ContainerConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectCreator.register('container', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var children = GetFastValue(config, 'children', null); + + var container = new Container(this.scene, x, y, children); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, container, config); + + return container; +}); + + +/***/ }, + +/***/ 24961 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Container = __webpack_require__(31559); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Container Game Object and adds it to the Scene. + * + * A Container is a special type of Game Object that can hold other Game Objects as children. + * You can use a Container to group related Game Objects together, then move, rotate, scale, + * or set the alpha of the Container to affect all of its children at once. Children are + * rendered relative to the Container's position and transform, making Containers useful for + * building composite objects, UI panels, or any group of Game Objects that should move together. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#container + * @since 3.4.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional Game Object, or array of Game Objects, to add to this Container. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectFactory.register('container', function (x, y, children) +{ + return this.displayList.add(new Container(this.scene, x, y, children)); +}); + + +/***/ }, + +/***/ 29959 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(72249); +} + +if (true) +{ + renderCanvas = __webpack_require__(53584); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 72249 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(8054); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderWebGL + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + * @param {number} renderStep - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} displayList - The display list which is currently being rendered. + * @param {number} displayListIndex - The index of the Game Object within the display list. + */ +var ContainerWebGLRenderer = function (renderer, container, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) +{ + var camera = drawingContext.camera; + camera.addToRenderList(container); + + var children = container.list; + var childCount = children.length; + + if (childCount === 0) + { + return; + } + + var baseContext = drawingContext; + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode && baseContext.blendMode !== 0) + { + // If Container is SKIP_TEST then set blend mode to be Normal + baseContext = baseContext.getClone(); + baseContext.setBlendMode(0); + baseContext.use(); + } + + var currentContext = baseContext; + + var alpha = container.alpha; + + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + for (var i = 0; i < childCount; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlphaTopLeft; + var childAlphaTopRight; + var childAlphaBottomLeft; + var childAlphaBottomRight; + + if (child.alphaTopLeft !== undefined) + { + childAlphaTopLeft = child.alphaTopLeft; + childAlphaTopRight = child.alphaTopRight; + childAlphaBottomLeft = child.alphaBottomLeft; + childAlphaBottomRight = child.alphaBottomRight; + } + else + { + var childAlpha = child.alpha; + + childAlphaTopLeft = childAlpha; + childAlphaTopRight = childAlpha; + childAlphaBottomLeft = childAlpha; + childAlphaBottomRight = childAlpha; + } + + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + if ( + !containerHasBlendMode && + child.blendMode !== currentContext.blendMode && + child.blendMode !== CONST.BlendModes.SKIP_CHECK + ) + { + // If Container doesn't have its own blend mode, then a child can have one + currentContext = baseContext.getClone(); + currentContext.setBlendMode(child.blendMode); + currentContext.use(); + } + + // Set parent values + + if (child.setScrollFactor) + { + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + } + + if (child.setAlpha) + { + child.setAlpha(childAlphaTopLeft * alpha, childAlphaTopRight * alpha, childAlphaBottomLeft * alpha, childAlphaBottomRight * alpha); + } + + // Render + child.renderWebGLStep(renderer, child, currentContext, transformMatrix, undefined, children, i); + + // Restore original values + + if (child.setAlpha) + { + child.setAlpha(childAlphaTopLeft, childAlphaTopRight, childAlphaBottomLeft, childAlphaBottomRight); + } + + if (child.setScrollFactor) + { + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + } + } + + // Release any remaining context. + if (currentContext !== drawingContext) + { + currentContext.release(); + } +}; + +module.exports = ContainerWebGLRenderer; + + +/***/ }, + +/***/ 55327 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Container = __webpack_require__(31559); + +/** + * @classdesc + * The Custom Context is a game object that allows you to modify the drawing context before it is used. + * + * The Custom Context is an extended Container Game Object. + * Before game objects are rendered, + * it clones the current DrawingContext and passes it to a callback. + * You can configure this callback to set options on the DrawingContext. + * + * See the {@link Phaser.Renderer.WebGL.DrawingContext} documentation for more details + * on DrawingContext settings. + * This is an advanced rendering system and should be used carefully. + * You should mostly only use the setter methods on the DrawingContext object. + * Methods that don't begin with `set` are typically for internal use. + * + * If you modify the DrawingContext to create a new framebuffer, + * it will not render to the canvas. + * It is your responsibility to use the texture from the DrawingContext. + * It is very inefficient to create a new framebuffer every frame, + * though, so you should use a `DynamicTexture` with a retained framebuffer instead. + * + * @class CustomContext + * @extends Phaser.GameObjects.Container + * @memberof Phaser.GameObjects + * @constructor + * @since 4.2.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to the Custom Context. + * @param {Phaser.Types.GameObjects.CustomContext.CustomContextCallback} [customContextCallback] - A function to be called before the custom DrawingContext is activated. If undefined, no callback will be called. + */ +var CustomContext = new Class({ + Extends: Container, + + initialize: function CustomContext(scene, x, y, children, customContextCallback) { + Container.call(this, scene, x, y, children); + + /** + * A function to be called before the custom DrawingContext is activated. + * Set this function to modify the drawing context before it is used, + * or set it to `null` to leave it as is. + * If defined, the callback runs during the `customContextRenderStep` method. + * + * The callback is called with one parameter: + * a copy of the current drawing context. + * + * @example + * // Copy the source context and disable the stencil test. + * this.customContextCallback = (drawingContext) => { + * drawingContext.state.stencil.enabled = false; + * }; + * + * @name Phaser.GameObjects.CustomContext#customContextCallback + * @type {Phaser.Types.GameObjects.CustomContext.CustomContextCallback | null} + * @since 4.2.0 + */ + this.customContextCallback = customContextCallback || null; + + this.addRenderStep(this.customContextRenderStep, 0); + }, + + /** + * The custom render step for the Custom Context. + * This runs before rendering the game object, + * allowing you to modify the drawing context before it is used. + * + * @method Phaser.GameObjects.CustomContext#customContextRenderStep + * @since 4.2.0 + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - This transform matrix is defined if the game object is nested + * @param {number} [renderStep] - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} [displayList] - The display list which is currently being rendered. + * @param {number} [displayListIndex] - The index of the Game Object within the display list. + */ + customContextRenderStep: function (renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) + { + if (renderStep === undefined) { renderStep = 0; } + + if (!gameObject.customContextCallback) + { + gameObject.renderWebGLStep( + renderer, + gameObject, + drawingContext, + parentMatrix, + renderStep + 1, + displayList, + displayListIndex + ); + return; + } + + var currentContext = drawingContext.getClone(); + gameObject.customContextCallback(currentContext); + currentContext.use(); + + gameObject.renderWebGLStep( + renderer, + gameObject, + currentContext, + parentMatrix, + renderStep + 1, + displayList, + displayListIndex + ); + + currentContext.release(); + } +}); + +module.exports = CustomContext; + + +/***/ }, + +/***/ 90255 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var CustomContext = __webpack_require__(55327); + +/** + * Creates a new CustomContext Game Object and returns it. + * + * Note: This method will only be available if the CustomContext Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#customContext + * @since 4.2.0 + * + * @param {Phaser.Types.GameObjects.CustomContext.CustomContextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.CustomContext} The Game Object that was created. + */ +GameObjectCreator.register('customContext', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var children = GetAdvancedValue(config, 'children', null); + var customContextCallback = GetAdvancedValue(config, 'customContextCallback', undefined); + + var customContext = new CustomContext(this.scene, x, y, children, customContextCallback); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, customContext, config); + + return customContext; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 4745 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CustomContext = __webpack_require__(55327); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new CustomContext Game Object and adds it to the Scene. + * + * Note: This method will only be available if the CustomContext Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#customContext + * @webglOnly + * @since 4.2.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to the Custom Context. + * @param {Phaser.Types.GameObjects.CustomContext.CustomContextCallback} [customContextCallback] - A function to be called before the custom DrawingContext is activated. If undefined, no callback will be called. + * + * @return {Phaser.GameObjects.CustomContext} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('customcontext', function (x, y, children, customContextCallback) + { + return this.displayList.add(new CustomContext(this.scene, x, y, children, customContextCallback)); + }); +} + + +/***/ }, + +/***/ 47407 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Phaser Blend Modes to CSS Blend Modes Map. + * + * @name Phaser.CSSBlendModes + * @ignore + * @enum {string} + * @memberof Phaser + * @readonly + * @since 3.12.0 + */ + +module.exports = [ + 'normal', + 'multiply', + 'multiply', + 'screen', + 'overlay', + 'darken', + 'lighten', + 'color-dodge', + 'color-burn', + 'hard-light', + 'soft-light', + 'difference', + 'exclusion', + 'hue', + 'saturation', + 'color', + 'luminosity' +]; + + +/***/ }, + +/***/ 3069 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var DOMElementRender = __webpack_require__(441); +var GameObject = __webpack_require__(95643); +var IsPlainObject = __webpack_require__(41212); +var RemoveFromDOM = __webpack_require__(35846); +var SCENE_EVENTS = __webpack_require__(44594); +var Vector4 = __webpack_require__(61369); + +/** + * @classdesc + * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. + * + * In order for DOM Elements to display you have to enable them by adding the following to your game + * configuration object: + * + * ```javascript + * dom { + * createContainer: true + * } + * ``` + * + * You must also have a parent container for Phaser. This is specified by the `parent` property in the + * game config. + * + * When these two things are added, Phaser will automatically create a DOM Container div that is positioned + * over the top of the game canvas. This div is sized to match the canvas, and if the canvas size changes, + * as a result of settings within the Scale Manager, the dom container is resized accordingly. + * + * If you have not already done so, you have to provide a `parent` in the Game Configuration, or the DOM + * Container will fail to be created. + * + * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing + * Element that you wish to be placed under the control of Phaser. For example: + * + * ```javascript + * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` + * + * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in + * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, + * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. + * + * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control + * alignment and positioning of the elements next to regular game content. + * + * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the + * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other + * methods available in this class to help construct your elements. + * + * Once the element has been created you can then control it like you would any other Game Object. You can set its + * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped + * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that + * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have + * a DOM Element, then a Sprite, then another DOM Element behind it. + * + * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event + * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas + * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you + * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. + * + * DOM Game Objects can be added to a Phaser Container, however you should only nest them **one level deep**. + * Any further down the chain and they will ignore all root container properties. + * + * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. + * + * Note that you should only have DOM Elements in a Scene with a _single_ Camera. If you require multiple cameras, + * use parallel scenes to achieve this. + * + * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert + * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. + * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and + * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top + * of your game, and should treat it accordingly. + * + * @class DOMElement + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.17.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this DOM Element in the world. + * @param {number} [y=0] - The vertical position of this DOM Element in the world. + * @param {(Element|string)} [element] - An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. + * @param {(string|any)} [style] - If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set. + * @param {string} [innerText] - If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. + */ +var DOMElement = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.Origin, + Components.ScrollFactor, + Components.Transform, + Components.Visible, + DOMElementRender + ], + + initialize: + + function DOMElement (scene, x, y, element, style, innerText) + { + GameObject.call(this, scene, 'DOMElement'); + + /** + * A reference to the parent DOM Container that the Game instance created when it started. + * + * @name Phaser.GameObjects.DOMElement#parent + * @type {Element} + * @since 3.17.0 + */ + this.parent = scene.sys.game.domContainer; + + if (!this.parent) + { + throw new Error('No DOM Container set in game config'); + } + + /** + * A reference to the HTML Cache. + * + * @name Phaser.GameObjects.DOMElement#cache + * @type {Phaser.Cache.BaseCache} + * @since 3.17.0 + */ + this.cache = scene.sys.cache.html; + + /** + * The actual DOM Element that this Game Object is bound to. For example, if you've created a `
` + * then this property is a direct reference to that element within the dom. + * + * @name Phaser.GameObjects.DOMElement#node + * @type {Element} + * @since 3.17.0 + */ + this.node; + + /** + * By default a DOM Element will have its transform, display, opacity, zIndex and blend mode properties + * updated when its rendered. If, for some reason, you don't want any of these changed other than the + * CSS transform, then set this flag to `true`. When `true` only the CSS Transform is applied and it's + * up to you to keep track of and set the other properties as required. + * + * This can be handy if, for example, you've a nested DOM Element and you don't want the opacity to be + * picked-up by any of its children. + * + * @name Phaser.GameObjects.DOMElement#transformOnly + * @type {boolean} + * @since 3.17.0 + */ + this.transformOnly = false; + + /** + * The angle, in radians, by which to skew the DOM Element on the horizontal axis. + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform + * + * @name Phaser.GameObjects.DOMElement#skewX + * @type {number} + * @since 3.17.0 + */ + this.skewX = 0; + + /** + * The angle, in radians, by which to skew the DOM Element on the vertical axis. + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform + * + * @name Phaser.GameObjects.DOMElement#skewY + * @type {number} + * @since 3.17.0 + */ + this.skewY = 0; + + /** + * A Vector4 that contains the 3D rotation of this DOM Element around a fixed axis in 3D space. + * + * The x, y, and z components define the direction of the rotation axis. The w component holds the + * angle of rotation, in the unit defined by the `rotate3dAngle` property (degrees by default). + * + * For more details see the following MDN page: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d + * + * @name Phaser.GameObjects.DOMElement#rotate3d + * @type {Phaser.Math.Vector4} + * @since 3.17.0 + */ + this.rotate3d = new Vector4(); + + /** + * The unit that represents the 3D rotation values. By default this is `deg` for degrees, but can + * be changed to any supported unit. See this page for further details: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d + * + * @name Phaser.GameObjects.DOMElement#rotate3dAngle + * @type {string} + * @since 3.17.0 + */ + this.rotate3dAngle = 'deg'; + + /** + * Sets the CSS `pointerEvents` attribute on the DOM Element during rendering. + * + * This is 'auto' by default. Changing it may have unintended side-effects with + * internal Phaser input handling, such as dragging, so only change this if you + * understand the implications. + * + * @name Phaser.GameObjects.DOMElement#pointerEvents + * @type {string} + * @since 3.55.0 + */ + this.pointerEvents = 'auto'; + + /** + * The native (un-scaled) width of this Game Object. + * + * For a DOM Element this property is read-only. + * + * The property `displayWidth` holds the computed bounds of this DOM Element, factoring in scaling. + * + * @name Phaser.GameObjects.DOMElement#width + * @type {number} + * @readonly + * @since 3.17.0 + */ + this.width = 0; + + /** + * The native (un-scaled) height of this Game Object. + * + * For a DOM Element this property is read-only. + * + * The property `displayHeight` holds the computed bounds of this DOM Element, factoring in scaling. + * + * @name Phaser.GameObjects.DOMElement#height + * @type {number} + * @readonly + * @since 3.17.0 + */ + this.height = 0; + + /** + * The computed display width of this Game Object, based on the `getBoundingClientRect` DOM call. + * + * The property `width` holds the un-scaled width of this DOM Element. + * + * @name Phaser.GameObjects.DOMElement#displayWidth + * @type {number} + * @readonly + * @since 3.17.0 + */ + this.displayWidth = 0; + + /** + * The computed display height of this Game Object, based on the `getBoundingClientRect` DOM call. + * + * The property `height` holds the un-scaled height of this DOM Element. + * + * @name Phaser.GameObjects.DOMElement#displayHeight + * @type {number} + * @readonly + * @since 3.17.0 + */ + this.displayHeight = 0; + + /** + * Internal native event handler. + * + * @name Phaser.GameObjects.DOMElement#handler + * @type {number} + * @private + * @since 3.17.0 + */ + this.handler = this.dispatchNativeEvent.bind(this); + + this.setPosition(x, y); + + if (typeof element === 'string') + { + // hash? + if (element[0] === '#') + { + this.setElement(element.substr(1), style, innerText); + } + else + { + this.createElement(element, style, innerText); + } + } + else if (element) + { + this.setElement(element, style, innerText); + } + + scene.sys.events.on(SCENE_EVENTS.SLEEP, this.handleSceneEvent, this); + scene.sys.events.on(SCENE_EVENTS.WAKE, this.handleSceneEvent, this); + scene.sys.events.on(SCENE_EVENTS.PRE_RENDER, this.preRender, this); + }, + + /** + * Handles a Scene Sleep and Wake event. + * + * @method Phaser.GameObjects.DOMElement#handleSceneEvent + * @private + * @since 3.22.0 + * + * @param {Phaser.Scenes.Systems} sys - The Scene Systems. + */ + handleSceneEvent: function (sys) + { + var node = this.node; + var style = node.style; + + if (node) + { + style.display = (sys.settings.visible) ? 'block' : 'none'; + } + }, + + /** + * Sets the horizontal and vertical skew values of this DOM Element. + * + * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/transform + * + * @method Phaser.GameObjects.DOMElement#setSkew + * @since 3.17.0 + * + * @param {number} [x=0] - The angle, in radians, by which to skew the DOM Element on the horizontal axis. + * @param {number} [y=x] - The angle, in radians, by which to skew the DOM Element on the vertical axis. + * + * @return {this} This DOM Element instance. + */ + setSkew: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.skewX = x; + this.skewY = y; + + return this; + }, + + /** + * Sets the perspective CSS property of the _parent DOM Container_. This determines the distance between the z=0 + * plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with + * z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined + * by the value of this property. + * + * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective + * + * **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.** + * + * @method Phaser.GameObjects.DOMElement#setPerspective + * @since 3.17.0 + * + * @param {number} value - The perspective value, in pixels, that determines the distance between the z plane and the user. + * + * @return {this} This DOM Element instance. + */ + setPerspective: function (value) + { + this.parent.style.perspective = value + 'px'; + + return this; + }, + + /** + * The perspective CSS property value of the _parent DOM Container_. This determines the distance between the z=0 + * plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with + * z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined + * by the value of this property. + * + * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective + * + * **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.** + * + * @name Phaser.GameObjects.DOMElement#perspective + * @type {number} + * @since 3.17.0 + */ + perspective: { + + get: function () + { + return parseFloat(this.parent.style.perspective); + }, + + set: function (value) + { + this.parent.style.perspective = value + 'px'; + } + + }, + + /** + * Adds one or more native DOM event listeners onto the underlying Element of this Game Object. + * The event is then dispatched via this Game Objects standard event emitter. + * + * For example: + * + * ```javascript + * var div = this.add.dom(x, y, element); + * + * div.addListener('click'); + * + * div.on('click', handler); + * ``` + * + * @method Phaser.GameObjects.DOMElement#addListener + * @since 3.17.0 + * + * @param {string} events - The DOM event/s to listen for. You can specify multiple events by separating them with spaces. + * + * @return {this} This DOM Element instance. + */ + addListener: function (events) + { + if (this.node) + { + events = events.split(' '); + + for (var i = 0; i < events.length; i++) + { + this.node.addEventListener(events[i], this.handler, false); + } + } + + return this; + }, + + /** + * Removes one or more native DOM event listeners from the underlying Element of this Game Object. + * + * @method Phaser.GameObjects.DOMElement#removeListener + * @since 3.17.0 + * + * @param {string} events - The DOM event/s to stop listening for. You can specify multiple events by separating them with spaces. + * + * @return {this} This DOM Element instance. + */ + removeListener: function (events) + { + if (this.node) + { + events = events.split(' '); + + for (var i = 0; i < events.length; i++) + { + this.node.removeEventListener(events[i], this.handler); + } + } + + return this; + }, + + /** + * Internal event proxy to dispatch native DOM Events via this Game Object. + * + * @method Phaser.GameObjects.DOMElement#dispatchNativeEvent + * @private + * @since 3.17.0 + * + * @param {any} event - The native DOM event. + */ + dispatchNativeEvent: function (event) + { + this.emit(event.type, event); + }, + + /** + * Creates a native DOM Element, adds it to the parent DOM Container and then binds it to this Game Object, + * so you can control it. The `tagName` should be a string and is passed to `document.createElement`: + * + * ```javascript + * this.add.dom().createElement('div'); + * ``` + * + * For more details on acceptable tag names see: https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement + * + * You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText` + * value as well. Here is an example of a DOMString: + * + * ```javascript + * this.add.dom().createElement('div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` + * + * And using a style object: + * + * ```javascript + * var style = { + * 'background-color': 'lime'; + * 'width': '200px'; + * 'height': '100px'; + * 'font': '48px Arial'; + * }; + * + * this.add.dom().createElement('div', style, 'Phaser'); + * ``` + * + * If this Game Object already has an Element, it is removed from the DOM entirely first. + * Any event listeners you may have previously created will need to be re-created after this call. + * + * @method Phaser.GameObjects.DOMElement#createElement + * @since 3.17.0 + * + * @param {string} tagName - A string that specifies the type of element to be created. The nodeName of the created element is initialized with the value of tagName. Don't use qualified names (like "html:a") with this method. + * @param {(string|any)} [style] - Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be read from. + * @param {string} [innerText] - A DOMString that holds the text that will be set as the innerText of the created element. + * + * @return {this} This DOM Element instance. + */ + createElement: function (tagName, style, innerText) + { + return this.setElement(document.createElement(tagName), style, innerText); + }, + + /** + * Binds a new DOM Element to this Game Object. If this Game Object already has an Element it is removed from the DOM + * entirely first. Any event listeners you may have previously created will need to be re-created on the new element. + * + * The `element` argument you pass to this method can be either a string tagName: + * + * ```javascript + *

Phaser

+ * + * this.add.dom().setElement('heading'); + * ``` + * + * Or a reference to an Element instance: + * + * ```javascript + *

Phaser

+ * + * var h1 = document.getElementById('heading'); + * + * this.add.dom().setElement(h1); + * ``` + * + * You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText` + * value as well. Here is an example of a DOMString: + * + * ```javascript + * this.add.dom().setElement(h1, 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` + * + * And using a style object: + * + * ```javascript + * var style = { + * 'background-color': 'lime'; + * 'width': '200px'; + * 'height': '100px'; + * 'font': '48px Arial'; + * }; + * + * this.add.dom().setElement(h1, style, 'Phaser'); + * ``` + * + * @method Phaser.GameObjects.DOMElement#setElement + * @since 3.17.0 + * + * @param {(string|Element)} element - If a string it is passed to `getElementById()`, or it should be a reference to an existing Element. + * @param {(string|any)} [style] - Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be read from. + * @param {string} [innerText] - A DOMString that holds the text that will be set as the innerText of the created element. + * + * @return {this} This DOM Element instance. + */ + setElement: function (element, style, innerText) + { + // Already got an element? Remove it first + this.removeElement(); + + var target; + + if (typeof element === 'string') + { + // hash? + if (element[0] === '#') + { + element = element.substr(1); + } + + target = document.getElementById(element); + } + else if (typeof element === 'object' && element.nodeType === 1) + { + target = element; + } + + if (!target) + { + return this; + } + + this.node = target; + + // style can be empty, a string or a plain object + if (style && IsPlainObject(style)) + { + for (var key in style) + { + target.style[key] = style[key]; + } + } + else if (typeof style === 'string') + { + target.style = style; + } + + // Add / Override the values we need + + target.style.zIndex = '0'; + target.style.display = 'inline'; + target.style.position = 'absolute'; + + // Node handler + + target.phaser = this; + + this.parent.appendChild(target); + + // InnerText + + if (innerText) + { + target.innerText = innerText; + } + + return this.updateSize(); + }, + + /** + * Takes a block of html from the HTML Cache, that has previously been preloaded into the game, and then + * creates a DOM Element from it. The loaded HTML is set as the `innerHTML` property of the created + * element. + * + * Assume the following html is stored in a file called `loginform.html`: + * + * ```html + * + * + * ``` + * + * Which is loaded into your game using the cache key 'login': + * + * ```javascript + * this.load.html('login', 'assets/loginform.html'); + * ``` + * + * You can create a DOM Element from it using the cache key: + * + * ```javascript + * this.add.dom().createFromCache('login'); + * ``` + * + * The optional `elementType` argument controls the container that is created, into which the loaded html is inserted. + * The default is a plain `div` object, but any valid tagName can be given. + * + * If this Game Object already has an Element, it is removed from the DOM entirely first. + * Any event listeners you may have previously created will need to be re-created after this call. + * + * @method Phaser.GameObjects.DOMElement#createFromCache + * @since 3.17.0 + * + * @param {string} key - The key of the html cache entry to use for this DOM Element. + * @param {string} [tagName='div'] - The tag name of the element into which all of the loaded html will be inserted. Defaults to a plain div tag. + * + * @return {this} This DOM Element instance. + */ + createFromCache: function (key, tagName) + { + var html = this.cache.get(key); + + if (html) + { + this.createFromHTML(html, tagName); + } + + return this; + }, + + /** + * Takes a string of html and then creates a DOM Element from it. The HTML is set as the `innerHTML` + * property of the created element. + * + * ```javascript + * let form = ` + * + * + * `; + * ``` + * + * You can create a DOM Element from it using the string: + * + * ```javascript + * this.add.dom().createFromHTML(form); + * ``` + * + * The optional `elementType` argument controls the type of container that is created, into which the html is inserted. + * The default is a plain `div` object, but any valid tagName can be given. + * + * If this Game Object already has an Element, it is removed from the DOM entirely first. + * Any event listeners you may have previously created will need to be re-created after this call. + * + * @method Phaser.GameObjects.DOMElement#createFromHTML + * @since 3.17.0 + * + * @param {string} html - A string of html to be set as the `innerHTML` property of the created element. + * @param {string} [tagName='div'] - The tag name of the element into which all of the html will be inserted. Defaults to a plain div tag. + * + * @return {this} This DOM Element instance. + */ + createFromHTML: function (html, tagName) + { + if (tagName === undefined) { tagName = 'div'; } + + // Already got an element? Remove it first + this.removeElement(); + + var element = document.createElement(tagName); + + this.node = element; + + element.style.zIndex = '0'; + element.style.display = 'inline'; + element.style.position = 'absolute'; + + // Node handler + + element.phaser = this; + + this.parent.appendChild(element); + + element.innerHTML = html; + + return this.updateSize(); + }, + + /** + * Removes the current DOM Element bound to this Game Object from the DOM entirely and resets the + * `node` property of this Game Object to be `null`. + * + * @method Phaser.GameObjects.DOMElement#removeElement + * @since 3.17.0 + * + * @return {this} This DOM Element instance. + */ + removeElement: function () + { + if (this.node) + { + RemoveFromDOM(this.node); + + this.node = null; + } + + return this; + }, + + /** + * Internal method that sets the `displayWidth` and `displayHeight` properties, and the `clientWidth` + * and `clientHeight` values into the `width` and `height` properties respectively. + * + * This is called automatically whenever a new element is created or set. + * + * @method Phaser.GameObjects.DOMElement#updateSize + * @since 3.17.0 + * + * @return {this} This DOM Element instance. + */ + updateSize: function () + { + var node = this.node; + + this.width = node.clientWidth; + this.height = node.clientHeight; + + this.displayWidth = this.width * this.scaleX; + this.displayHeight = this.height * this.scaleY; + + return this; + }, + + /** + * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through + * them, looking for the first one that has a property matching the given key and value. It then returns this child + * if found, or `null` if not. + * + * @method Phaser.GameObjects.DOMElement#getChildByProperty + * @since 3.17.0 + * + * @param {string} property - The property to search the children for. + * @param {string} value - The value the property must strictly equal. + * + * @return {?Element} The first matching child DOM Element, or `null` if not found. + */ + getChildByProperty: function (property, value) + { + if (this.node) + { + var children = this.node.querySelectorAll('*'); + + for (var i = 0; i < children.length; i++) + { + if (children[i][property] === value) + { + return children[i]; + } + } + } + + return null; + }, + + /** + * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through + * them, looking for the first one that has a matching id. It then returns this child if found, or `null` if not. + * + * Be aware that class and id names are case-sensitive. + * + * @method Phaser.GameObjects.DOMElement#getChildByID + * @since 3.17.0 + * + * @param {string} id - The id to search the children for. + * + * @return {?Element} The first matching child DOM Element, or `null` if not found. + */ + getChildByID: function (id) + { + return this.getChildByProperty('id', id); + }, + + /** + * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through + * them, looking for the first one that has a matching name. It then returns this child if found, or `null` if not. + * + * Be aware that class and id names are case-sensitive. + * + * @method Phaser.GameObjects.DOMElement#getChildByName + * @since 3.17.0 + * + * @param {string} name - The name to search the children for. + * + * @return {?Element} The first matching child DOM Element, or `null` if not found. + */ + getChildByName: function (name) + { + return this.getChildByProperty('name', name); + }, + + /** + * Sets the `className` property of the DOM Element node and updates the internal sizes. + * + * @method Phaser.GameObjects.DOMElement#setClassName + * @since 3.17.0 + * + * @param {string} className - A string representing the class or space-separated classes of the element. + * + * @return {this} This DOM Element instance. + */ + setClassName: function (className) + { + if (this.node) + { + this.node.className = className; + + this.updateSize(); + } + + return this; + }, + + /** + * Sets the `innerText` property of the DOM Element node and updates the internal sizes. + * + * Note that only certain types of Elements can have `innerText` set on them. + * + * @method Phaser.GameObjects.DOMElement#setText + * @since 3.17.0 + * + * @param {string} text - A DOMString representing the rendered text content of the element. + * + * @return {this} This DOM Element instance. + */ + setText: function (text) + { + if (this.node) + { + this.node.innerText = text; + + this.updateSize(); + } + + return this; + }, + + /** + * Sets the `innerHTML` property of the DOM Element node and updates the internal sizes. + * + * @method Phaser.GameObjects.DOMElement#setHTML + * @since 3.17.0 + * + * @param {string} html - A DOMString of html to be set as the `innerHTML` property of the element. + * + * @return {this} This DOM Element instance. + */ + setHTML: function (html) + { + if (this.node) + { + this.node.innerHTML = html; + + this.updateSize(); + } + + return this; + }, + + /** + * Runs internal update tasks. + * + * @method Phaser.GameObjects.DOMElement#preRender + * @private + * @since 3.60.0 + */ + preRender: function () + { + var parent = this.parentContainer; + var node = this.node; + + if (node && parent && !parent.willRender()) + { + node.style.display = 'none'; + } + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * + * DOMElements always return `true` as they need to still set values during the render pass, even if not visible. + * + * @method Phaser.GameObjects.DOMElement#willRender + * @since 3.17.0 + * + * @return {boolean} `true` if the Game Object should be rendered, otherwise `false`. + */ + willRender: function () + { + return true; + }, + + /** + * Handles the pre-destroy step for the DOM Element, which removes the underlying node from the DOM. + * + * @method Phaser.GameObjects.DOMElement#preDestroy + * @private + * @since 3.17.0 + */ + preDestroy: function () + { + this.removeElement(); + + this.scene.sys.events.off(SCENE_EVENTS.SLEEP, this.handleSceneEvent, this); + this.scene.sys.events.off(SCENE_EVENTS.WAKE, this.handleSceneEvent, this); + this.scene.sys.events.off(SCENE_EVENTS.PRE_RENDER, this.preRender, this); + } + +}); + +module.exports = DOMElement; + + +/***/ }, + +/***/ 49381 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CSSBlendModes = __webpack_require__(47407); +var GameObject = __webpack_require__(95643); +var TransformMatrix = __webpack_require__(61340); + +var tempMatrix1 = new TransformMatrix(); +var tempMatrix2 = new TransformMatrix(); +var tempMatrix3 = new TransformMatrix(); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DOMElement#renderWebGL + * @since 3.17.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active renderer. + * @param {Phaser.GameObjects.DOMElement} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DOMElementCSSRenderer = function (renderer, src, camera, parentMatrix) +{ + if (!src.node) + { + return; + } + + if (camera.camera) + { + // `camera` is really a DrawingContext object, used in WebGL rendering. + camera = camera.camera; + } + + var style = src.node.style; + var settings = src.scene.sys.settings; + + if (!style || !settings.visible || GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter !== 0 && (src.cameraFilter & camera.id)) || (src.parentContainer && !src.parentContainer.willRender())) + { + style.display = 'none'; + + return; + } + + var parent = src.parentContainer; + var alpha = camera.alpha * src.alpha; + + if (parent) + { + alpha *= parent.alpha; + } + + var camMatrix = tempMatrix1; + var srcMatrix = tempMatrix2; + var calcMatrix = tempMatrix3; + + var dx = src.width * src.originX; + var dy = src.height * src.originY; + + var tx = '0%'; + var ty = '0%'; + + camMatrix.copyWithScrollFactorFrom( + camera.matrix, + camera.scrollX, camera.scrollY, + src.scrollFactorX, src.scrollFactorY + ); + + if (parentMatrix) + { + camMatrix.multiply(parentMatrix); + dx *= src.scaleX; + dy *= src.scaleY; + } + else + { + tx = (100 * src.originX) + '%'; + ty = (100 * src.originY) + '%'; + } + + camMatrix.translate(-dx, -dy); + + srcMatrix.applyITRS( + src.x, src.y, + src.rotation, + src.scaleX, src.scaleY + ); + + camMatrix.multiply(srcMatrix, calcMatrix); + + if (!src.transformOnly) + { + style.display = 'block'; + style.opacity = alpha; + style.zIndex = src._depth; + style.pointerEvents = src.pointerEvents; + style.mixBlendMode = CSSBlendModes[src._blendMode]; + } + + // https://developer.mozilla.org/en-US/docs/Web/CSS/transform + + style.transform = + calcMatrix.getCSSMatrix() + + ' skew(' + src.skewX + 'rad, ' + src.skewY + 'rad)' + + ' rotate3d(' + src.rotate3d.x + ',' + src.rotate3d.y + ',' + src.rotate3d.z + ',' + src.rotate3d.w + src.rotate3dAngle + ')'; + + style.transformOrigin = tx + ' ' + ty; +}; + +module.exports = DOMElementCSSRenderer; + + +/***/ }, + +/***/ 2611 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DOMElement = __webpack_require__(3069); +var GameObjectFactory = __webpack_require__(39429); + +/** + * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. + * + * In order for DOM Elements to display you have to enable them by adding the following to your game + * configuration object: + * + * ```javascript + * dom { + * createContainer: true + * } + * ``` + * + * When this is added, Phaser will automatically create a DOM Container div that is positioned over the top + * of the game canvas. This div is sized to match the canvas, and if the canvas size changes, as a result of + * settings within the Scale Manager, the dom container is resized accordingly. + * + * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing + * Element that you wish to be placed under the control of Phaser. For example: + * + * ```javascript + * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` + * + * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in + * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, + * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. + * + * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control + * alignment and positioning of the elements next to regular game content. + * + * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the + * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other + * methods available in this class to help construct your elements. + * + * Once the element has been created you can then control it like you would any other Game Object. You can set its + * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped + * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that + * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have + * a DOM Element, then a Sprite, then another DOM Element behind it. + * + * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event + * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas + * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you + * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. + * + * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. + * + * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert + * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. + * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and + * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top + * of your game, and should treat it accordingly. + * + * Note: This method will only be available if the DOM Element Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dom + * @since 3.17.0 + * + * @param {number} x - The horizontal position of this DOM Element in the world. + * @param {number} y - The vertical position of this DOM Element in the world. + * @param {(HTMLElement|string)} [element] - An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. + * @param {(string|any)} [style] - If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replace whatever CSS styles may have been previously set. + * @param {string} [innerText] - If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. + * + * @return {Phaser.GameObjects.DOMElement} The Game Object that was created. + */ +GameObjectFactory.register('dom', function (x, y, element, style, innerText) +{ + var gameObject = new DOMElement(this.scene, x, y, element, style, innerText); + + this.displayList.add(gameObject); + + return gameObject; +}); + + +/***/ }, + +/***/ 441 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(49381); +} + +if (true) +{ + renderCanvas = __webpack_require__(49381); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 62980 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Added to Scene Event. + * + * This event is dispatched when a Game Object is added to a Scene. + * + * Listen for it on a Game Object instance using `GameObject.on('addedtoscene', listener)`. + * + * @event Phaser.GameObjects.Events#ADDED_TO_SCENE + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was added to the Scene. + * @param {Phaser.Scene} scene - The Scene to which the Game Object was added. + */ +module.exports = 'addedtoscene'; + + +/***/ }, + +/***/ 41337 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Destroy Event. + * + * This event is dispatched when a Game Object instance is being destroyed. + * + * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. + * + * @event Phaser.GameObjects.Events#DESTROY + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object which is being destroyed. + * @param {boolean} fromScene - `True` if this Game Object is being destroyed by the Scene, `false` if not. + */ +module.exports = 'destroy'; + + +/***/ }, + +/***/ 44947 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Removed from Scene Event. + * + * This event is dispatched when a Game Object is removed from a Scene. + * + * Listen for it on a Game Object instance using `GameObject.on('removedfromscene', listener)`. + * + * @event Phaser.GameObjects.Events#REMOVED_FROM_SCENE + * @type {string} + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was removed from the Scene. + * @param {Phaser.Scene} scene - The Scene from which the Game Object was removed. + */ +module.exports = 'removedfromscene'; + + +/***/ }, + +/***/ 49358 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Complete Event. + * + * This event is dispatched when a Video finishes playback by reaching the end of its duration. It + * is also dispatched if a video marker sequence is being played and reaches the end. + * + * Note that not all videos can fire this event. Live streams, for example, have no fixed duration, + * so never technically 'complete'. + * + * If a video is stopped from playback, via the `Video.stop` method, it will emit the + * `VIDEO_STOP` event instead of this one. + * + * Listen for it from a Video Game Object instance using `Video.on('complete', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_COMPLETE + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which completed playback. + */ +module.exports = 'complete'; + + +/***/ }, + +/***/ 35163 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Created Event. + * + * This event is dispatched when the texture for a Video has been created. This happens + * when enough of the video source has been loaded that the browser is able to render a + * frame from it. + * + * Listen for it from a Video Game Object instance using `Video.on('created', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_CREATED + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which raised the event. + * @param {number} width - The width of the video. + * @param {number} height - The height of the video. + */ +module.exports = 'created'; + + +/***/ }, + +/***/ 97249 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Error Event. + * + * This event is dispatched when a Video tries to play a source that does not exist, or is the wrong file type. + * + * Listen for it from a Video Game Object instance using `Video.on('error', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_ERROR + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which threw the error. + * @param {DOMException|string} event - The native DOM event the browser raised during playback. + */ +module.exports = 'error'; + + +/***/ }, + +/***/ 19483 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Locked Event. + * + * This event is dispatched when a Video was attempted to be played, but the browser prevented it + * from doing so due to the Media Engagement Interaction policy. + * + * If you get this event you will need to wait for the user to interact with the browser before + * the video will play. This is a browser security measure to prevent autoplaying videos with + * audio. An interaction includes a mouse click, a touch, or a key press. + * + * Listen for it from a Video Game Object instance using `Video.on('locked', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_LOCKED + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which raised the event. + */ +module.exports = 'locked'; + + +/***/ }, + +/***/ 56059 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Loop Event. + * + * This event is dispatched when a Video that is currently playing has looped. This only + * happens if the `loop` parameter was specified, or the `setLoop` method was called, + * and if the video has a fixed duration. Video streams, for example, cannot loop, as + * they have no duration. + * + * Looping is based on the result of the Video `timeupdate` event. This event is not + * frame-accurate, due to the way browsers work, so please do not rely on this loop + * event to be time or frame precise. + * + * Listen for it from a Video Game Object instance using `Video.on('loop', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_LOOP + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which has looped. + */ +module.exports = 'loop'; + + +/***/ }, + +/***/ 26772 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Metadata Event. + * + * This event is dispatched when a Video has access to the metadata. + * + * Listen for it from a Video Game Object instance using `Video.on('metadata', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_METADATA + * @type {string} + * @since 3.80.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which fired the event. + * @param {DOMException|string} event - The native DOM event the browser raised during playback. + */ +module.exports = 'metadata'; + + +/***/ }, + +/***/ 64437 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Playing Event. + * + * The playing event is fired after playback is first started, + * and whenever it is restarted. For example it is fired when playback + * resumes after having been paused or delayed due to lack of data. + * + * Listen for it from a Video Game Object instance using `Video.on('playing', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_PLAYING + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which started playback. + */ +module.exports = 'playing'; + + +/***/ }, + +/***/ 83411 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Play Event. + * + * This event is dispatched when a Video begins playback. For videos that do not require + * interaction unlocking, this is usually as soon as the `Video.play` method is called. + * However, for videos that require unlocking, it is fired once playback begins after + * they've been unlocked. + * + * Listen for it from a Video Game Object instance using `Video.on('play', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_PLAY + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which started playback. + */ +module.exports = 'play'; + + +/***/ }, + +/***/ 75780 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Seeked Event. + * + * This event is dispatched when a Video completes seeking to a new point in its timeline. + * + * Listen for it from a Video Game Object instance using `Video.on('seeked', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_SEEKED + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which completed seeking. + */ +module.exports = 'seeked'; + + +/***/ }, + +/***/ 67799 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Seeking Event. + * + * This event is dispatched when a Video _begins_ seeking to a new point in its timeline. + * When the seek is complete, it will dispatch the `VIDEO_SEEKED` event to conclude. + * + * Listen for it from a Video Game Object instance using `Video.on('seeking', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_SEEKING + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which started seeking. + */ +module.exports = 'seeking'; + + +/***/ }, + +/***/ 63500 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Stalled Event. + * + * This event is dispatched by a Video Game Object when the video playback stalls. + * + * This can happen if the video is buffering. + * + * If will fire for any of the following native DOM events: + * + * `stalled` + * `suspend` + * `waiting` + * + * Listen for it from a Video Game Object instance using `Video.on('stalled', listener)`. + * + * Note that being stalled isn't always a negative thing. A video can be stalled if it + * has downloaded enough data in to its buffer to not need to download any more until + * the current batch of frames have rendered. + * + * @event Phaser.GameObjects.Events#VIDEO_STALLED + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which threw the error. + * @param {Event} event - The native DOM event the browser raised during playback. + */ +module.exports = 'stalled'; + + +/***/ }, + +/***/ 55541 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Stopped Event. + * + * This event is dispatched when a Video is stopped from playback via a call to the `Video.stop` method, + * either directly via game code, or indirectly as the result of changing a video source or destroying it. + * + * Listen for it from a Video Game Object instance using `Video.on('stop', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_STOP + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which stopped playback. + */ +module.exports = 'stop'; + + +/***/ }, + +/***/ 53208 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Texture Ready Event. + * + * This event is dispatched by a Video Game Object when it has finished creating its texture. + * + * This happens when the video has finished loading enough data for its first frame. + * + * If you wish to use the Video texture elsewhere in your game, such as as a Sprite texture, + * then you should listen for this event first, before creating the Sprites that use it. + * + * Listen for it from a Video Game Object instance using `Video.on('textureready', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_TEXTURE + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object that emitted the event. + * @param {Phaser.Textures.Texture} texture - The Texture that was created. + */ +module.exports = 'textureready'; + + +/***/ }, + +/***/ 4992 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Unlocked Event. + * + * This event is dispatched when a Video that was prevented from playback due to the browsers + * Media Engagement Interaction policy, is unlocked by a user gesture. + * + * Listen for it from a Video Game Object instance using `Video.on('unlocked', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_UNLOCKED + * @type {string} + * @since 3.20.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which raised the event. + */ +module.exports = 'unlocked'; + + +/***/ }, + +/***/ 12 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Unsupported Event. + * + * This event is dispatched by a Video Game Object if the media source + * (which may be specified as a MediaStream, MediaSource, Blob, or File, + * for example) doesn't represent a supported media format. + * + * Listen for it from a Video Game Object instance using `Video.on('unsupported', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_UNSUPPORTED + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which started playback. + * @param {DOMException|string} event - The native DOM event the browser raised during playback. + */ +module.exports = 'unsupported'; + + +/***/ }, + +/***/ 51708 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Events + */ + +module.exports = { + + ADDED_TO_SCENE: __webpack_require__(62980), + DESTROY: __webpack_require__(41337), + REMOVED_FROM_SCENE: __webpack_require__(44947), + VIDEO_COMPLETE: __webpack_require__(49358), + VIDEO_CREATED: __webpack_require__(35163), + VIDEO_ERROR: __webpack_require__(97249), + VIDEO_LOCKED: __webpack_require__(19483), + VIDEO_LOOP: __webpack_require__(56059), + VIDEO_METADATA: __webpack_require__(26772), + VIDEO_PLAY: __webpack_require__(83411), + VIDEO_PLAYING: __webpack_require__(64437), + VIDEO_SEEKED: __webpack_require__(75780), + VIDEO_SEEKING: __webpack_require__(67799), + VIDEO_STALLED: __webpack_require__(63500), + VIDEO_STOP: __webpack_require__(55541), + VIDEO_TEXTURE: __webpack_require__(53208), + VIDEO_UNLOCKED: __webpack_require__(4992), + VIDEO_UNSUPPORTED: __webpack_require__(12) + +}; + + +/***/ }, + +/***/ 42421 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var ExternRender = __webpack_require__(64993); + +/** + * @classdesc + * An Extern Game Object is a special type of Game Object that allows you to pass + * rendering off to a 3rd party. + * + * When you create an Extern and place it in the display list of a Scene, the renderer will + * process the list as usual. When it finds an Extern it will flush the current batch + * and prepare a transform matrix which your render function can + * take advantage of, if required. + * + * The WebGL context is then left in a 'clean' state, ready for you to bind your own shaders, + * or draw to it, whatever you wish to do. This should all take place in the `render` method. + * The correct way to deploy an Extern object is to create a class that extends it, then + * override the `render` (and optionally `preUpdate`) methods and pass off control to your + * 3rd party libraries or custom WebGL code there. + * + * The `render` method is called with this signature: + * `render(renderer: Phaser.Renderer.WebGL.WebGLRenderer, drawingContext: Phaser.Renderer.WebGL.DrawingContext, calcMatrix: Phaser.GameObjects.Components.TransformMatrix, displayList: Phaser.GameObjects.GameObject[], displayListIndex: number): void`. + * + * The `displayList` and `displayListIndex` parameters allow you to check + * other objects in the display list. This might be convenient for optimizing + * operations such as resource management. + * + * Once you've finished, you should free-up any of your resources. + * The Extern will then return Phaser state and carry on rendering the display list. + * + * Although this object has lots of properties such as Alpha, Blend Mode and Tint, none of + * them are used during rendering unless you take advantage of them in your own render code. + * + * @example + * extern.render = (webGLRenderer, drawingContext, calcMatrix) => { + * // You may want to initialize the external renderer here. + * // ... + * + * // Ensure the DrawingContext framebuffer is bound. + * // This allows you to use Filters on the external render. + * webGLRenderer.glWrapper.updateBindingsFramebuffer({ + * bindings: { + * framebuffer: drawingContext.framebuffer + * } + * }, true); + * + * // Run the external render method. + * // ... + * }; + * + * @class Extern + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.16.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + */ +var Extern = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.Origin, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + ExternRender + ], + + initialize: + + function Extern (scene) + { + GameObject.call(this, scene, 'Extern'); + }, + + /** + * Called when this Extern is added to a Scene. + * + * Registers the Extern with the Scene's Update List so that `preUpdate` is called each frame. + * + * @method Phaser.GameObjects.Extern#addedToScene + * @since 3.50.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Called when this Extern is removed from a Scene. + * + * Removes the Extern from the Scene's Update List so that `preUpdate` is no longer called. + * + * @method Phaser.GameObjects.Extern#removedFromScene + * @since 3.50.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * Called automatically by the Scene Update List each frame. + * + * Override this method in your own class to add custom logic that + * should run every frame, such as updating animations or physics. + * + * @method Phaser.GameObjects.Extern#preUpdate + * @since 3.16.0 + * + * @param {number} time - The current timestamp, as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function () + { + // override this! + // Arguments: time, delta + }, + + /** + * Override this method in your own class to provide custom rendering logic. + * + * When the renderer encounters this Extern in the display list, it will flush the + * current batch, prepare a transform matrix, and leave the WebGL context in a clean + * state for you to bind your own shaders or draw calls. + * + * @method Phaser.GameObjects.Extern#render + * @since 3.16.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current Drawing Context. + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The calculated Transform Matrix for this Extern. + * @param {Phaser.GameObjects.GameObject[]} displayList - The current display list for the Scene. + * @param {number} displayListIndex - The index of this Extern within the display list. + */ + render: function () + { + // override this! + // Arguments: renderer, drawingContext, calcMatrix, displayList, displayListIndex + } + +}); + +module.exports = Extern; + + +/***/ }, + +/***/ 70217 +() { + + + +/***/ }, + +/***/ 56315 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Extern = __webpack_require__(42421); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Extern Game Object and adds it to the Scene's display list. + * + * An Extern is a special type of Game Object that allows you to integrate custom rendering + * logic directly into Phaser's render pipeline. By adding an Extern to the display list, + * you can inject your own WebGL or Canvas draw calls at a specific point in the rendering + * order, without Phaser interfering with the renderer state. This is useful when you need + * to use a third-party renderer, perform custom GPU operations, or render content that + * Phaser does not natively support, while still having it composited correctly with other + * Game Objects in your Scene. + * + * Note: This method will only be available if the Extern Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#extern + * @since 3.16.0 + * + * @return {Phaser.GameObjects.Extern} The Extern Game Object that was created and added to the display list. + */ +GameObjectFactory.register('extern', function () +{ + var extern = new Extern(this.scene); + + this.displayList.add(extern); + + return extern; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 64993 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(80287); +} + +if (true) +{ + renderCanvas = __webpack_require__(70217); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 80287 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Extern#renderWebGL + * @since 3.16.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Extern} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + * @param {number} renderStep - The render step index. + * @param {Phaser.GameObjects.GameObject[]} displayList - The display list which is currently being rendered. + * @param {number} displayListIndex - The index of the Game Object within the display list. + */ +var ExternWebGLRenderer = function (renderer, src, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) +{ + renderer.renderNodes.getNode('YieldContext').run(drawingContext); + + var calcMatrix = GetCalcMatrix(src, drawingContext.camera, parentMatrix, !drawingContext.useCanvas).calc; + + src.render.call(src, renderer, drawingContext, calcMatrix, displayList, displayListIndex); + + renderer.renderNodes.getNode('RebindContext').run(drawingContext); +}; + +module.exports = ExternWebGLRenderer; + + +/***/ }, + +/***/ 34637 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var ColorRamp = __webpack_require__(73043); +var Vector2 = __webpack_require__(26099); +var GradientFrag = __webpack_require__(41509); +var RampGlsl = __webpack_require__(68589); +var Class = __webpack_require__(83419); +var Shader = __webpack_require__(20071); + +/** + * @classdesc + * A Gradient Game Object. + * + * This Game Object is a quad which displays a gradient. + * You can manipulate this object like any other, make it interactive, + * and use it in filters and masks to create visually stunning effects. + * + * Behind the scenes, a Gradient is a {@link Phaser.GameObjects.Shader} using a specific shader program. + * + * The gradient color is determined by a {@link Phaser.Display.ColorRamp}, + * containing one or more {@link Phaser.Display.ColorBand} objects. + * The ramp is laid out along the `shape` of the gradient, + * originating from the `start` location. + * The `shapeMode` describes how the gradient fills elsewhere, + * e.g. a LINEAR gradient creates straight bands + * while a RADIAL gradient creates circles. + * + * Note that the shape of the gradient is fitted to a square. + * If its width and height are not equal, the shape will be distorted. + * This may be what you want. + * + * A Gradient can be animated by modifying its `offset` property, + * or by modifying the ramp data. If you modify ramp data, + * you may have to call `gradient.ramp.encode()` to rebuild it. + * + * @example + * // Create a linear gradient going left to right. + * scene.add.gradient(undefined, 100, 100, 200, 200); + * + * // Create a glowing halo. + * var halo = scene.add.gradient({ + * bands: [ + * { + * start: 0.5, + * end: 0.6, + * colorStart: [ 0.5, 0.5, 1, 0 ], + * colorEnd: 0xffffff, + * colorSpace: 1, + * interpolation: 4, + * }, + * { + * start: 0.6, + * end: 1, + * colorStart: 0xffffff, + * colorEnd: [ 1, 0.5, 0.5, 0 ], + * colorSpace: 1, + * interpolation: 3, + * }, + * ], + * dither: true, + * repeatMode: 1, + * shapeMode: 2, + * start: { x: 0.5, y: 0.5 }, + * shape: { x: 0.5, y: 0.0 }, + * }, 400, 300, 800, 800); + * + * // Animate the halo, given a `time` value in seconds: + * halo.offset = 0.1 * (1 + Math.sin(time/1000)); + * + * @class Gradient + * @extends Phaser.GameObjects.Shader + * @memberof Phaser.GameObjects + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Types.GameObjects.Gradient.GradientQuadConfig} [config] - The configuration for this Game Object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + */ +var Gradient = new Class({ + Extends: Shader, + + initialize: function Gradient (scene, config, x, y, width, height) + { + if (!config) { config = {}; } + + var shaderConfig = { + name: 'gradient', + fragmentSource: GradientFrag, + shaderAdditions: [ + { + name: 'RAMP_0', + tags: 'RAMP', + additions: { + fragmentHeader: RampGlsl + } + } + ], + initialUniforms: { + uRampTexture: 0 + }, + setupUniforms: this._setupUniforms, + updateShaderConfig: this._updateShaderConfig + }; + + Shader.call(this, scene, shaderConfig, x, y, width, height); + + this.type = 'Gradient'; + + /** + * The ramp which contains the color data for the gradient. + * + * By default, this is a linear progression from black to white. + * You can encode much more complex gradients with the ColorRamp. + * + * @name Phaser.GameObjects.Gradient#ramp + * @type {Phaser.Display.ColorRamp} + * @since 4.0.0 + */ + this.ramp = new ColorRamp(this.scene, config.bands || { + colorStart: 0x000000, + colorEnd: 0xffffff + }); + + /** + * Move the start of the gradient. + * You can animate gradients in this way. + * + * Note that the offset effect changes based on shape and repeat mode. + * Conic gradients may appear weird! + * + * Animate the offset from -1 to 1 using mode 1 (TRUNCATE) + * to create a one-time shockwave. + * + * Use mode 2 (SAWTOOTH) or 3 (TRIANGULAR) to create a moving pattern. + * + * @name Phaser.GameObjects.Gradient#offset + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.offset = config.offset || 0; + + /** + * The repeat mode of the gradient. + * Gradient progress is evaluated as a number, + * where 0 is the start of the `shape` vector and 1 is the end. + * Repeat mode tells us how to handle that number below 0/above 1. + * + * This can be one of the following: + * + * - 0 (EXTEND): values are clamped between 0 and 1, + * so the ends of the gradient become flat color. + * - 1 (TRUNCATE): values are discarded outside 0-1, + * so the ends of the gradient become transparent. + * - 2 (SAWTOOTH): values are modulo 1, + * so the gradient repeats. + * - 3 (TRIANGULAR): values rise to 1 then fall to 0, + * so the gradient goes smoothly back and forth. + * + * Note that conic gradients never leave the range 0-1 + * unless offset is applied. They may look weird if you do. + * + * @name Phaser.GameObjects.Gradient#repeatMode + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.repeatMode = config.repeatMode || 0; + + /** + * The shape mode of the gradient. + * Shapes are based on the `shape` vector. + * + * This can be one of the following: + * + * - 0 (LINEAR): a ribbon where the shape points from one side to the other. + * Commonly used for skies etc. + * - 1 (BILINEAR): like LINEAR, but reflected in both directions. + * Useful for gentle waves, reflections etc. + * - 2 (RADIAL): gradient spreads out from the `start`, + * to the radius described by `shape`. + * Useful for glows, ripples etc. + * - 3 (CONIC_SYMMETRIC): gradient is determined by angle to `shape`, + * going from 0 along the shape vector to 1 opposite it. + * Useful for sharp-looking features or light effects. + * - 4 (CONIC_ASYMMETRIC): gradient is determined by angle to `shape`, + * going from 0 to 1 with a full rotation. This creates a seam. + * Good for creating colors that change with angle, + * like speed meters. + * + * @name Phaser.GameObjects.Gradient#shapeMode + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.shapeMode = config.shapeMode || 0; + + /** + * The start location of the gradient within its quad. + * The gradient emanates from this point. + * Gradient color starts here and ends at the tip of the `shape` vector. + * + * @name Phaser.GameObjects.Gradient#start + * @type {Phaser.Types.Math.Vector2Like} + * @since 4.0.0 + */ + this.start = new Vector2(0, 0); + if (config.start) + { + this.start.copy(config.start); + } + + /** + * The shape vector of the gradient within its quad. + * This points from the start in the direction that the gradient flows. + * Gradient color starts from the `start` vector and ends at the tip of this. + * + * @name Phaser.GameObjects.Gradient#shape + * @type {Phaser.Types.Math.Vector2Like} + * @since 4.0.0 + */ + this.shape = new Vector2(1, 0); + if (config.shape) + { + this.shape.copy(config.shape); + } + else + { + var length = config.length === undefined ? 1 : config.length; + var direction = config.direction || 0; + this.shape.setTo(length * Math.cos(direction), length * Math.sin(direction)); + } + + /** + * Whether to dither the gradient. + * This helps to eliminate banding by adding a tiny amount of noise + * to the gradient. + * Dither may lose effectiveness if resized, so you should only enable + * it when it will make a difference. + * + * @name Phaser.GameObjects.Gradient#dither + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.dither = !!config.dither; + + this.setTextures([ this.ramp.dataTexture ]); + }, + + /** + * The function which sets uniforms for the shader. + * This is provided to the Shader base class as `setupUniforms`. + * You should not override `setupUniforms` on a Gradient. + * + * @method Phaser.GameObjects.Gradient#_setupUniforms + * @private + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + _setupUniforms: function (setUniform, drawingContext) + { + setUniform('uRampResolution', this.ramp.dataTextureResolution); + setUniform('uRampBandStart', this.ramp.dataTextureFirstBand); + setUniform('uOffset', this.offset); + setUniform('uRepeatMode', this.repeatMode); + setUniform('uShapeMode', this.shapeMode); + setUniform('uStart', [ this.start.x, 1 - this.start.y ]); + setUniform('uShape', [ this.shape.x, -this.shape.y ]); + setUniform('uDither', this.dither); + }, + + /** + * The function which updates shader configuration. + * This is provided to the Shader base class as `updateShaderConfig`. + * You should not override `updateShaderConfig` on a Gradient. + * + * @method Phaser.GameObjects.Gradient#_updateShaderConfig + * @private + * @since 4.0.0 + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + * @param {Phaser.GameObjects.Gradient} gameObject - The game object which is rendering. + * @param {Phaser.Renderer.WebGL.RenderNodes.ShaderQuad} renderNode - The render node currently rendering. + */ + _updateShaderConfig: function (drawingContext, gameObject, renderNode) + { + var depth = gameObject.ramp.bandTreeDepth; + + var bandTreeDepth = renderNode.programManager.getAdditionsByTag('RAMP')[0]; + bandTreeDepth.name = 'RAMP_' + depth; + bandTreeDepth.additions.fragmentHeader = RampGlsl.replace( + '#define BAND_TREE_DEPTH 0.0', + '#define BAND_TREE_DEPTH ' + depth + '.0' + ); + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Gradient#preDestroy + * @protected + * @since 4.0.0 + */ + preDestroy: function () + { + this.ramp.destroy(); + + Shader.prototype.preDestroy.call(this); + } +}); + +module.exports = Gradient; + + +/***/ }, + +/***/ 26353 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Gradient = __webpack_require__(34637); + +/** + * Creates a new Gradient Game Object and returns it. A Gradient is a rectangular + * Game Object that renders a smooth color gradient across its surface using WebGL. + * It is useful for backgrounds, overlays, and decorative visual effects where a + * multi-color fill is needed without a texture. Position, size, and gradient + * appearance are all configured via the `config` object. + * + * Note: This method will only be available if the Gradient Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#gradient + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.Gradient.GradientConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Gradient} The Game Object that was created. + */ +GameObjectCreator.register('gradient', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var gradient = new Gradient(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, gradient, config); + + return gradient; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 69315 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Gradient = __webpack_require__(34637); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Gradient Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Gradient Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#gradient + * @webglOnly + * @since 4.0.0 + * + * @param {(string|Phaser.Types.GameObjects.Gradient.GradientQuadConfig)} [config] - The configuration object this Gradient will use. This defines the shape and appearance of the gradient texture. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * + * @return {Phaser.GameObjects.Gradient} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('gradient', function (config, x, y, width, height) + { + return this.displayList.add(new Gradient(this.scene, config, x, y, width, height)); + }); +} + + +/***/ }, + +/***/ 85592 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +module.exports = { + + ARC: 0, + BEGIN_PATH: 1, + CLOSE_PATH: 2, + FILL_RECT: 3, + LINE_TO: 4, + MOVE_TO: 5, + LINE_STYLE: 6, + FILL_STYLE: 7, + FILL_PATH: 8, + STROKE_PATH: 9, + FILL_TRIANGLE: 10, + STROKE_TRIANGLE: 11, + SAVE: 14, + RESTORE: 15, + TRANSLATE: 16, + SCALE: 17, + ROTATE: 18, + GRADIENT_FILL_STYLE: 21, + GRADIENT_LINE_STYLE: 22 + +}; + + +/***/ }, + +/***/ 43831 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BaseCamera = __webpack_require__(71911); +var Class = __webpack_require__(83419); +var Commands = __webpack_require__(85592); +var Components = __webpack_require__(31401); +var Ellipse = __webpack_require__(8497); +var GameObject = __webpack_require__(95643); +var DefaultGraphicsNodes = __webpack_require__(87891); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var MATH_CONST = __webpack_require__(36383); +var Render = __webpack_require__(84503); + +/** + * @classdesc + * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as + * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics + * object it will be empty. + * + * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally + * fill or stroke them. For example: + * + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.beginPath(); + * graphics.moveTo(100, 100); + * graphics.lineTo(200, 200); + * graphics.closePath(); + * graphics.strokePath(); + * ``` + * + * There are also many helpful methods that draw and fill/stroke common shapes for you. + * + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.fillStyle(0xFFFFFF, 1.0); + * graphics.fillRect(50, 50, 400, 200); + * graphics.strokeRect(50, 50, 400, 200); + * ``` + * + * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL. + * Under Canvas it will use the HTML Canvas context drawing operations to draw the path. + * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with + * complex shapes. + * + * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help + * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into + * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object + * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume + * memory. + * + * Under WebGL, Graphics uses its own shader which will batch drawing operations. + * Try to keep Graphics objects grouped together so they can be batched together. + * Avoid mixing object types where possible, as each batch will be flushed, + * costing performance. + * + * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful + * in their complexity and quantity of them in your game. + * + * @class Graphics + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Graphics object belongs. + * @param {Phaser.Types.GameObjects.Graphics.Options} [options] - Options that set the position and default style of this Graphics object. + */ +var Graphics = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.Lighting, + Components.Mask, + Components.RenderNodes, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + Render + ], + + initialize: + + function Graphics (scene, options) + { + var x = GetValue(options, 'x', 0); + var y = GetValue(options, 'y', 0); + + GameObject.call(this, scene, 'Graphics'); + + this.setPosition(x, y); + this.initRenderNodes(this._defaultRenderNodesMap); + + /** + * The horizontal display origin of the Graphics. + * + * @name Phaser.GameObjects.Graphics#displayOriginX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginX = 0; + + /** + * The vertical display origin of the Graphics. + * + * @name Phaser.GameObjects.Graphics#displayOriginY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginY = 0; + + /** + * The array of commands used to render the Graphics. + * + * @name Phaser.GameObjects.Graphics#commandBuffer + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.commandBuffer = []; + + /** + * The default fill color for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. + * + * @name Phaser.GameObjects.Graphics#defaultFillColor + * @type {number} + * @readonly + * @default -1 + * @since 3.0.0 + */ + this.defaultFillColor = -1; + + /** + * The default fill alpha for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. + * + * @name Phaser.GameObjects.Graphics#defaultFillAlpha + * @type {number} + * @readonly + * @default 1 + * @since 3.0.0 + */ + this.defaultFillAlpha = 1; + + /** + * The default stroke width for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. + * + * @name Phaser.GameObjects.Graphics#defaultStrokeWidth + * @type {number} + * @readonly + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeWidth = 1; + + /** + * The default stroke color for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. + * + * @name Phaser.GameObjects.Graphics#defaultStrokeColor + * @type {number} + * @readonly + * @default -1 + * @since 3.0.0 + */ + this.defaultStrokeColor = -1; + + /** + * The default stroke alpha for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. + * + * @name Phaser.GameObjects.Graphics#defaultStrokeAlpha + * @type {number} + * @readonly + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeAlpha = 1; + + /** + * Internal property that keeps track of the line width style setting. + * + * @name Phaser.GameObjects.Graphics#_lineWidth + * @type {number} + * @private + * @since 3.0.0 + */ + this._lineWidth = 1; + + /** + * Path detail threshold for the WebGL renderer, in pixels. + * Path segments will be combined until the path is complete + * or the segment length is above the threshold. + * + * If the value is negative, the threshold will be taken from the + * game config `render.pathDetailThreshold` property. + * + * This threshold can greatly improve performance on complex shapes. + * It is calculated at render time and does not affect the original + * path data. + * The threshold is evaluated in screen pixels, so if the object is + * scaled up, fine detail will emerge. + * + * @name Phaser.GameObjects.Graphics#pathDetailThreshold + * @type {number} + * @default -1 + * @since 4.0.0 + */ + this.pathDetailThreshold = -1; + + this.lineStyle(1, 0, 0); + this.fillStyle(0, 0); + + this.setDefaultStyles(options); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Graphics#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultGraphicsNodes; + } + }, + + /** + * Set the default style settings for this Graphics object. + * + * @method Phaser.GameObjects.Graphics#setDefaultStyles + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Graphics.Styles} options - The styles to set as defaults. + * + * @return {this} This Game Object. + */ + setDefaultStyles: function (options) + { + if (GetValue(options, 'lineStyle', null)) + { + this.defaultStrokeWidth = GetValue(options, 'lineStyle.width', 1); + this.defaultStrokeColor = GetValue(options, 'lineStyle.color', 0xffffff); + this.defaultStrokeAlpha = GetValue(options, 'lineStyle.alpha', 1); + + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + if (GetValue(options, 'fillStyle', null)) + { + this.defaultFillColor = GetValue(options, 'fillStyle.color', 0xffffff); + this.defaultFillAlpha = GetValue(options, 'fillStyle.alpha', 1); + + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + return this; + }, + + /** + * Set the current line style. Used for all 'stroke' related functions. + * + * @method Phaser.GameObjects.Graphics#lineStyle + * @since 3.0.0 + * + * @param {number} lineWidth - The stroke width. + * @param {number} color - The stroke color. + * @param {number} [alpha=1] - The stroke alpha. + * + * @return {this} This Game Object. + */ + lineStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.LINE_STYLE, + lineWidth, color, alpha + ); + + this._lineWidth = lineWidth; + + return this; + }, + + /** + * Set the current fill style. Used for all 'fill' related functions. + * + * @method Phaser.GameObjects.Graphics#fillStyle + * @since 3.0.0 + * + * @param {number} color - The fill color. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {this} This Game Object. + */ + fillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.FILL_STYLE, + color, alpha + ); + + return this; + }, + + /** + * Sets a gradient fill style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#fillGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {number} topLeft - The top left fill color. + * @param {number} topRight - The top right fill color. + * @param {number} bottomLeft - The bottom left fill color. + * @param {number} bottomRight - The bottom right fill color. Not used when filling triangles. + * @param {number} [alphaTopLeft=1] - The top left alpha value. If you give only this value, it's used for all corners. + * @param {number} [alphaTopRight=1] - The top right alpha value. + * @param {number} [alphaBottomLeft=1] - The bottom left alpha value. + * @param {number} [alphaBottomRight=1] - The bottom right alpha value. + * + * @return {this} This Game Object. + */ + fillGradientStyle: function (topLeft, topRight, bottomLeft, bottomRight, alphaTopLeft, alphaTopRight, alphaBottomLeft, alphaBottomRight) + { + if (alphaTopLeft === undefined) { alphaTopLeft = 1; } + if (alphaTopRight === undefined) { alphaTopRight = alphaTopLeft; } + if (alphaBottomLeft === undefined) { alphaBottomLeft = alphaTopLeft; } + if (alphaBottomRight === undefined) { alphaBottomRight = alphaTopLeft; } + + this.commandBuffer.push( + Commands.GRADIENT_FILL_STYLE, + alphaTopLeft, alphaTopRight, alphaBottomLeft, alphaBottomRight, + topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets a gradient line style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * + * This feature is best used only on single lines. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#lineGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {number} lineWidth - The stroke width. + * @param {number} topLeft - The stroke color for the top-left of the gradient. + * @param {number} topRight - The stroke color for the top-right of the gradient. + * @param {number} bottomLeft - The stroke color for the bottom-left of the gradient. + * @param {number} bottomRight - The stroke color for the bottom-right of the gradient. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {this} This Game Object. + */ + lineGradientStyle: function (lineWidth, topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_LINE_STYLE, + lineWidth, alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Start a new shape path. + * + * @method Phaser.GameObjects.Graphics#beginPath + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + beginPath: function () + { + this.commandBuffer.push( + Commands.BEGIN_PATH + ); + + return this; + }, + + /** + * Close the current path. + * + * @method Phaser.GameObjects.Graphics#closePath + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + closePath: function () + { + this.commandBuffer.push( + Commands.CLOSE_PATH + ); + + return this; + }, + + /** + * Fill the current path. + * + * @method Phaser.GameObjects.Graphics#fillPath + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + fillPath: function () + { + this.commandBuffer.push( + Commands.FILL_PATH + ); + + return this; + }, + + /** + * Fill the current path. + * + * This is an alias for `Graphics.fillPath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + * + * @method Phaser.GameObjects.Graphics#fill + * @since 3.16.0 + * + * @return {this} This Game Object. + */ + fill: function () + { + this.commandBuffer.push( + Commands.FILL_PATH + ); + + return this; + }, + + /** + * Stroke the current path. + * + * @method Phaser.GameObjects.Graphics#strokePath + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + strokePath: function () + { + this.commandBuffer.push( + Commands.STROKE_PATH + ); + + return this; + }, + + /** + * Stroke the current path. + * + * This is an alias for `Graphics.strokePath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + * + * @method Phaser.GameObjects.Graphics#stroke + * @since 3.16.0 + * + * @return {this} This Game Object. + */ + stroke: function () + { + this.commandBuffer.push( + Commands.STROKE_PATH + ); + + return this; + }, + + /** + * Fill the given circle. + * + * @method Phaser.GameObjects.Graphics#fillCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The circle to fill. + * + * @return {this} This Game Object. + */ + fillCircleShape: function (circle) + { + return this.fillCircle(circle.x, circle.y, circle.radius); + }, + + /** + * Stroke the given circle. + * + * @method Phaser.GameObjects.Graphics#strokeCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The circle to stroke. + * + * @return {this} This Game Object. + */ + strokeCircleShape: function (circle) + { + return this.strokeCircle(circle.x, circle.y, circle.radius); + }, + + /** + * Fill a circle with the given position and radius. + * + * @method Phaser.GameObjects.Graphics#fillCircle + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} radius - The radius of the circle. + * + * @return {this} This Game Object. + */ + fillCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.TAU); + this.fillPath(); + + return this; + }, + + /** + * Stroke a circle with the given position and radius. + * + * @method Phaser.GameObjects.Graphics#strokeCircle + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} radius - The radius of the circle. + * + * @return {this} This Game Object. + */ + strokeCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.TAU); + this.strokePath(); + + return this; + }, + + /** + * Fill the given rectangle. + * + * @method Phaser.GameObjects.Graphics#fillRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The rectangle to fill. + * + * @return {this} This Game Object. + */ + fillRectShape: function (rect) + { + return this.fillRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * Stroke the given rectangle. + * + * @method Phaser.GameObjects.Graphics#strokeRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The rectangle to stroke. + * + * @return {this} This Game Object. + */ + strokeRectShape: function (rect) + { + return this.strokeRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * Fill a rectangle with the given position and size. + * + * @method Phaser.GameObjects.Graphics#fillRect + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * + * @return {this} This Game Object. + */ + fillRect: function (x, y, width, height) + { + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, width, height + ); + + return this; + }, + + /** + * Stroke a rectangle with the given position and size. + * + * @method Phaser.GameObjects.Graphics#strokeRect + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * + * @return {this} This Game Object. + */ + strokeRect: function (x, y, width, height) + { + var lineWidthHalf = this._lineWidth / 2; + var minx = x - lineWidthHalf; + var maxx = x + lineWidthHalf; + + this.beginPath(); + this.moveTo(x, y); + this.lineTo(x, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(x + width, y); + this.lineTo(x + width, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y); + this.lineTo(maxx + width, y); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y + height); + this.lineTo(maxx + width, y + height); + this.strokePath(); + + return this; + }, + + /** + * Fill a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#fillRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {(Phaser.Types.GameObjects.Graphics.RoundedRectRadius|number)} [radius=20] - The corner radius; It can also be an object to specify different radius for corners. + * + * @return {this} This Game Object. + */ + fillRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + var convexTL = (tl >= 0); + var convexTR = (tr >= 0); + var convexBL = (bl >= 0); + var convexBR = (br >= 0); + + tl = Math.abs(tl); + tr = Math.abs(tr); + bl = Math.abs(bl); + br = Math.abs(br); + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + + if (convexTR) + { + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.PI_OVER_2, 0); + } + else + { + this.arc(x + width, y, tr, Math.PI, MATH_CONST.PI_OVER_2, true); + } + + this.lineTo(x + width, y + height - br); + + if (convexBR) + { + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.PI_OVER_2); + } + else + { + this.arc(x + width, y + height, br, -MATH_CONST.PI_OVER_2, Math.PI, true); + } + + this.lineTo(x + bl, y + height); + + if (convexBL) + { + this.arc(x + bl, y + height - bl, bl, MATH_CONST.PI_OVER_2, Math.PI); + } + else + { + this.arc(x, y + height, bl, 0, -MATH_CONST.PI_OVER_2, true); + } + + this.lineTo(x, y + tl); + + if (convexTL) + { + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.PI_OVER_2); + } + else + { + this.arc(x, y, tl, MATH_CONST.PI_OVER_2, 0, true); + } + + this.fillPath(); + + return this; + }, + + /** + * Stroke a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#strokeRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {(Phaser.Types.GameObjects.Graphics.RoundedRectRadius|number)} [radius=20] - The corner radius; It can also be an object to specify different radii for corners. + * + * @return {this} This Game Object. + */ + strokeRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + var maxRadius = Math.min(width, height) / 2; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + var convexTL = (tl >= 0); + var convexTR = (tr >= 0); + var convexBL = (bl >= 0); + var convexBR = (br >= 0); + + tl = Math.min(Math.abs(tl), maxRadius); + tr = Math.min(Math.abs(tr), maxRadius); + bl = Math.min(Math.abs(bl), maxRadius); + br = Math.min(Math.abs(br), maxRadius); + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + this.moveTo(x + width - tr, y); + + if (convexTR) + { + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.PI_OVER_2, 0); + } + else + { + this.arc(x + width, y, tr, Math.PI, MATH_CONST.PI_OVER_2, true); + } + + this.lineTo(x + width, y + height - br); + this.moveTo(x + width, y + height - br); + + if (convexBR) + { + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.PI_OVER_2); + } + else + { + this.arc(x + width, y + height, br, -MATH_CONST.PI_OVER_2, Math.PI, true); + } + + this.lineTo(x + bl, y + height); + this.moveTo(x + bl, y + height); + + if (convexBL) + { + this.arc(x + bl, y + height - bl, bl, MATH_CONST.PI_OVER_2, Math.PI); + } + else + { + this.arc(x, y + height, bl, 0, -MATH_CONST.PI_OVER_2, true); + } + + this.lineTo(x, y + tl); + this.moveTo(x, y + tl); + + if (convexTL) + { + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.PI_OVER_2); + } + else + { + this.arc(x, y, tl, MATH_CONST.PI_OVER_2, 0, true); + } + + this.strokePath(); + + return this; + }, + + /** + * Fill the given point. + * + * Draws a square at the given position, 1 pixel in size by default. + * + * @method Phaser.GameObjects.Graphics#fillPointShape + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} point - The point to fill. + * @param {number} [size=1] - The size of the square to draw. + * + * @return {this} This Game Object. + */ + fillPointShape: function (point, size) + { + return this.fillPoint(point.x, point.y, size); + }, + + /** + * Fill a point at the given position. + * + * Draws a square at the given position, 1 pixel in size by default. + * + * @method Phaser.GameObjects.Graphics#fillPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point. + * @param {number} y - The y coordinate of the point. + * @param {number} [size=1] - The size of the square to draw. + * + * @return {this} This Game Object. + */ + fillPoint: function (x, y, size) + { + if (!size || size < 1) + { + size = 1; + } + else + { + x -= (size / 2); + y -= (size / 2); + } + + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, size, size + ); + + return this; + }, + + /** + * Fill the given triangle. + * + * @method Phaser.GameObjects.Graphics#fillTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to fill. + * + * @return {this} This Game Object. + */ + fillTriangleShape: function (triangle) + { + return this.fillTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * Stroke the given triangle. + * + * @method Phaser.GameObjects.Graphics#strokeTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to stroke. + * + * @return {this} This Game Object. + */ + strokeTriangleShape: function (triangle) + { + return this.strokeTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * Fill a triangle with the given points. + * + * @method Phaser.GameObjects.Graphics#fillTriangle + * @since 3.0.0 + * + * @param {number} x0 - The x coordinate of the first point. + * @param {number} y0 - The y coordinate of the first point. + * @param {number} x1 - The x coordinate of the second point. + * @param {number} y1 - The y coordinate of the second point. + * @param {number} x2 - The x coordinate of the third point. + * @param {number} y2 - The y coordinate of the third point. + * + * @return {this} This Game Object. + */ + fillTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.FILL_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * Stroke a triangle with the given points. + * + * @method Phaser.GameObjects.Graphics#strokeTriangle + * @since 3.0.0 + * + * @param {number} x0 - The x coordinate of the first point. + * @param {number} y0 - The y coordinate of the first point. + * @param {number} x1 - The x coordinate of the second point. + * @param {number} y1 - The y coordinate of the second point. + * @param {number} x2 - The x coordinate of the third point. + * @param {number} y2 - The y coordinate of the third point. + * + * @return {this} This Game Object. + */ + strokeTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.STROKE_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * Draw the given line. + * + * @method Phaser.GameObjects.Graphics#strokeLineShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to stroke. + * + * @return {this} This Game Object. + */ + strokeLineShape: function (line) + { + return this.lineBetween(line.x1, line.y1, line.x2, line.y2); + }, + + /** + * Draw a line between the given points. + * + * @method Phaser.GameObjects.Graphics#lineBetween + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the start point of the line. + * @param {number} y1 - The y coordinate of the start point of the line. + * @param {number} x2 - The x coordinate of the end point of the line. + * @param {number} y2 - The y coordinate of the end point of the line. + * + * @return {this} This Game Object. + */ + lineBetween: function (x1, y1, x2, y2) + { + this.beginPath(); + this.moveTo(x1, y1); + this.lineTo(x2, y2); + this.strokePath(); + + return this; + }, + + /** + * Draw a line from the current drawing position to the given position. + * + * Moves the current drawing position to the given position. + * + * @method Phaser.GameObjects.Graphics#lineTo + * @since 3.0.0 + * + * @param {number} x - The x coordinate to draw the line to. + * @param {number} y - The y coordinate to draw the line to. + * + * @return {this} This Game Object. + */ + lineTo: function (x, y) + { + this.commandBuffer.push( + Commands.LINE_TO, + x, y + ); + + return this; + }, + + /** + * Move the current drawing position to the given position. + * + * @method Phaser.GameObjects.Graphics#moveTo + * @since 3.0.0 + * + * @param {number} x - The x coordinate to move to. + * @param {number} y - The y coordinate to move to. + * + * @return {this} This Game Object. + */ + moveTo: function (x, y) + { + this.commandBuffer.push( + Commands.MOVE_TO, + x, y + ); + + return this; + }, + + /** + * Stroke the shape represented by the given array of points. + * + * Pass `closeShape` to automatically close the shape by joining the last to the first point. + * + * Pass `closePath` to automatically close the path before it is stroked. + * + * @method Phaser.GameObjects.Graphics#strokePoints + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - The points to stroke. + * @param {boolean} [closeShape=false] - When `true`, the shape is closed by joining the last point to the first point. + * @param {boolean} [closePath=false] - When `true`, the path is closed before being stroked. + * @param {number} [endIndex] - The index of `points` to stop drawing at. Defaults to `points.length`. + * + * @return {this} This Game Object. + */ + strokePoints: function (points, closeShape, closePath, endIndex) + { + if (closeShape === undefined) { closeShape = false; } + if (closePath === undefined) { closePath = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (closeShape) + { + this.lineTo(points[0].x, points[0].y); + } + + if (closePath) + { + this.closePath(); + } + + this.strokePath(); + + return this; + }, + + /** + * Fill the shape represented by the given array of points. + * + * Pass `closeShape` to automatically close the shape by joining the last to the first point. + * + * Pass `closePath` to automatically close the path before it is filled. + * + * @method Phaser.GameObjects.Graphics#fillPoints + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - The points to fill. + * @param {boolean} [closeShape=false] - When `true`, the shape is closed by joining the last point to the first point. + * @param {boolean} [closePath=false] - When `true`, the path is closed before being filled. + * @param {number} [endIndex] - The index of `points` to stop at. Defaults to `points.length`. + * + * @return {this} This Game Object. + */ + fillPoints: function (points, closeShape, closePath, endIndex) + { + if (closeShape === undefined) { closeShape = false; } + if (closePath === undefined) { closePath = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (closeShape) + { + this.lineTo(points[0].x, points[0].y); + } + + if (closePath) + { + this.closePath(); + } + + this.fillPath(); + + return this; + }, + + /** + * Stroke the given ellipse. + * + * @method Phaser.GameObjects.Graphics#strokeEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The ellipse to stroke. + * @param {number} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {this} This Game Object. + */ + strokeEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * Stroke an ellipse with the given position and size. + * + * @method Phaser.GameObjects.Graphics#strokeEllipse + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the ellipse. + * @param {number} y - The y coordinate of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {number} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {this} This Game Object. + */ + strokeEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * Fill the given ellipse. + * + * @method Phaser.GameObjects.Graphics#fillEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The ellipse to fill. + * @param {number} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {this} This Game Object. + */ + fillEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * Fill an ellipse with the given position and size. + * + * @method Phaser.GameObjects.Graphics#fillEllipse + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the ellipse. + * @param {number} y - The y coordinate of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {number} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {this} This Game Object. + */ + fillEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * Draw an arc. + * + * This method can be used to create circles, or parts of circles. + * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. + * + * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling + * this method to draw the arc. + * + * @method Phaser.GameObjects.Graphics#arc + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} radius - The radius of the circle. + * @param {number} startAngle - The starting angle, in radians. + * @param {number} endAngle - The ending angle, in radians. + * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. + * + * @return {this} This Game Object. + */ + arc: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) + { + if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } + + this.commandBuffer.push( + Commands.ARC, + x, y, radius, startAngle, endAngle, anticlockwise, overshoot + ); + + return this; + }, + + /** + * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. + * You must define the start and end angle of the slice. + * + * Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman. + * Setting it to `false` creates a shape like a slice of pie. + * + * This method will begin a new path and close the path at the end of it. + * To display the actual slice you need to call either `strokePath` or `fillPath` after it. + * + * @method Phaser.GameObjects.Graphics#slice + * @since 3.4.0 + * + * @param {number} x - The horizontal center of the slice. + * @param {number} y - The vertical center of the slice. + * @param {number} radius - The radius of the slice. + * @param {number} startAngle - The start angle of the slice, given in radians. + * @param {number} endAngle - The end angle of the slice, given in radians. + * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. + * + * @return {this} This Game Object. + */ + slice: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) + { + if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } + + this.commandBuffer.push(Commands.BEGIN_PATH); + + this.commandBuffer.push(Commands.MOVE_TO, x, y); + + this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise, overshoot); + + this.commandBuffer.push(Commands.CLOSE_PATH); + + return this; + }, + + /** + * Saves the state of the Graphics by pushing the current state onto a stack. + * + * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. + * + * @method Phaser.GameObjects.Graphics#save + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + save: function () + { + this.commandBuffer.push( + Commands.SAVE + ); + + return this; + }, + + /** + * Restores the most recently saved state of the Graphics by popping from the state stack. + * + * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * + * If there is no saved state, this command does nothing. + * + * @method Phaser.GameObjects.Graphics#restore + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + restore: function () + { + this.commandBuffer.push( + Commands.RESTORE + ); + + return this; + }, + + /** + * Inserts a translation command into this Graphics objects command buffer. + * + * All objects drawn _after_ calling this method will be translated + * by the given amount. + * + * This does not change the position of the Graphics object itself, + * only of the objects drawn by it after calling this method. + * + * @method Phaser.GameObjects.Graphics#translateCanvas + * @since 3.0.0 + * + * @param {number} x - The horizontal translation to apply. + * @param {number} y - The vertical translation to apply. + * + * @return {this} This Game Object. + */ + translateCanvas: function (x, y) + { + this.commandBuffer.push( + Commands.TRANSLATE, + x, y + ); + + return this; + }, + + /** + * Inserts a scale command into this Graphics objects command buffer. + * + * All objects drawn _after_ calling this method will be scaled + * by the given amount. + * + * This does not change the scale of the Graphics object itself, + * only of the objects drawn by it after calling this method. + * + * @method Phaser.GameObjects.Graphics#scaleCanvas + * @since 3.0.0 + * + * @param {number} x - The horizontal scale to apply. + * @param {number} y - The vertical scale to apply. + * + * @return {this} This Game Object. + */ + scaleCanvas: function (x, y) + { + this.commandBuffer.push( + Commands.SCALE, + x, y + ); + + return this; + }, + + /** + * Inserts a rotation command into this Graphics objects command buffer. + * + * All objects drawn _after_ calling this method will be rotated + * by the given amount. + * + * This does not change the rotation of the Graphics object itself, + * only of the objects drawn by it after calling this method. + * + * @method Phaser.GameObjects.Graphics#rotateCanvas + * @since 3.0.0 + * + * @param {number} radians - The rotation angle, in radians. + * + * @return {this} This Game Object. + */ + rotateCanvas: function (radians) + { + this.commandBuffer.push( + Commands.ROTATE, + radians + ); + + return this; + }, + + /** + * Clear the command buffer and reset the fill style and line style to their defaults. + * + * @method Phaser.GameObjects.Graphics#clear + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + clear: function () + { + this.commandBuffer.length = 0; + + if (this.defaultFillColor > -1) + { + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + if (this.defaultStrokeColor > -1) + { + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + return this; + }, + + /** + * Generate a texture from this Graphics object. + * + * If `key` is a string it'll generate a new texture using it and add it into the + * Texture Manager (assuming no key conflict happens). + * + * If `key` is a Canvas it will draw the Graphics to that canvas context. Note that it will NOT + * automatically upload it to the GPU in WebGL mode. + * + * Please understand that the texture is created via the Canvas API of the browser, therefore some + * Graphics features, such as `fillGradientStyle`, will not appear on the resulting texture, + * as they're unsupported by the Canvas API. + * + * @method Phaser.GameObjects.Graphics#generateTexture + * @since 3.0.0 + * + * @param {(string|HTMLCanvasElement)} key - The key to store the texture with in the Texture Manager, or a Canvas to draw to. + * @param {number} [width] - The width of the graphics to generate. + * @param {number} [height] - The height of the graphics to generate. + * + * @return {this} This Game Object. + */ + generateTexture: function (key, width, height) + { + var sys = this.scene.sys; + var renderer = sys.game.renderer; + + if (width === undefined) { width = sys.scale.width; } + if (height === undefined) { height = sys.scale.height; } + + Graphics.TargetCamera.setScene(this.scene); + Graphics.TargetCamera.setViewport(0, 0, width, height); + Graphics.TargetCamera.scrollX = this.x; + Graphics.TargetCamera.scrollY = this.y; + + var texture; + var ctx; + var willRead = { willReadFrequently: true }; + + if (typeof key === 'string') + { + if (sys.textures.exists(key)) + { + // Key is a string, it DOES exist in the Texture Manager AND is a canvas, so draw to it + + texture = sys.textures.get(key); + + var src = texture.getSourceImage(); + + if (src instanceof HTMLCanvasElement) + { + ctx = src.getContext('2d', willRead); + } + } + else + { + // Key is a string and doesn't exist in the Texture Manager, so generate and save it + + texture = sys.textures.createCanvas(key, width, height); + + ctx = texture.getSourceImage().getContext('2d', willRead); + } + } + else if (key instanceof HTMLCanvasElement) + { + // Key is a Canvas, so draw to it + + ctx = key.getContext('2d', willRead); + } + + if (ctx) + { + // var GraphicsCanvasRenderer = function (renderer, src, camera, parentMatrix, renderTargetCtx, allowClip) + this.renderCanvas(renderer, this, Graphics.TargetCamera, null, ctx, false); + + if (texture) + { + texture.refresh(); + } + } + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Graphics#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.commandBuffer = []; + } + +}); + +/** + * A Camera used specifically by the Graphics system for rendering to textures. + * + * @name Phaser.GameObjects.Graphics.TargetCamera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.1.0 + */ +Graphics.TargetCamera = new BaseCamera(); + +module.exports = Graphics; + + +/***/ }, + +/***/ 32768 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Commands = __webpack_require__(85592); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Graphics#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + * @param {CanvasRenderingContext2D} [renderTargetCtx] - The target rendering context. + * @param {boolean} allowClip - If `true` then path operations will be used instead of fill operations. + */ +var GraphicsCanvasRenderer = function (renderer, src, camera, parentMatrix, renderTargetCtx, allowClip) +{ + var commandBuffer = src.commandBuffer; + var commandBufferLength = commandBuffer.length; + + var ctx = renderTargetCtx || renderer.currentContext; + + if (commandBufferLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + camera.addToRenderList(src); + + var lineAlpha = 1; + var fillAlpha = 1; + var lineColor = 0; + var fillColor = 0; + var lineWidth = 1; + var red = 0; + var green = 0; + var blue = 0; + + // Reset any currently active paths + ctx.beginPath(); + + for (var index = 0; index < commandBufferLength; ++index) + { + var commandID = commandBuffer[index]; + + switch (commandID) + { + case Commands.ARC: + ctx.arc( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4], + commandBuffer[index + 5], + commandBuffer[index + 6] + ); + + // +7 because overshoot is the 7th value, not used in Canvas + index += 7; + break; + + case Commands.LINE_STYLE: + lineWidth = commandBuffer[index + 1]; + lineColor = commandBuffer[index + 2]; + lineAlpha = commandBuffer[index + 3]; + red = ((lineColor & 0xFF0000) >>> 16); + green = ((lineColor & 0xFF00) >>> 8); + blue = (lineColor & 0xFF); + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + lineAlpha + ')'; + ctx.lineWidth = lineWidth; + index += 3; + break; + + case Commands.FILL_STYLE: + fillColor = commandBuffer[index + 1]; + fillAlpha = commandBuffer[index + 2]; + red = ((fillColor & 0xFF0000) >>> 16); + green = ((fillColor & 0xFF00) >>> 8); + blue = (fillColor & 0xFF); + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; + index += 2; + break; + + case Commands.BEGIN_PATH: + ctx.beginPath(); + break; + + case Commands.CLOSE_PATH: + ctx.closePath(); + break; + + case Commands.FILL_PATH: + if (!allowClip) + { + ctx.fill(); + } + break; + + case Commands.STROKE_PATH: + if (!allowClip) + { + ctx.stroke(); + } + break; + + case Commands.FILL_RECT: + if (!allowClip) + { + ctx.fillRect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + else + { + ctx.rect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + index += 4; + break; + + case Commands.FILL_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.fill(); + } + index += 6; + break; + + case Commands.STROKE_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.stroke(); + } + index += 6; + break; + + case Commands.LINE_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.MOVE_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.LINE_FX_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.MOVE_FX_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.SAVE: + ctx.save(); + break; + + case Commands.RESTORE: + ctx.restore(); + break; + + case Commands.TRANSLATE: + ctx.translate( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.SCALE: + ctx.scale( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.ROTATE: + ctx.rotate( + commandBuffer[index + 1] + ); + index += 1; + break; + + case Commands.GRADIENT_FILL_STYLE: + index += 5; + break; + + case Commands.GRADIENT_LINE_STYLE: + index += 6; + break; + } + } + + // Restore the context saved in SetTransform + ctx.restore(); +}; + +module.exports = GraphicsCanvasRenderer; + + +/***/ }, + +/***/ 87079 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectCreator = __webpack_require__(44603); +var Graphics = __webpack_require__(43831); + +/** + * Creates a new Graphics Game Object and returns it. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#graphics + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Graphics.Options} [config] - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectCreator.register('graphics', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + var graphics = new Graphics(this.scene, config); + + if (config.add) + { + this.scene.sys.displayList.add(graphics); + } + + return graphics; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 1201 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Graphics = __webpack_require__(43831); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Graphics Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#graphics + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Graphics.Options} [config] - The Graphics configuration. + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectFactory.register('graphics', function (config) +{ + return this.displayList.add(new Graphics(this.scene, config)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 84503 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(77545); + + // Needed for Graphics.generateTexture + renderCanvas = __webpack_require__(32768); +} + +if (true) +{ + renderCanvas = __webpack_require__(32768); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 77545 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Commands = __webpack_require__(85592); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); +var TransformMatrix = __webpack_require__(61340); + +var Point = function (x, y, width) +{ + this.x = x; + this.y = y; + this.width = width; +}; + +var Path = function (x, y, width) +{ + this.points = []; + this.points[0] = new Point(x, y, width); + + this.addPoint = function (x, y, width) + { + var point = this.points[this.points.length - 1]; + + if (point.x === x && point.y === y) + { + return; + } + + this.points.push(new Point(x, y, width)); + }; +}; + +var matrixStack = []; +var tempMatrix = new TransformMatrix(); +var renderMatrix = new TransformMatrix(); +var fillTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; +var strokeTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; +var trianglePath = [ + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 } +]; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Graphics#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GraphicsWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + if (src.commandBuffer.length === 0) + { + return; + } + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + var submitterNode = customRenderNodes.Submitter || defaultRenderNodes.Submitter; + var lighting = src.lighting; + + var currentContext = drawingContext; + + var camera = currentContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var currentMatrix = tempMatrix.loadIdentity(); + + var commands = src.commandBuffer; + var alpha = src.alpha; + + var pathDetailThreshold = Math.max( + src.pathDetailThreshold, + renderer.config.pathDetailThreshold, + 0 + ); + + var lineWidth = 1; + + var tx = 0; + var ty = 0; + var ta = 0; + var iterStep = 0.01; + var PI2 = Math.PI * 2; + + var cmd; + + var path = []; + var pathIndex = 0; + var pathOpen = true; + var lastPath = null; + + var getTint = Utils.getTintAppendFloatAlpha; + + for (var cmdIndex = 0; cmdIndex < commands.length; cmdIndex++) + { + cmd = commands[cmdIndex]; + + switch (cmd) + { + case Commands.BEGIN_PATH: + { + path.length = 0; + lastPath = null; + pathOpen = true; + break; + } + + case Commands.CLOSE_PATH: + { + pathOpen = false; + + if (lastPath && lastPath.points.length) + { + lastPath.points.push(lastPath.points[0]); + } + break; + } + + case Commands.FILL_PATH: + { + calcMatrix.multiply(currentMatrix, renderMatrix); + + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + (customRenderNodes.FillPath || defaultRenderNodes.FillPath).run( + currentContext, + renderMatrix, + submitterNode, + path[pathIndex].points, + fillTint.TL, + fillTint.TR, + fillTint.BL, + pathDetailThreshold, + lighting + ); + } + break; + } + + case Commands.STROKE_PATH: + { + calcMatrix.multiply(currentMatrix, renderMatrix); + + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + (customRenderNodes.StrokePath || defaultRenderNodes.StrokePath).run( + currentContext, + submitterNode, + path[pathIndex].points, + lineWidth, + pathOpen, + renderMatrix, + strokeTint.TL, + strokeTint.TR, + strokeTint.BL, + strokeTint.BR, + pathDetailThreshold, + lighting + ); + } + break; + } + + case Commands.LINE_STYLE: + { + lineWidth = commands[++cmdIndex]; + var strokeColor = commands[++cmdIndex]; + var strokeAlpha = commands[++cmdIndex] * alpha; + var strokeTintColor = getTint(strokeColor, strokeAlpha); + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + break; + } + + case Commands.FILL_STYLE: + { + var fillColor = commands[++cmdIndex]; + var fillAlpha = commands[++cmdIndex] * alpha; + var fillTintColor = getTint(fillColor, fillAlpha); + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + break; + } + + case Commands.GRADIENT_FILL_STYLE: + { + var alphaTL = commands[++cmdIndex] * alpha; + var alphaTR = commands[++cmdIndex] * alpha; + var alphaBL = commands[++cmdIndex] * alpha; + var alphaBR = commands[++cmdIndex] * alpha; + + fillTint.TL = getTint(commands[++cmdIndex], alphaTL); + fillTint.TR = getTint(commands[++cmdIndex], alphaTR); + fillTint.BL = getTint(commands[++cmdIndex], alphaBL); + fillTint.BR = getTint(commands[++cmdIndex], alphaBR); + break; + } + + case Commands.GRADIENT_LINE_STYLE: + { + lineWidth = commands[++cmdIndex]; + var gradientLineAlpha = commands[++cmdIndex] * alpha; + strokeTint.TL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.TR = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BR = getTint(commands[++cmdIndex], gradientLineAlpha); + break; + } + + case Commands.ARC: + { + var iteration = 0; + var x = commands[++cmdIndex]; + var y = commands[++cmdIndex]; + var radius = commands[++cmdIndex]; + var startAngle = commands[++cmdIndex]; + var endAngle = commands[++cmdIndex]; + var anticlockwise = commands[++cmdIndex]; + var overshoot = commands[++cmdIndex]; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -PI2) + { + endAngle = -PI2; + } + else if (endAngle > 0) + { + endAngle = -PI2 + endAngle % PI2; + } + } + else if (endAngle > PI2) + { + endAngle = PI2; + } + else if (endAngle < 0) + { + endAngle = PI2 + endAngle % PI2; + } + + if (lastPath === null) + { + lastPath = new Path(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius, lineWidth); + path.push(lastPath); + iteration += iterStep; + } + + while (iteration < 1 + overshoot) + { + ta = endAngle * iteration + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.addPoint(tx, ty, lineWidth); + + iteration += iterStep; + } + + ta = endAngle + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.addPoint(tx, ty, lineWidth); + + break; + } + + case Commands.FILL_RECT: + { + calcMatrix.multiply(currentMatrix, renderMatrix); + + (customRenderNodes.FillRect || defaultRenderNodes.FillRect).run( + currentContext, + renderMatrix, + submitterNode, + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + fillTint.TL, + fillTint.TR, + fillTint.BL, + fillTint.BR, + lighting + ); + + break; + } + + case Commands.FILL_TRIANGLE: + { + calcMatrix.multiply(currentMatrix, renderMatrix); + + (customRenderNodes.FillTri || defaultRenderNodes.FillTri).run( + currentContext, + renderMatrix, + submitterNode, + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + fillTint.TL, + fillTint.TR, + fillTint.BL, + lighting + ); + + break; + } + + case Commands.STROKE_TRIANGLE: + { + calcMatrix.multiply(currentMatrix, renderMatrix); + + trianglePath[0].x = commands[++cmdIndex]; + trianglePath[0].y = commands[++cmdIndex]; + trianglePath[0].width = lineWidth; + + trianglePath[1].x = commands[++cmdIndex]; + trianglePath[1].y = commands[++cmdIndex]; + trianglePath[1].width = lineWidth; + + trianglePath[2].x = commands[++cmdIndex]; + trianglePath[2].y = commands[++cmdIndex]; + trianglePath[2].width = lineWidth; + + trianglePath[3].x = trianglePath[0].x; + trianglePath[3].y = trianglePath[0].y; + trianglePath[3].width = lineWidth; + + (customRenderNodes.StrokePath || defaultRenderNodes.StrokePath).run( + currentContext, + submitterNode, + trianglePath, + lineWidth, + false, + renderMatrix, + strokeTint.TL, + strokeTint.TR, + strokeTint.BL, + strokeTint.BR, + lighting + ); + break; + } + + case Commands.LINE_TO: + { + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + + if (lastPath !== null) + { + lastPath.addPoint(x, y, lineWidth); + } + else + { + lastPath = new Path(x, y, lineWidth); + path.push(lastPath); + } + break; + } + + case Commands.MOVE_TO: + { + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + break; + } + + case Commands.SAVE: + { + matrixStack.push(currentMatrix.copyToArray()); + break; + } + + case Commands.RESTORE: + { + currentMatrix.copyFromArray(matrixStack.pop()); + break; + } + + case Commands.TRANSLATE: + { + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.translate(x, y); + break; + } + + case Commands.SCALE: + { + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.scale(x, y); + break; + } + + case Commands.ROTATE: + { + currentMatrix.rotate(commands[++cmdIndex]); + break; + } + } + } +}; + +module.exports = GraphicsWebGLRenderer; + + +/***/ }, + +/***/ 26479 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Actions = __webpack_require__(61061); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(51708); +var EventEmitter = __webpack_require__(50792); +var GetAll = __webpack_require__(46710); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var HasValue = __webpack_require__(97022); +var IsPlainObject = __webpack_require__(41212); +var Range = __webpack_require__(88492); +var Sprite = __webpack_require__(68287); + +/** + * @classdesc + * A Group is a way for you to create, manipulate, or recycle similar Game Objects. + * + * Groups are commonly used to implement object pools, where a fixed set of Game Objects + * are created up front and then recycled by toggling their `active` and `visible` states, + * avoiding the overhead of repeated construction and garbage collection. This pattern is + * especially useful for frequently spawned objects such as bullets, particles, or enemies. + * + * Group membership is non-exclusive. A Game Object can belong to several groups, one group, or none. + * + * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. + * + * @class Group + * @memberof Phaser.GameObjects + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|Phaser.Types.GameObjects.Group.GroupConfig|Phaser.Types.GameObjects.Group.GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {Phaser.Types.GameObjects.Group.GroupConfig|Phaser.Types.GameObjects.Group.GroupCreateConfig} [config] - Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings. + * + * @see Phaser.Physics.Arcade.Group + * @see Phaser.Physics.Arcade.StaticGroup + */ +var Group = new Class({ + + Extends: EventEmitter, + + initialize: + + function Group (scene, children, config) + { + EventEmitter.call(this); + + // They can pass in any of the following as the first argument: + + // 1) A single child + // 2) An array of children + // 3) A config object + // 4) An array of config objects + + // Or they can pass in a child, or array of children AND a config object + + if (config) + { + // config has been set, are the children an array? + + if (children && !Array.isArray(children)) + { + children = [ children ]; + } + } + else if (Array.isArray(children)) + { + // No config, so let's check the children argument + + if (IsPlainObject(children[0])) + { + // It's an array of plain config objects + config = children; + children = null; + } + } + else if (IsPlainObject(children)) + { + // Children isn't an array. Is it a config object though? + config = children; + children = null; + } + + /** + * This scene this group belongs to. + * + * @name Phaser.GameObjects.Group#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Members of this group. + * + * @name Phaser.GameObjects.Group#children + * @type {Set.} + * @since 3.0.0 + */ + this.children = new Set(); + + /** + * A flag identifying this object as a group. + * + * @name Phaser.GameObjects.Group#isParent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isParent = true; + + /** + * A textual representation of this Game Object. + * Used internally by Phaser but is available for your own custom classes to populate. + * + * @name Phaser.GameObjects.Group#type + * @type {string} + * @default 'Group' + * @since 3.21.0 + */ + this.type = 'Group'; + + /** + * The class to create new group members from. + * + * The constructor arguments must match `(scene, x, y, texture, frame)`. + * + * @name Phaser.GameObjects.Group#classType + * @type {function} + * @since 3.0.0 + * @default Phaser.GameObjects.Sprite + * @see Phaser.Types.GameObjects.Group.GroupClassTypeConstructor + */ + this.classType = GetFastValue(config, 'classType', Sprite); + + /** + * The name of this group. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.Group#name + * @type {string} + * @default '' + * @since 3.18.0 + */ + this.name = GetFastValue(config, 'name', ''); + + /** + * Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method (which may update any members). + * + * @name Phaser.GameObjects.Group#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = GetFastValue(config, 'active', true); + + /** + * The maximum size of this group, if used as a pool. -1 is no limit. + * + * @name Phaser.GameObjects.Group#maxSize + * @type {number} + * @since 3.0.0 + * @default -1 + */ + this.maxSize = GetFastValue(config, 'maxSize', -1); + + /** + * A default texture key to use when creating new group members. + * + * This is used in {@link Phaser.GameObjects.Group#create} + * but not in {@link Phaser.GameObjects.Group#createMultiple}. + * + * @name Phaser.GameObjects.Group#defaultKey + * @type {string} + * @since 3.0.0 + */ + this.defaultKey = GetFastValue(config, 'defaultKey', null); + + /** + * A default texture frame to use when creating new group members. + * + * @name Phaser.GameObjects.Group#defaultFrame + * @type {(string|number)} + * @since 3.0.0 + */ + this.defaultFrame = GetFastValue(config, 'defaultFrame', null); + + /** + * Whether to call the update method of any members. + * + * @name Phaser.GameObjects.Group#runChildUpdate + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Group#preUpdate + */ + this.runChildUpdate = GetFastValue(config, 'runChildUpdate', false); + + /** + * A function to be called when adding or creating group members. + * + * @name Phaser.GameObjects.Group#createCallback + * @type {?Phaser.Types.GameObjects.Group.GroupCallback} + * @since 3.0.0 + */ + this.createCallback = GetFastValue(config, 'createCallback', null); + + /** + * A function to be called when removing group members. + * + * @name Phaser.GameObjects.Group#removeCallback + * @type {?Phaser.Types.GameObjects.Group.GroupCallback} + * @since 3.0.0 + */ + this.removeCallback = GetFastValue(config, 'removeCallback', null); + + /** + * A function to be called when creating several group members at once. + * + * @name Phaser.GameObjects.Group#createMultipleCallback + * @type {?Phaser.Types.GameObjects.Group.GroupMultipleCreateCallback} + * @since 3.0.0 + */ + this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null); + + /** + * A function to be called when adding or creating group members. + * For internal use only by a Group, or any class that extends it. + * + * @name Phaser.GameObjects.Group#internalCreateCallback + * @type {?Phaser.Types.GameObjects.Group.GroupCallback} + * @private + * @since 3.22.0 + */ + this.internalCreateCallback = GetFastValue(config, 'internalCreateCallback', null); + + /** + * A function to be called when removing group members. + * For internal use only by a Group, or any class that extends it. + * + * @name Phaser.GameObjects.Group#internalRemoveCallback + * @type {?Phaser.Types.GameObjects.Group.GroupCallback} + * @private + * @since 3.22.0 + */ + this.internalRemoveCallback = GetFastValue(config, 'internalRemoveCallback', null); + + if (children) + { + this.addMultiple(children); + } + + if (config) + { + this.createMultiple(config); + } + + this.on(Events.ADDED_TO_SCENE, this.addedToScene, this); + this.on(Events.REMOVED_FROM_SCENE, this.removedFromScene, this); + }, + + /** + * Called when this Group is added to a Scene. Registers this Group with the Scene's update list + * so that its `preUpdate` method is called each game step. + * + * @method Phaser.GameObjects.Group#addedToScene + * @since 3.0.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Called when this Group is removed from a Scene. Unregisters this Group from the Scene's + * update list so that its `preUpdate` method is no longer called each game step. + * + * @method Phaser.GameObjects.Group#removedFromScene + * @since 3.0.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * Creates a new Game Object and adds it to this group, unless the group {@link Phaser.GameObjects.Group#isFull is full}. + * + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * + * @method Phaser.GameObjects.Group#create + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal position of the new Game Object in the world. + * @param {number} [y=0] - The vertical position of the new Game Object in the world. + * @param {string} [key=defaultKey] - The texture key of the new Game Object. + * @param {(string|number)} [frame=defaultFrame] - The texture frame of the new Game Object. + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object. + * @param {boolean} [active=true] - The {@link Phaser.GameObjects.GameObject#active} state of the new Game Object. + * + * @return {any} The new Game Object (usually a Sprite, etc.). + */ + create: function (x, y, key, frame, visible, active) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (key === undefined) { key = this.defaultKey; } + if (frame === undefined) { frame = this.defaultFrame; } + if (visible === undefined) { visible = true; } + if (active === undefined) { active = true; } + + // Pool? + if (this.isFull()) + { + return null; + } + + var child = new this.classType(this.scene, x, y, key, frame); + + child.addToDisplayList(this.scene.sys.displayList); + child.addToUpdateList(); + + child.visible = visible; + child.setActive(active); + + this.add(child); + + return child; + }, + + /** + * Creates several Game Objects and adds them to this group. + * + * If the group becomes {@link Phaser.GameObjects.Group#isFull}, no further Game Objects are created. + * + * Calls {@link Phaser.GameObjects.Group#createMultipleCallback} and {@link Phaser.GameObjects.Group#createCallback}. + * + * @method Phaser.GameObjects.Group#createMultiple + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Group.GroupCreateConfig|Phaser.Types.GameObjects.Group.GroupCreateConfig[]} config - Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn. + * + * @return {any[]} The newly created Game Objects. + */ + createMultiple: function (config) + { + if (this.isFull()) + { + return []; + } + + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var output = []; + + if (config[0].key) + { + for (var i = 0; i < config.length; i++) + { + var entries = this.createFromConfig(config[i]); + + output = output.concat(entries); + } + } + + return output; + }, + + /** + * A helper for {@link Phaser.GameObjects.Group#createMultiple}. + * + * @method Phaser.GameObjects.Group#createFromConfig + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Group.GroupCreateConfig} options - Creation settings. + * + * @return {any[]} The newly created Game Objects. + */ + createFromConfig: function (options) + { + if (this.isFull()) + { + return []; + } + + this.classType = GetFastValue(options, 'classType', this.classType); + + var key = GetFastValue(options, 'key', undefined); + var frame = GetFastValue(options, 'frame', null); + var visible = GetFastValue(options, 'visible', true); + var active = GetFastValue(options, 'active', true); + + var entries = []; + + // Can't do anything without at least a key + if (key === undefined) + { + return entries; + } + else + { + if (!Array.isArray(key)) + { + key = [ key ]; + } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + } + + // Build an array of key frame pairs to loop through + + var repeat = GetFastValue(options, 'repeat', 0); + var randomKey = GetFastValue(options, 'randomKey', false); + var randomFrame = GetFastValue(options, 'randomFrame', false); + var yoyo = GetFastValue(options, 'yoyo', false); + var quantity = GetFastValue(options, 'quantity', false); + var frameQuantity = GetFastValue(options, 'frameQuantity', 1); + var max = GetFastValue(options, 'max', 0); + + // If a quantity value is set we use that to override the frameQuantity + + var range = Range(key, frame, { + max: max, + qty: (quantity) ? quantity : frameQuantity, + random: randomKey, + randomB: randomFrame, + repeat: repeat, + yoyo: yoyo + }); + + if (options.createCallback) + { + this.createCallback = options.createCallback; + } + + if (options.removeCallback) + { + this.removeCallback = options.removeCallback; + } + + if (options.internalCreateCallback) + { + this.internalCreateCallback = options.internalCreateCallback; + } + + if (options.internalRemoveCallback) + { + this.internalRemoveCallback = options.internalRemoveCallback; + } + + for (var c = 0; c < range.length; c++) + { + var created = this.create(0, 0, range[c].a, range[c].b, visible, active); + + if (!created) + { + break; + } + + entries.push(created); + } + + // Post-creation options (applied only to those items created in this call): + + if (HasValue(options, 'setXY')) + { + var x = GetValue(options, 'setXY.x', 0); + var y = GetValue(options, 'setXY.y', 0); + var stepX = GetValue(options, 'setXY.stepX', 0); + var stepY = GetValue(options, 'setXY.stepY', 0); + + Actions.SetXY(entries, x, y, stepX, stepY); + } + + if (HasValue(options, 'setRotation')) + { + var rotation = GetValue(options, 'setRotation.value', 0); + var stepRotation = GetValue(options, 'setRotation.step', 0); + + Actions.SetRotation(entries, rotation, stepRotation); + } + + if (HasValue(options, 'setScale')) + { + var scaleX = GetValue(options, 'setScale.x', 1); + var scaleY = GetValue(options, 'setScale.y', scaleX); + var stepScaleX = GetValue(options, 'setScale.stepX', 0); + var stepScaleY = GetValue(options, 'setScale.stepY', 0); + + Actions.SetScale(entries, scaleX, scaleY, stepScaleX, stepScaleY); + } + + if (HasValue(options, 'setOrigin')) + { + var originX = GetValue(options, 'setOrigin.x', 0.5); + var originY = GetValue(options, 'setOrigin.y', originX); + var stepOriginX = GetValue(options, 'setOrigin.stepX', 0); + var stepOriginY = GetValue(options, 'setOrigin.stepY', 0); + + Actions.SetOrigin(entries, originX, originY, stepOriginX, stepOriginY); + } + + if (HasValue(options, 'setAlpha')) + { + var alpha = GetValue(options, 'setAlpha.value', 1); + var stepAlpha = GetValue(options, 'setAlpha.step', 0); + + Actions.SetAlpha(entries, alpha, stepAlpha); + } + + if (HasValue(options, 'setDepth')) + { + var depth = GetValue(options, 'setDepth.value', 0); + var stepDepth = GetValue(options, 'setDepth.step', 0); + + Actions.SetDepth(entries, depth, stepDepth); + } + + if (HasValue(options, 'setScrollFactor')) + { + var scrollFactorX = GetValue(options, 'setScrollFactor.x', 1); + var scrollFactorY = GetValue(options, 'setScrollFactor.y', scrollFactorX); + var stepScrollFactorX = GetValue(options, 'setScrollFactor.stepX', 0); + var stepScrollFactorY = GetValue(options, 'setScrollFactor.stepY', 0); + + Actions.SetScrollFactor(entries, scrollFactorX, scrollFactorY, stepScrollFactorX, stepScrollFactorY); + } + + var hitArea = GetFastValue(options, 'hitArea', null); + var hitAreaCallback = GetFastValue(options, 'hitAreaCallback', null); + + if (hitArea) + { + Actions.SetHitArea(entries, hitArea, hitAreaCallback); + } + + var grid = GetFastValue(options, 'gridAlign', false); + + if (grid) + { + Actions.GridAlign(entries, grid); + } + + if (this.createMultipleCallback) + { + this.createMultipleCallback.call(this, entries); + } + + return entries; + }, + + /** + * Updates any group members, if {@link Phaser.GameObjects.Group#runChildUpdate} is enabled. + * + * @method Phaser.GameObjects.Group#preUpdate + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + if (!this.runChildUpdate || this.children.size === 0) + { + return; + } + + this.children.forEach(function (child) + { + if (child.active) + { + child.update(time, delta); + } + }); + }, + + /** + * Adds a Game Object to this group. + * + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * + * @method Phaser.GameObjects.Group#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. + * @param {boolean} [addToScene=false] - Also add the Game Object to the scene. + * + * @return {this} This Group object. + */ + add: function (child, addToScene) + { + if (addToScene === undefined) { addToScene = false; } + + if (this.isFull()) + { + return this; + } + + this.children.add(child); + + if (this.internalCreateCallback) + { + this.internalCreateCallback.call(this, child); + } + + if (this.createCallback) + { + this.createCallback.call(this, child); + } + + if (addToScene) + { + child.addToDisplayList(this.scene.sys.displayList); + child.addToUpdateList(); + } + + child.on(Events.DESTROY, this.remove, this); + + return this; + }, + + /** + * Adds several Game Objects to this group. + * + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * + * @method Phaser.GameObjects.Group#addMultiple + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} children - The Game Objects to add. + * @param {boolean} [addToScene=false] - Also add the Game Objects to the scene. + * + * @return {this} This group. + */ + addMultiple: function (children, addToScene) + { + if (addToScene === undefined) { addToScene = false; } + + if (Array.isArray(children)) + { + for (var i = 0; i < children.length; i++) + { + this.add(children[i], addToScene); + } + } + + return this; + }, + + /** + * Removes a member of this Group and optionally removes it from the Scene and / or destroys it. + * + * Calls {@link Phaser.GameObjects.Group#removeCallback}. + * + * @method Phaser.GameObjects.Group#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove. + * @param {boolean} [removeFromScene=false] - Optionally remove the Group member from the Scene it belongs to. + * @param {boolean} [destroyChild=false] - Optionally call destroy on the removed Group member. + * + * @return {this} This Group object. + */ + remove: function (child, removeFromScene, destroyChild) + { + if (removeFromScene === undefined) { removeFromScene = false; } + if (destroyChild === undefined) { destroyChild = false; } + + if (!this.children.has(child)) + { + return this; + } + + this.children.delete(child); + + if (this.internalRemoveCallback) + { + this.internalRemoveCallback.call(this, child); + } + + if (this.removeCallback) + { + this.removeCallback.call(this, child); + } + + child.off(Events.DESTROY, this.remove, this); + + if (destroyChild) + { + child.destroy(); + } + else if (removeFromScene) + { + child.removeFromDisplayList(); + child.removeFromUpdateList(); + } + + return this; + }, + + /** + * Removes all members of this Group and optionally removes them from the Scene and / or destroys them. + * + * Does not call {@link Phaser.GameObjects.Group#removeCallback}. + * + * @method Phaser.GameObjects.Group#clear + * @since 3.0.0 + * + * @param {boolean} [removeFromScene=false] - Optionally remove each Group member from the Scene. + * @param {boolean} [destroyChild=false] - Optionally call destroy on the removed Group members. + * + * @return {this} This group. + */ + clear: function (removeFromScene, destroyChild) + { + if (removeFromScene === undefined) { removeFromScene = false; } + if (destroyChild === undefined) { destroyChild = false; } + + var children = this.children; + + children.forEach(function (gameObject) + { + gameObject.off(Events.DESTROY, this.remove, this); + + if (destroyChild) + { + gameObject.destroy(); + } + else if (removeFromScene) + { + gameObject.removeFromDisplayList(); + gameObject.removeFromUpdateList(); + } + }, this); + + children.clear(); + + return this; + }, + + /** + * Tests if a Game Object is a member of this group. + * + * @method Phaser.GameObjects.Group#contains + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - A Game Object. + * + * @return {boolean} True if the Game Object is a member of this group. + */ + contains: function (child) + { + return this.children.has(child); + }, + + /** + * All members of the group. + * + * @method Phaser.GameObjects.Group#getChildren + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject[]} The group members. + */ + getChildren: function () + { + return Array.from(this.children); + }, + + /** + * The number of members of the group. + * + * @method Phaser.GameObjects.Group#getLength + * @since 3.0.0 + * + * @return {number} The total number of members in this Group. + */ + getLength: function () + { + return this.children.size; + }, + + /** + * Returns all children in this Group that match the given criteria based on the `property` and `value` arguments. + * + * For example: `getMatching('visible', true)` would return only children that have their `visible` property set. + * + * Optionally, you can specify a start and end index. For example if the Group has 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50. + * + * @method Phaser.GameObjects.Group#getMatching + * @since 3.50.0 + * + * @param {string} [property] - The property to test on each array element. + * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {number} [startIndex] - An optional start index to search from. + * @param {number} [endIndex] - An optional end index to search to. + * + * @return {any[]} An array of matching Group members. The array will be empty if nothing matched. + */ + getMatching: function (property, value, startIndex, endIndex) + { + return GetAll(Array.from(this.children), property, value, startIndex, endIndex); + }, + + /** + * Scans the Group, from top to bottom, for the first member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#getFirst + * @since 3.0.0 + * + * @param {boolean} [state=false] - The {@link Phaser.GameObjects.GameObject#active} value to match. + * @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments. + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {?any} The first matching group member, or a newly created member, or null. + */ + getFirst: function (state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(true, 1, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the Group, from top to bottom, for the nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#getFirstNth + * @since 3.6.0 + * + * @param {number} nth - The nth matching Group member to search for. + * @param {boolean} [state=false] - The {@link Phaser.GameObjects.GameObject#active} value to match. + * @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments. + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {?any} The nth matching group member, or a newly created member, or null. + */ + getFirstNth: function (nth, state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(true, nth, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the Group for the last member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#getLast + * @since 3.6.0 + * + * @param {boolean} [state=false] - The {@link Phaser.GameObjects.GameObject#active} value to match. + * @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments. + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {?any} The last matching group member, or a newly created member, or null. + */ + getLast: function (state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(false, 1, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the Group for the last nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#getLastNth + * @since 3.6.0 + * + * @param {number} nth - The nth matching Group member to search for. + * @param {boolean} [state=false] - The {@link Phaser.GameObjects.GameObject#active} value to match. + * @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments. + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {?any} The nth matching group member (searching from the end), or a newly created member, or null. + */ + getLastNth: function (nth, state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(false, nth, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the group for the last member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#getHandler + * @private + * @since 3.6.0 + * + * @param {boolean} forwards - Search front to back or back to front? + * @param {number} nth - Stop matching after nth successful matches. + * @param {boolean} [state=false] - The {@link Phaser.GameObjects.GameObject#active} value to match. + * @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments. + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {?any} The first matching group member, or a newly created member, or null. + */ + getHandler: function (forwards, nth, state, createIfNull, x, y, key, frame, visible) + { + if (state === undefined) { state = false; } + if (createIfNull === undefined) { createIfNull = false; } + + var gameObject; + + var i; + var total = 0; + var children = Array.from(this.children); + + if (forwards) + { + for (i = 0; i < children.length; i++) + { + gameObject = children[i]; + + if (gameObject.active === state) + { + total++; + + if (total === nth) + { + break; + } + } + else + { + gameObject = null; + } + } + } + else + { + for (i = children.length - 1; i >= 0; i--) + { + gameObject = children[i]; + + if (gameObject.active === state) + { + total++; + + if (total === nth) + { + break; + } + } + else + { + gameObject = null; + } + } + } + + if (gameObject) + { + if (typeof(x) === 'number') + { + gameObject.x = x; + } + + if (typeof(y) === 'number') + { + gameObject.y = y; + } + + return gameObject; + } + + // Got this far? We need to create or bail + if (createIfNull) + { + return this.create(x, y, key, frame, visible); + } + else + { + return null; + } + }, + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, + * assigns `x` and `y`, and returns the member. + * + * If no inactive member is found and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * The new Game Object will have its active state set to `true`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#get + * @since 3.0.0 + * + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {?any} The first inactive group member, or a newly created member, or null. + */ + get: function (x, y, key, frame, visible) + { + return this.getFirst(false, true, x, y, key, frame, visible); + }, + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `true`, + * assigns `x` and `y`, and returns the member. + * + * If no active member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#getFirstAlive + * @since 3.0.0 + * + * @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments. + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {any} The first active group member, or a newly created member, or null. + */ + getFirstAlive: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(true, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, + * assigns `x` and `y`, and returns the member. + * + * If no inactive member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. + * The new Game Object will have an active state set to `true`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * + * @method Phaser.GameObjects.Group#getFirstDead + * @since 3.0.0 + * + * @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments. + * @param {number} [x] - The horizontal position of the Game Object in the world. + * @param {number} [y] - The vertical position of the Game Object in the world. + * @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created). + * @param {(string|number)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created). + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). + * + * @return {any} The first inactive group member, or a newly created member, or null. + */ + getFirstDead: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(false, createIfNull, x, y, key, frame, visible); + }, + + /** + * {@link Phaser.Animations.AnimationState#play Plays} an animation for all members of this group. + * + * @method Phaser.GameObjects.Group#playAnimation + * @since 3.0.0 + * + * @param {string} key - The string-based key of the animation to play. + * @param {string} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {this} This Group object. + */ + playAnimation: function (key, startFrame) + { + Actions.PlayAnimation(Array.from(this.children), key, startFrame); + + return this; + }, + + /** + * Whether this group's size is at its {@link Phaser.GameObjects.Group#maxSize maximum}. + * + * @method Phaser.GameObjects.Group#isFull + * @since 3.0.0 + * + * @return {boolean} True if the number of members equals {@link Phaser.GameObjects.Group#maxSize}. + */ + isFull: function () + { + if (this.maxSize === -1) + { + return false; + } + else + { + return (this.children.size >= this.maxSize); + } + }, + + /** + * Counts the number of active (or inactive) group members. + * + * @method Phaser.GameObjects.Group#countActive + * @since 3.0.0 + * + * @param {boolean} [value=true] - Count active (true) or inactive (false) group members. + * + * @return {number} The number of group members with an active state matching the `active` argument. + */ + countActive: function (value) + { + if (value === undefined) { value = true; } + + var total = 0; + + this.children.forEach(function (child) + { + if (child.active === value) + { + total++; + } + }); + + return total; + }, + + /** + * Counts the number of in-use (active) group members. + * + * @method Phaser.GameObjects.Group#getTotalUsed + * @since 3.0.0 + * + * @return {number} The number of group members with an active state of true. + */ + getTotalUsed: function () + { + return this.countActive(); + }, + + /** + * The difference of {@link Phaser.GameObjects.Group#maxSize} and the number of active group members. + * + * This represents the number of group members that could be created or reactivated before reaching the size limit. + * + * @method Phaser.GameObjects.Group#getTotalFree + * @since 3.0.0 + * + * @return {number} maxSize minus the number of active group members; or a large number (if maxSize is -1). + */ + getTotalFree: function () + { + var used = this.getTotalUsed(); + var capacity = (this.maxSize === -1) ? 999999999999 : this.maxSize; + + return (capacity - used); + }, + + /** + * Sets the `active` property of this Group. + * When active, this Group runs its `preUpdate` method. + * + * @method Phaser.GameObjects.Group#setActive + * @since 3.24.0 + * + * @param {boolean} value - True if this Group should be set as active, false if not. + * + * @return {this} This Group object. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Sets the `name` property of this Group. + * The `name` property is not populated by Phaser and is presented for your own use. + * + * @method Phaser.GameObjects.Group#setName + * @since 3.24.0 + * + * @param {string} value - The name to be given to this Group. + * + * @return {this} This Group object. + */ + setName: function (value) + { + this.name = value; + + return this; + }, + + /** + * Sets the property as defined in `key` of each group member to the given value. + * + * @method Phaser.GameObjects.Group#propertyValueSet + * @since 3.21.0 + * + * @param {string} key - The property to be updated. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {this} This Group object. + */ + propertyValueSet: function (key, value, step, index, direction) + { + Actions.PropertyValueSet(Array.from(this.children), key, value, step, index, direction); + + return this; + }, + + /** + * Adds the given value to the property as defined in `key` of each group member. + * + * @method Phaser.GameObjects.Group#propertyValueInc + * @since 3.21.0 + * + * @param {string} key - The property to be updated. + * @param {number} value - The amount to add to the property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {this} This Group object. + */ + propertyValueInc: function (key, value, step, index, direction) + { + Actions.PropertyValueInc(Array.from(this.children), key, value, step, index, direction); + + return this; + }, + + /** + * Sets the x of each group member. + * + * @method Phaser.GameObjects.Group#setX + * @since 3.21.0 + * + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + setX: function (value, step) + { + Actions.SetX(Array.from(this.children), value, step); + + return this; + }, + + /** + * Sets the y of each group member. + * + * @method Phaser.GameObjects.Group#setY + * @since 3.21.0 + * + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + setY: function (value, step) + { + Actions.SetY(Array.from(this.children), value, step); + + return this; + }, + + /** + * Sets the x, y of each group member. + * + * @method Phaser.GameObjects.Group#setXY + * @since 3.21.0 + * + * @param {number} x - The amount to set the `x` property to. + * @param {number} [y=x] - The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + setXY: function (x, y, stepX, stepY) + { + Actions.SetXY(Array.from(this.children), x, y, stepX, stepY); + + return this; + }, + + /** + * Adds the given value to the x of each group member. + * + * @method Phaser.GameObjects.Group#incX + * @since 3.21.0 + * + * @param {number} value - The amount to be added to the `x` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + incX: function (value, step) + { + Actions.IncX(Array.from(this.children), value, step); + + return this; + }, + + /** + * Adds the given value to the y of each group member. + * + * @method Phaser.GameObjects.Group#incY + * @since 3.21.0 + * + * @param {number} value - The amount to be added to the `y` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + incY: function (value, step) + { + Actions.IncY(Array.from(this.children), value, step); + + return this; + }, + + /** + * Adds the given value to the x, y of each group member. + * + * @method Phaser.GameObjects.Group#incXY + * @since 3.21.0 + * + * @param {number} x - The amount to be added to the `x` property. + * @param {number} [y=x] - The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + incXY: function (x, y, stepX, stepY) + { + Actions.IncXY(Array.from(this.children), x, y, stepX, stepY); + + return this; + }, + + /** + * Iterate through the group members changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * + * The first group member position is set to x/y. + * + * @method Phaser.GameObjects.Group#shiftPosition + * @since 3.21.0 + * + * @param {number} x - The x coordinate to place the first item in the array at. + * @param {number} y - The y coordinate to place the first item in the array at. + * @param {number} [direction=0] - The iteration direction. 0 = first to last and 1 = last to first. + * + * @return {this} This Group object. + */ + shiftPosition: function (x, y, direction) + { + Actions.ShiftPosition(Array.from(this.children), x, y, direction); + + return this; + }, + + /** + * Adds the given value to the angle of each group member. + * + * @method Phaser.GameObjects.Group#angle + * @since 3.21.0 + * + * @param {number} value - The amount to add to the angle, in degrees. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + angle: function (value, step) + { + Actions.Angle(Array.from(this.children), value, step); + + return this; + }, + + /** + * Sets the rotation of each group member. + * + * @method Phaser.GameObjects.Group#rotate + * @since 3.21.0 + * + * @param {number} value - The amount to set the rotation to, in radians. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + rotate: function (value, step) + { + Actions.Rotate(Array.from(this.children), value, step); + + return this; + }, + + /** + * Rotates each group member around the given point by the given angle. + * + * @method Phaser.GameObjects.Group#rotateAround + * @since 3.21.0 + * + * @param {Phaser.Types.Math.Vector2Like} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * + * @return {this} This Group object. + */ + rotateAround: function (point, angle) + { + Actions.RotateAround(Array.from(this.children), point, angle); + + return this; + }, + + /** + * Rotates each group member around the given point by the given angle and distance. + * + * @method Phaser.GameObjects.Group#rotateAroundDistance + * @since 3.21.0 + * + * @param {Phaser.Types.Math.Vector2Like} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * @param {number} distance - The distance from the point of rotation in pixels. + * + * @return {this} This Group object. + */ + rotateAroundDistance: function (point, angle, distance) + { + Actions.RotateAroundDistance(Array.from(this.children), point, angle, distance); + + return this; + }, + + /** + * Sets the alpha of each group member. + * + * @method Phaser.GameObjects.Group#setAlpha + * @since 3.21.0 + * + * @param {number} value - The amount to set the alpha to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + setAlpha: function (value, step) + { + Actions.SetAlpha(Array.from(this.children), value, step); + + return this; + }, + + /** + * Sets the tint of each group member. + * + * @method Phaser.GameObjects.Group#setTint + * @since 3.21.0 + * + * @param {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. + * @param {number} [topRight] - The tint to be applied to top-right corner of item. + * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. + * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. + * + * @return {this} This Group object. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + Actions.SetTint(Array.from(this.children), topLeft, topRight, bottomLeft, bottomRight); + + return this; + }, + + /** + * Sets the originX, originY of each group member. + * + * @method Phaser.GameObjects.Group#setOrigin + * @since 3.21.0 + * + * @param {number} originX - The amount to set the `originX` property to. + * @param {number} [originY] - The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. + * @param {number} [stepX=0] - This is added to the `originX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `originY` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + setOrigin: function (originX, originY, stepX, stepY) + { + Actions.SetOrigin(Array.from(this.children), originX, originY, stepX, stepY); + + return this; + }, + + /** + * Sets the scaleX of each group member. + * + * @method Phaser.GameObjects.Group#scaleX + * @since 3.21.0 + * + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + scaleX: function (value, step) + { + Actions.ScaleX(Array.from(this.children), value, step); + + return this; + }, + + /** + * Sets the scaleY of each group member. + * + * @method Phaser.GameObjects.Group#scaleY + * @since 3.21.0 + * + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + scaleY: function (value, step) + { + Actions.ScaleY(Array.from(this.children), value, step); + + return this; + }, + + /** + * Sets the scaleX, scaleY of each group member. + * + * @method Phaser.GameObjects.Group#scaleXY + * @since 3.21.0 + * + * @param {number} scaleX - The amount to set the `scaleX` property to. + * @param {number} [scaleY] - The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + scaleXY: function (scaleX, scaleY, stepX, stepY) + { + Actions.ScaleXY(Array.from(this.children), scaleX, scaleY, stepX, stepY); + + return this; + }, + + /** + * Sets the depth of each group member. + * + * @method Phaser.GameObjects.Group#setDepth + * @since 3.0.0 + * + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * + * @return {this} This Group object. + */ + setDepth: function (value, step) + { + Actions.SetDepth(Array.from(this.children), value, step); + + return this; + }, + + /** + * Sets the blendMode of each group member. + * + * @method Phaser.GameObjects.Group#setBlendMode + * @since 3.21.0 + * + * @param {number} value - The blend mode value to set. See `Phaser.BlendModes` for valid values. + * + * @return {this} This Group object. + */ + setBlendMode: function (value) + { + Actions.SetBlendMode(Array.from(this.children), value); + + return this; + }, + + /** + * Passes all group members to the Input Manager to enable them for input with identical areas and callbacks. + * + * @method Phaser.GameObjects.Group#setHitArea + * @since 3.21.0 + * + * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * + * @return {this} This Group object. + */ + setHitArea: function (hitArea, hitAreaCallback) + { + Actions.SetHitArea(Array.from(this.children), hitArea, hitAreaCallback); + + return this; + }, + + /** + * Shuffles the group members in place. + * + * @method Phaser.GameObjects.Group#shuffle + * @since 3.21.0 + * + * @return {this} This Group object. + */ + shuffle: function () + { + Actions.Shuffle(Array.from(this.children)); + + return this; + }, + + /** + * Deactivates a member of this group. + * + * @method Phaser.GameObjects.Group#kill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - A member of this group. + */ + kill: function (gameObject) + { + if (this.children.has(gameObject)) + { + gameObject.setActive(false); + } + }, + + /** + * Deactivates and hides a member of this group. + * + * @method Phaser.GameObjects.Group#killAndHide + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - A member of this group. + */ + killAndHide: function (gameObject) + { + if (this.children.has(gameObject)) + { + gameObject.setActive(false); + gameObject.setVisible(false); + } + }, + + /** + * Sets the visibility of each group member. + * + * @method Phaser.GameObjects.Group#setVisible + * @since 3.21.0 + * + * @param {boolean} value - The value to set the property to. + * @param {number} [index=0] - An optional offset to start searching from within the items array. + * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {this} This Group object. + */ + setVisible: function (value, index, direction) + { + Actions.SetVisible(Array.from(this.children), value, index, direction); + + return this; + }, + + /** + * Toggles (flips) the visible state of each member of this group. + * + * @method Phaser.GameObjects.Group#toggleVisible + * @since 3.0.0 + * + * @return {this} This Group object. + */ + toggleVisible: function () + { + Actions.ToggleVisible(Array.from(this.children)); + + return this; + }, + + /** + * Empties this Group of all children and removes it from the Scene. + * + * Does not call {@link Phaser.GameObjects.Group#removeCallback}. + * + * Children of this Group will _not_ be removed from the Scene by calling this method + * unless you specify the `removeFromScene` parameter. + * + * Children of this Group will also _not_ be destroyed by calling this method + * unless you specify the `destroyChildren` parameter. + * + * @method Phaser.GameObjects.Group#destroy + * @since 3.0.0 + * + * @param {boolean} [destroyChildren=false] - Also {@link Phaser.GameObjects.GameObject#destroy} each Group member. + * @param {boolean} [removeFromScene=false] - Optionally remove each Group member from the Scene. + */ + destroy: function (destroyChildren, removeFromScene) + { + if (destroyChildren === undefined) { destroyChildren = false; } + if (removeFromScene === undefined) { removeFromScene = false; } + + // This Game Object had already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + this.emit(Events.DESTROY, this); + + this.removeAllListeners(); + + this.scene.sys.updateList.remove(this); + + this.clear(removeFromScene, destroyChildren); + + this.scene = undefined; + this.children = undefined; + } + +}); + +module.exports = Group; + + +/***/ }, + +/***/ 94975 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectCreator = __webpack_require__(44603); +var Group = __webpack_require__(26479); + +/** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#group + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Group.GroupConfig|Phaser.Types.GameObjects.Group.GroupCreateConfig} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectCreator.register('group', function (config) +{ + return new Group(this.scene, null, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 3385 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Group = __webpack_require__(26479); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Group Game Object and adds it to the Scene. + * + * A Group is a way of grouping together Game Objects so they can be managed as a single unit. + * Groups have no position or visual representation of their own; they are purely an organizational + * tool. A common use-case is object pooling: pre-creating a fixed set of identical Game Objects + * and recycling them rather than creating and destroying them at runtime. Groups can also apply + * bulk operations (such as setting visibility or enabling physics) to all of their members at once. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#group + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|Phaser.Types.GameObjects.Group.GroupConfig|Phaser.Types.GameObjects.Group.GroupConfig[]|Phaser.Types.GameObjects.Group.GroupCreateConfig)} [children] - Game Objects to add to this Group; or the `config` argument. + * @param {Phaser.Types.GameObjects.Group.GroupConfig|Phaser.Types.GameObjects.Group.GroupCreateConfig} [config] - A Group Configuration object. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectFactory.register('group', function (children, config) +{ + return this.updateList.add(new Group(this.scene, children, config)); +}); + + +/***/ }, + +/***/ 88571 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DefaultImageNodes = __webpack_require__(40939); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var ImageRender = __webpack_require__(59819); + +/** + * @classdesc + * An Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Image = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Lighting, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.Size, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + ImageRender + ], + + initialize: + + function Image (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Image'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Image#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initRenderNodes(this._defaultRenderNodesMap); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Image#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultImageNodes; + } + } + +}); + +module.exports = Image; + + +/***/ }, + +/***/ 40652 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Image#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ImageCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = ImageCanvasRenderer; + + +/***/ }, + +/***/ 82459 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Image = __webpack_require__(88571); + +/** + * Creates a new Image Game Object and returns it. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#image + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.GameObjectConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectCreator.register('image', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var image = new Image(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, image, config); + + return image; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 2117 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Image = __webpack_require__(88571); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Image Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectFactory.register('image', function (x, y, texture, frame) +{ + return this.displayList.add(new Image(this.scene, x, y, texture, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 59819 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(99517); +} + +if (true) +{ + renderCanvas = __webpack_require__(40652); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 99517 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Image#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ImageWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + drawingContext.camera.addToRenderList(src); + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext, + src, + parentMatrix, + 0, + customRenderNodes.Texturer || defaultRenderNodes.Texturer, + customRenderNodes.Transformer || defaultRenderNodes.Transformer + ); +}; + +module.exports = ImageWebGLRenderer; + + +/***/ }, + +/***/ 77856 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.GameObjects + */ + +var GameObjects = { + + Events: __webpack_require__(51708), + + DisplayList: __webpack_require__(8050), + GameObjectCreator: __webpack_require__(44603), + GameObjectFactory: __webpack_require__(39429), + UpdateList: __webpack_require__(45027), + + Components: __webpack_require__(31401), + GetCalcMatrix: __webpack_require__(91296), + + BuildGameObject: __webpack_require__(25305), + BuildGameObjectAnimation: __webpack_require__(13059), + GameObject: __webpack_require__(95643), + BitmapText: __webpack_require__(22186), + Blitter: __webpack_require__(6107), + Bob: __webpack_require__(46590), + Container: __webpack_require__(31559), + DOMElement: __webpack_require__(3069), + DynamicBitmapText: __webpack_require__(2638), + Extern: __webpack_require__(42421), + Graphics: __webpack_require__(43831), + Group: __webpack_require__(26479), + Image: __webpack_require__(88571), + Layer: __webpack_require__(93595), + Particles: __webpack_require__(18404), + PathFollower: __webpack_require__(1159), + RenderTexture: __webpack_require__(591), + RetroFont: __webpack_require__(196), + Rope: __webpack_require__(77757), + Sprite: __webpack_require__(68287), + Stamp: __webpack_require__(14727), + + Text: __webpack_require__(50171), + GetTextSize: __webpack_require__(14220), + MeasureText: __webpack_require__(79557), + TextStyle: __webpack_require__(35762), + + TileSprite: __webpack_require__(20839), + Zone: __webpack_require__(41481), + Video: __webpack_require__(18471), + + // Shapes + + Shape: __webpack_require__(17803), + Arc: __webpack_require__(23629), + Curve: __webpack_require__(89), + Ellipse: __webpack_require__(19921), + Grid: __webpack_require__(30479), + IsoBox: __webpack_require__(61475), + IsoTriangle: __webpack_require__(16933), + Line: __webpack_require__(57847), + Polygon: __webpack_require__(24949), + Rectangle: __webpack_require__(74561), + Star: __webpack_require__(55911), + Triangle: __webpack_require__(36931), + + // Game Object Factories + + Factories: { + Blitter: __webpack_require__(12709), + Container: __webpack_require__(24961), + DOMElement: __webpack_require__(2611), + DynamicBitmapText: __webpack_require__(72566), + Extern: __webpack_require__(56315), + Graphics: __webpack_require__(1201), + Group: __webpack_require__(3385), + Image: __webpack_require__(2117), + Layer: __webpack_require__(20005), + Particles: __webpack_require__(676), + PathFollower: __webpack_require__(90145), + RenderTexture: __webpack_require__(60505), + Rope: __webpack_require__(96819), + Sprite: __webpack_require__(46409), + Stamp: __webpack_require__(85326), + StaticBitmapText: __webpack_require__(34914), + Text: __webpack_require__(68005), + TileSprite: __webpack_require__(91681), + Zone: __webpack_require__(84175), + Video: __webpack_require__(89025), + + // Shapes + Arc: __webpack_require__(42563), + Curve: __webpack_require__(40511), + Ellipse: __webpack_require__(1543), + Grid: __webpack_require__(34137), + IsoBox: __webpack_require__(3933), + IsoTriangle: __webpack_require__(49803), + Line: __webpack_require__(2481), + Polygon: __webpack_require__(64827), + Rectangle: __webpack_require__(87959), + Star: __webpack_require__(93697), + Triangle: __webpack_require__(45245) + }, + + Creators: { + Blitter: __webpack_require__(9403), + Container: __webpack_require__(77143), + DynamicBitmapText: __webpack_require__(11164), + Graphics: __webpack_require__(87079), + Group: __webpack_require__(94975), + Image: __webpack_require__(82459), + Layer: __webpack_require__(25179), + Particles: __webpack_require__(92730), + RenderTexture: __webpack_require__(34495), + Rope: __webpack_require__(26209), + Sprite: __webpack_require__(15567), + Stamp: __webpack_require__(31479), + StaticBitmapText: __webpack_require__(57336), + Text: __webpack_require__(71259), + TileSprite: __webpack_require__(14167), + Zone: __webpack_require__(95261), + Video: __webpack_require__(11511) + } + +}; + +// WebGL only Game Objects +if (true) +{ + GameObjects.CaptureFrame = __webpack_require__(43451); + GameObjects.CustomContext = __webpack_require__(55327); + GameObjects.Gradient = __webpack_require__(34637); + GameObjects.Mesh2D = __webpack_require__(76435); + GameObjects.Noise = __webpack_require__(35387); + GameObjects.NoiseCell2D = __webpack_require__(51513); + GameObjects.NoiseCell3D = __webpack_require__(15686); + GameObjects.NoiseCell4D = __webpack_require__(41946); + GameObjects.NoiseSimplex2D = __webpack_require__(1792); + GameObjects.NoiseSimplex3D = __webpack_require__(51098); + GameObjects.Shader = __webpack_require__(20071); + GameObjects.NineSlice = __webpack_require__(28103); + GameObjects.PointLight = __webpack_require__(80321); + GameObjects.SpriteGPULayer = __webpack_require__(76573); + GameObjects.Stencil = __webpack_require__(84423); + GameObjects.StencilReference = __webpack_require__(63911); + + GameObjects.Factories.CaptureFrame = __webpack_require__(20421); + GameObjects.Factories.CustomContext = __webpack_require__(4745); + GameObjects.Factories.Gradient = __webpack_require__(69315); + GameObjects.Factories.Mesh2D = __webpack_require__(2317); + GameObjects.Factories.Noise = __webpack_require__(34757); + GameObjects.Factories.NoiseCell2D = __webpack_require__(26590); + GameObjects.Factories.NoiseCell3D = __webpack_require__(89918); + GameObjects.Factories.NoiseCell4D = __webpack_require__(65874); + GameObjects.Factories.NoiseSimplex2D = __webpack_require__(80308); + GameObjects.Factories.NoiseSimplex3D = __webpack_require__(73810); + GameObjects.Factories.Shader = __webpack_require__(74177); + GameObjects.Factories.NineSlice = __webpack_require__(47521); + GameObjects.Factories.PointLight = __webpack_require__(71255); + GameObjects.Factories.SpriteGPULayer = __webpack_require__(96019); + GameObjects.Factories.Stencil = __webpack_require__(67841); + GameObjects.Factories.StencilReference = __webpack_require__(37889); + + GameObjects.Creators.CaptureFrame = __webpack_require__(23675); + GameObjects.Creators.CustomContext = __webpack_require__(90255); + GameObjects.Creators.Gradient = __webpack_require__(26353); + GameObjects.Creators.Mesh2D = __webpack_require__(2227); + GameObjects.Creators.Noise = __webpack_require__(39931); + GameObjects.Creators.NoiseCell2D = __webpack_require__(98292); + GameObjects.Creators.NoiseCell3D = __webpack_require__(97044); + GameObjects.Creators.NoiseCell4D = __webpack_require__(20136); + GameObjects.Creators.NoiseSimplex2D = __webpack_require__(51754); + GameObjects.Creators.NoiseSimplex3D = __webpack_require__(71112); + GameObjects.Creators.Shader = __webpack_require__(54935); + GameObjects.Creators.NineSlice = __webpack_require__(28279); + GameObjects.Creators.PointLight = __webpack_require__(39829); + GameObjects.Creators.SpriteGPULayer = __webpack_require__(16193); + GameObjects.Creators.Stencil = __webpack_require__(32247); + GameObjects.Creators.StencilReference = __webpack_require__(44023); + + GameObjects.Light = __webpack_require__(41432); + GameObjects.LightsManager = __webpack_require__(61356); + GameObjects.LightsPlugin = __webpack_require__(88992); +} + +module.exports = GameObjects; + + +/***/ }, + +/***/ 93595 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BlendModes = __webpack_require__(10312); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var EventEmitter = __webpack_require__(50792); +var GameObject = __webpack_require__(95643); +var GameObjectEvents = __webpack_require__(51708); +var List = __webpack_require__(73162); +var Render = __webpack_require__(33963); +var SceneEvents = __webpack_require__(44594); +var StableSort = __webpack_require__(19186); + +/** + * @classdesc + * A Layer Game Object. + * + * A Layer is a special type of Game Object that acts as a Display List. You can add any type of Game Object + * to a Layer, just as you would to a Scene. Layers can be used to visually group together 'layers' of Game + * Objects: + * + * ```javascript + * const spaceman = this.add.sprite(150, 300, 'spaceman'); + * const bunny = this.add.sprite(400, 300, 'bunny'); + * const elephant = this.add.sprite(650, 300, 'elephant'); + * + * const layer = this.add.layer(); + * + * layer.add([ spaceman, bunny, elephant ]); + * ``` + * + * The 3 sprites in the example above will now be managed by the Layer they were added to. Therefore, + * if you then set `layer.setVisible(false)` they would all vanish from the display. + * + * You can also control the depth of the Game Objects within the Layer. For example, calling the + * `setDepth` method of a child of a Layer will allow you to adjust the depth of that child _within the + * Layer itself_, rather than the whole Scene. The Layer, too, can have its depth set as well. + * + * The Layer class also offers many different methods for manipulating the list, such as the + * methods `moveUp`, `moveDown`, `sendToBack`, `bringToTop` and so on. These allow you to change the + * display list position of the Layers children, causing it to adjust the order in which they are + * rendered. Using `setDepth` on a child allows you to override this. + * + * Layers have no position or size within the Scene. This means you cannot enable a Layer for + * physics or input, or change the position, rotation or scale of a Layer. They also have no scroll + * factor, texture, tint, origin, crop or bounds. + * + * If you need those kind of features then you should use a Container instead. Containers can be added + * to Layers, but Layers cannot be added to Containers. + * + * However, you can set the Alpha, Blend Mode, Depth, Mask and Visible state of a Layer. These settings + * will impact all children being rendered by the Layer. + * + * Layers should always be the topmost elements of any scene hierarchy. + * They can be children of layers, but not of anything else. + * + * Until Phaser version 4.1.0, Layer was not a true GameObject. + * It is now a true GameObject. + * + * @class Layer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.50.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Layer. + */ +var Layer = new Class({ + + Extends: List, + + Mixins: [ + EventEmitter, + GameObject, + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.Visible, + Render + ], + + initialize: + + function Layer (scene, children) + { + List.call(this, scene); + EventEmitter.call(this); + GameObject.call(this, scene, 'Layer'); + + /** + * A reference to the Scene to which this Game Object belongs. + * + * Game Objects can only belong to one Scene. + * + * You should consider this property as being read-only. You cannot move a + * Game Object to another Scene by simply changing it. + * + * @name Phaser.GameObjects.Layer#scene + * @type {Phaser.Scene} + * @since 3.50.0 + */ + this.scene = scene; + + /** + * A reference to the Scene Systems. + * + * @name Phaser.GameObjects.Layer#systems + * @type {Phaser.Scenes.Systems} + * @since 3.50.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Event Emitter. + * + * @name Phaser.GameObjects.Layer#events + * @type {Phaser.Events.EventEmitter} + * @since 3.50.0 + */ + this.events = scene.sys.events; + + /** + * The flag that determines whether Game Objects should be sorted when `depthSort()` is called. + * + * @name Phaser.GameObjects.Layer#sortChildrenFlag + * @type {boolean} + * @default false + * @since 3.50.0 + */ + this.sortChildrenFlag = false; + + // Set the List callbacks + this.addCallback = this.addChildCallback; + this.removeCallback = this.removeChildCallback; + + this.clearAlpha(); + + this.setBlendMode(BlendModes.SKIP_CHECK); + + if (children) + { + this.add(children); + } + + // Tell the Scene to re-sort the children + scene.sys.queueDepthSort(); + }, + + /** + * A Layer cannot be enabled for input. + * + * This method does nothing and is kept to ensure + * the Layer has the same shape as a Game Object. + * + * @method Phaser.GameObjects.Layer#setInteractive + * @since 3.51.0 + * + * @return {this} This GameObject. + */ + setInteractive: function () + { + return this; + }, + + /** + * A Layer cannot be enabled for input. + * + * This method does nothing and is kept to ensure + * the Layer has the same shape as a Game Object. + * + * @method Phaser.GameObjects.Layer#disableInteractive + * @since 3.51.0 + * + * @return {this} This GameObject. + */ + disableInteractive: function () + { + return this; + }, + + /** + * A Layer cannot be enabled for input. + * + * This method does nothing and is kept to ensure + * the Layer has the same shape as a Game Object. + * + * @method Phaser.GameObjects.Layer#removeInteractive + * @since 3.51.0 + * + * @return {this} This GameObject. + */ + removeInteractive: function () + { + return this; + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.Layer#willRender + * @since 3.50.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + return !(this.renderFlags !== 15 || this.list.length === 0 || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Internal method called from `List.addCallback`. + * + * @method Phaser.GameObjects.Layer#addChildCallback + * @private + * @fires Phaser.Scenes.Events#ADDED_TO_SCENE + * @fires Phaser.GameObjects.Events#ADDED_TO_SCENE + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was added to the list. + */ + addChildCallback: function (gameObject) + { + var displayList = gameObject.displayList; + + if (displayList && displayList !== this) + { + gameObject.removeFromDisplayList(); + } + + if (!gameObject.displayList) + { + this.queueDepthSort(); + + gameObject.displayList = this; + + gameObject.emit(GameObjectEvents.ADDED_TO_SCENE, gameObject, this.scene); + + this.events.emit(SceneEvents.ADDED_TO_SCENE, gameObject, this.scene); + } + }, + + /** + * Internal method called from `List.removeCallback`. + * + * @method Phaser.GameObjects.Layer#removeChildCallback + * @private + * @fires Phaser.Scenes.Events#REMOVED_FROM_SCENE + * @fires Phaser.GameObjects.Events#REMOVED_FROM_SCENE + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was removed from the list. + */ + removeChildCallback: function (gameObject) + { + this.queueDepthSort(); + + gameObject.displayList = null; + + gameObject.emit(GameObjectEvents.REMOVED_FROM_SCENE, gameObject, this.scene); + + this.events.emit(SceneEvents.REMOVED_FROM_SCENE, gameObject, this.scene); + }, + + /** + * Force a sort of the display list on the next call to depthSort. + * + * @method Phaser.GameObjects.Layer#queueDepthSort + * @since 3.50.0 + */ + queueDepthSort: function () + { + this.sortChildrenFlag = true; + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.GameObjects.Layer#depthSort + * @since 3.50.0 + */ + depthSort: function () + { + if (this.sortChildrenFlag) + { + StableSort(this.list, this.sortByDepth); + + this.sortChildrenFlag = false; + } + }, + + /** + * Compare the depth of two Game Objects. + * + * @method Phaser.GameObjects.Layer#sortByDepth + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first Game Object. + * @param {Phaser.GameObjects.GameObject} childB - The second Game Object. + * + * @return {number} The difference between the depths of each Game Object. + */ + sortByDepth: function (childA, childB) + { + return childA._depth - childB._depth; + }, + + /** + * Returns a reference to the array which contains all Game Objects in this Layer. + * + * This is a reference, not a copy of it, so be very careful not to mutate it. + * + * @method Phaser.GameObjects.Layer#getChildren + * @since 3.50.0 + * + * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects within this Layer. + */ + getChildren: function () + { + return this.list; + }, + + /** + * Return an array listing the events for which the emitter has registered listeners. + * + * @method Phaser.GameObjects.Layer#eventNames + * @since 3.50.0 + * + * @return {Array.} + */ + + /** + * Return the listeners registered for a given event. + * + * @method Phaser.GameObjects.Layer#listeners + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {Function[]} The registered listeners. + */ + + /** + * Return the number of listeners listening to a given event. + * + * @method Phaser.GameObjects.Layer#listenerCount + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {number} The number of listeners. + */ + + /** + * Calls each of the listeners registered for a given event. + * + * @method Phaser.GameObjects.Layer#emit + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * @param {...*} [args] - Additional arguments that will be passed to the event handler. + * + * @return {boolean} `true` if the event had listeners, else `false`. + */ + + /** + * Add a listener for a given event. + * + * @method Phaser.GameObjects.Layer#on + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {this} This Layer instance. + */ + + /** + * Add a listener for a given event. + * + * @method Phaser.GameObjects.Layer#addListener + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {this} This Layer instance. + */ + + /** + * Add a one-time listener for a given event. + * + * @method Phaser.GameObjects.Layer#once + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {this} This Layer instance. + */ + + /** + * Remove the listeners of a given event. + * + * @method Phaser.GameObjects.Layer#removeListener + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} [fn] - Only remove the listeners that match this function. + * @param {*} [context] - Only remove the listeners that have this context. + * @param {boolean} [once] - Only remove one-time listeners. + * + * @return {this} This Layer instance. + */ + + /** + * Remove the listeners of a given event. + * + * @method Phaser.GameObjects.Layer#off + * @since 3.50.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} [fn] - Only remove the listeners that match this function. + * @param {*} [context] - Only remove the listeners that have this context. + * @param {boolean} [once] - Only remove one-time listeners. + * + * @return {this} This Layer instance. + */ + + /** + * Remove all listeners, or those of the specified event. + * + * @method Phaser.GameObjects.Layer#removeAllListeners + * @since 3.50.0 + * + * @param {(string|symbol)} [event] - The event name. + * + * @return {this} This Layer instance. + */ + + // -------------- + // Append type declarations from List, which won't otherwise be picked up by the type build system. + // -------------- + + /** + * The parent of this list. + * + * @name Phaser.GameObjects.Layer#parent + * @type {*} + * @since 3.0.0 + */ + + /** + * The objects that belong to this collection. + * + * @name Phaser.GameObjects.Layer#list + * @type {Array.} + * @default [] + * @since 3.0.0 + */ + + /** + * The index of the current element. + * + * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #next}, and {@link #previous} properties. + * + * @name Phaser.GameObjects.Layer#position + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * A callback that is invoked every time a child is added to this list. + * + * @name Phaser.GameObjects.Layer#addCallback + * @type {function} + * @since 3.4.0 + */ + + /** + * A callback that is invoked every time a child is removed from this list. + * + * @name Phaser.GameObjects.Layer#removeCallback + * @type {function} + * @since 3.4.0 + */ + + /** + * The property key to sort by. + * + * @name Phaser.GameObjects.Layer#_sortKey + * @type {string} + * @since 3.4.0 + */ + + /** + * Adds the given item to the end of the list. Each item must be unique. + * + * @method Phaser.GameObjects.Layer#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject|Array.} child - The item, or array of items, to add to the list. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {*} The list's underlying array. + */ + + /** + * Adds an item to list, starting at a specified index. Each item must be unique within the list. + * + * @method Phaser.GameObjects.Layer#addAt + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject|Array.} child - The item, or array of items, to add to the list. + * @param {number} [index=0] - The index in the list at which the element(s) will be inserted. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {Array.} The List's underlying array. + */ + + /** + * Retrieves the item at a given position inside the List. + * + * @method Phaser.GameObjects.Layer#getAt + * @since 3.0.0 + * + * @param {number} index - The index of the item. + * + * @return {Phaser.GameObjects.GameObject|undefined} The retrieved item, or `undefined` if it's outside the List's bounds. + */ + + /** + * Locates an item within the List and returns its index. + * + * @method Phaser.GameObjects.Layer#getIndex + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The item to locate. + * + * @return {number} The index of the item within the List, or -1 if it's not in the List. + */ + + /** + * Sort the contents of this List so the items are in order based on the given property. + * For example, `sort('alpha')` would sort the List contents based on the value of their `alpha` property. + * + * @method Phaser.GameObjects.Layer#sort + * @since 3.0.0 + * + * @param {string} property - The property to lexically sort by. + * @param {function} [handler] - Provide your own custom handler function. Will receive 2 children which it should compare and return a number (negative if the first should come before the second, positive if after, zero if equal). + * + * @return {Phaser.GameObjects.Layer} This List object. + */ + + /** + * Searches for the first instance of a child with its `name` + * property matching the given argument. Should more than one child have + * the same name only the first is returned. + * + * @method Phaser.GameObjects.Layer#getByName + * @since 3.0.0 + * + * @param {string} name - The name to search for. + * + * @return {?Phaser.GameObjects.GameObject} The first child with a matching name, or null if none were found. + */ + + /** + * Returns a random child from the list. + * + * @method Phaser.GameObjects.Layer#getRandom + * @since 3.0.0 + * + * @param {number} [startIndex=0] - Offset from the front of the list (lowest child). + * @param {number} [length=(to top)] - Restriction on the number of values you want to randomly select from. + * + * @return {?Phaser.GameObjects.GameObject} A random child of this List. + */ + + /** + * Returns the first element in a given part of the List which matches a specific criterion. + * + * @method Phaser.GameObjects.Layer#getFirst + * @since 3.0.0 + * + * @param {string} property - The name of the property to test or a falsey value to have no criterion. + * @param {Phaser.GameObjects.GameObject|undefined} value - The value to test the `property` against, or `undefined` to allow any value and only check for existence. + * @param {number} [startIndex=0] - The position in the List to start the search at. + * @param {number} [endIndex] - The position in the List to optionally stop the search at. It won't be checked. + * + * @return {?Phaser.GameObjects.GameObject} The first item which matches the given criterion, or `null` if no such item exists. + */ + + /** + * Returns all children in this List. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('parent')` would return only children that have a property called `parent`. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only children that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this List had 100 children, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 children in the List. + * + * @method Phaser.GameObjects.Layer#getAll + * @since 3.0.0 + * + * @param {string} [property] - An optional property to test against the value argument. + * @param {any} [value] - If property is set then Child.property must strictly equal this value to be included in the results. + * @param {number} [startIndex] - The first child index to start the search from. + * @param {number} [endIndex] - The last child index to search up until. + * + * @return {Array.} All items of the List which match the given criterion, if any. + */ + + /** + * Returns the total number of items in the List which have a property matching the given value. + * + * @method Phaser.GameObjects.Layer#count + * @since 3.0.0 + * + * @param {string} property - The property to test on each item. + * @param {Phaser.GameObjects.GameObject} value - The value to test the property against. + * + * @return {number} The total number of matching elements. + */ + + /** + * Swaps the positions of two items in the list. + * + * @method Phaser.GameObjects.Layer#swap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child1 - The first item to swap. + * @param {Phaser.GameObjects.GameObject} child2 - The second item to swap. + */ + + /** + * Moves an item in the List to a new position. + * + * @method Phaser.GameObjects.Layer#moveTo + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The item to move. + * @param {number} index - The new position to move the item to. + * + * @return {Phaser.GameObjects.GameObject} The item that was moved. + */ + + /** + * Moves an item above another one in the List. + * If the given item is already above the other, it isn't moved. + * Above means toward the end of the List. + * + * @method Phaser.GameObjects.Layer#moveAbove + * @since 3.55.0 + * + * @param {Phaser.GameObjects.GameObject} child1 - The element to move above base element. + * @param {Phaser.GameObjects.GameObject} child2 - The base element. + */ + + /** + * Moves an item below another one in the List. + * If the given item is already below the other, it isn't moved. + * Below means toward the start of the List. + * + * @method Phaser.GameObjects.Layer#moveBelow + * @since 3.55.0 + * + * @param {Phaser.GameObjects.GameObject} child1 - The element to move below base element. + * @param {Phaser.GameObjects.GameObject} child2 - The base element. + */ + + /** + * Removes one or many items from the List. + * + * @method Phaser.GameObjects.Layer#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject|Array.} child - The item, or array of items, to remove. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Phaser.GameObjects.GameObject|Array.} The item, or array of items, which were successfully removed from the List. + */ + + /** + * Removes the item at the given position in the List. + * + * @method Phaser.GameObjects.Layer#removeAt + * @since 3.0.0 + * + * @param {number} index - The position to remove the item from. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Phaser.GameObjects.GameObject} The item that was removed. + */ + + /** + * Removes the items within the given range in the List. + * + * @method Phaser.GameObjects.Layer#removeBetween + * @since 3.0.0 + * + * @param {number} [startIndex=0] - The index to start removing from. + * @param {number} [endIndex] - The position to stop removing at. The item at this position won't be removed. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Array.} An array of the items which were removed. + */ + + /** + * Removes all the items. + * + * @method Phaser.GameObjects.Layer#removeAll + * @since 3.0.0 + * + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {this} This List object. + */ + + /** + * Brings the given child to the top of this List. + * + * @method Phaser.GameObjects.Layer#bringToTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The item to bring to the top of the List. + * + * @return {Phaser.GameObjects.GameObject} The item which was moved. + */ + + /** + * Sends the given child to the bottom of this List. + * + * @method Phaser.GameObjects.Layer#sendToBack + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The item to send to the back of the list. + * + * @return {Phaser.GameObjects.GameObject} The item which was moved. + */ + + /** + * Moves the given child up one place in this List unless it's already at the top. + * + * @method Phaser.GameObjects.Layer#moveUp + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The item to move up. + * + * @return {Phaser.GameObjects.GameObject} The item which was moved. + */ + + /** + * Moves the given child down one place in this List unless it's already at the bottom. + * + * @method Phaser.GameObjects.Layer#moveDown + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The item to move down. + * + * @return {Phaser.GameObjects.GameObject} The item which was moved. + */ + + /** + * Reverses the order of all children in this List. + * + * @method Phaser.GameObjects.Layer#reverse + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Layer} This List object. + */ + + /** + * Shuffles the items in the list. + * + * @method Phaser.GameObjects.Layer#shuffle + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Layer} This List object. + */ + + /** + * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. + * + * @method Phaser.GameObjects.Layer#replace + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} oldChild - The child in this List that will be replaced. + * @param {Phaser.GameObjects.GameObject} newChild - The child to be inserted into this List. + * + * @return {Phaser.GameObjects.GameObject} Returns the oldChild that was replaced within this List. + */ + + /** + * Checks if an item exists within the List. + * + * @method Phaser.GameObjects.Layer#exists + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The item to check for the existence of. + * + * @return {boolean} `true` if the item is found in the list, otherwise `false`. + */ + + /** + * Sets the property `key` to the given value on all members of this List. + * + * @method Phaser.GameObjects.Layer#setAll + * @since 3.0.0 + * + * @param {string} property - The name of the property to set. + * @param {any} value - The value to set the property to. + * @param {number} [startIndex] - The first child index to start the search from. + * @param {number} [endIndex] - The last child index to search up until. + */ + + /** + * Passes all children to the given callback. + * + * @method Phaser.GameObjects.Layer#each + * @since 3.0.0 + * + * @param {EachListCallback.} callback - The function to call. + * @param {any} [context] - Value to use as `this` when executing callback. + * @param {...any} [args] - Additional arguments that will be passed to the callback, after the child. + */ + + /** + * Clears the List and recreates its internal array. + * + * @method Phaser.GameObjects.Layer#shutdown + * @since 3.0.0 + */ + + /** + * The number of items inside the List. + * + * @name Phaser.GameObjects.Layer#length + * @type {number} + * @readonly + * @since 3.0.0 + */ + + /** + * The first item in the List or `null` for an empty List. + * + * @name Phaser.GameObjects.Layer#first + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.0.0 + */ + + /** + * The last item in the List, or `null` for an empty List. + * + * @name Phaser.GameObjects.Layer#last + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.0.0 + */ + + /** + * The next item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. + * + * @name Phaser.GameObjects.Layer#next + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.0.0 + */ + + /** + * The previous item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. + * + * @name Phaser.GameObjects.Layer#previous + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.0.0 + */ + + /** + * Destroys this Layer removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also destroys all children of this Layer. If you do not wish for the + * children to be destroyed, you should move them from this Layer first. + * + * Use this to remove this Layer from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * + * @method Phaser.GameObjects.Layer#destroy + * @fires Phaser.GameObjects.Events#DESTROY + * @since 3.50.0 + * + * @param {boolean} [fromScene=false] - `True` if this Game Object is being destroyed by the Scene, `false` if not. + */ + destroy: function (fromScene) + { + // This Game Object has already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + GameObject.prototype.destroy.call(this, fromScene); + + var list = this.list; + + while (list.length) + { + list[0].destroy(fromScene); + } + + this.list = undefined; + this.systems = undefined; + this.events = undefined; + } + +}); + +module.exports = Layer; + + +/***/ }, + +/***/ 2956 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Layer#renderCanvas + * @since 3.50.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Layer} layer - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var LayerCanvasRenderer = function (renderer, layer, camera) +{ + var children = layer.list; + + if (children.length === 0) + { + return; + } + + layer.depthSort(); + + var layerHasBlendMode = (layer.blendMode !== -1); + + if (!layerHasBlendMode) + { + // If Layer is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = layer._alpha; + + if (layer.mask) + { + layer.mask.preRenderCanvas(renderer, null, camera); + } + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child.alpha; + + if (!layerHasBlendMode && child.blendMode !== renderer.currentBlendMode) + { + // If Layer doesn't have its own blend mode, then a child can have one + renderer.setBlendMode(child.blendMode); + } + + // Set parent values + child.setAlpha(childAlpha * alpha); + + // Render + child.renderCanvas(renderer, child, camera); + + // Restore original values + child.setAlpha(childAlpha); + } + + if (layer.mask) + { + layer.mask.postRenderCanvas(renderer); + } +}; + +module.exports = LayerCanvasRenderer; + + +/***/ }, + +/***/ 25179 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var Layer = __webpack_require__(93595); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); + +/** + * Creates a new Layer Game Object and returns it. + * + * A Layer is a special type of Game Object that groups other Game Objects together. Unlike a Container, + * a Layer does not apply any transform to its children. Instead, it provides a way to manage rendering + * order and apply post-pipelines or effects to a collection of Game Objects as a single unit. + * The `children` property of the config object can be used to pass an array of Game Objects to add + * to the Layer immediately upon creation. + * + * Note: This method will only be available if the Layer Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#layer + * @since 3.50.0 + * + * @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} config - The configuration object this Game Object will use to create itself. The `children` key can be set to an array of Game Objects to add to the Layer. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Layer} The Game Object that was created. + */ +GameObjectCreator.register('layer', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var children = GetAdvancedValue(config, 'children', null); + + var layer = new Layer(this.scene, children); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, layer, config); + + return layer; +}); + + +/***/ }, + +/***/ 20005 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Layer = __webpack_require__(93595); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Layer Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Layer Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#layer + * @since 3.50.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Layer. + * + * @return {Phaser.GameObjects.Layer} The Game Object that was created. + */ +GameObjectFactory.register('layer', function (children) +{ + return this.displayList.add(new Layer(this.scene, children)); +}); + + +/***/ }, + +/***/ 33963 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(15869); +} + +if (true) +{ + renderCanvas = __webpack_require__(2956); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 15869 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(8054); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Layer#renderWebGL + * @since 3.50.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Layer} layer - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + * @param {number} renderStep - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} displayList - The display list which is currently being rendered. + * @param {number} displayListIndex - The index of the Game Object within the display list. + */ +var LayerWebGLRenderer = function (renderer, layer, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) +{ + var children = layer.list; + var childCount = children.length; + + if (childCount === 0) + { + return; + } + + var currentContext = drawingContext; + var camera = currentContext.camera; + + layer.depthSort(); + + var layerHasBlendMode = (layer.blendMode !== CONST.BlendModes.SKIP_CHECK); + + if (!layerHasBlendMode && currentContext.blendMode !== 0) + { + // If Layer is SKIP_TEST then set blend mode to be Normal + currentContext = currentContext.getClone(); + currentContext.setBlendMode(0); + currentContext.use(); + } + + var alpha = layer.alpha; + + for (var i = 0; i < childCount; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlphaTopLeft; + var childAlphaTopRight; + var childAlphaBottomLeft; + var childAlphaBottomRight; + + if (child.alphaTopLeft !== undefined) + { + childAlphaTopLeft = child.alphaTopLeft; + childAlphaTopRight = child.alphaTopRight; + childAlphaBottomLeft = child.alphaBottomLeft; + childAlphaBottomRight = child.alphaBottomRight; + } + else + { + var childAlpha = child.alpha; + + childAlphaTopLeft = childAlpha; + childAlphaTopRight = childAlpha; + childAlphaBottomLeft = childAlpha; + childAlphaBottomRight = childAlpha; + } + + if ( + !layerHasBlendMode && + child.blendMode !== currentContext.blendMode && + child.blendMode !== CONST.BlendModes.SKIP_CHECK + ) + { + // If Layer doesn't have its own blend mode, then a child can have one + currentContext = currentContext.getClone(); + currentContext.setBlendMode(child.blendMode); + currentContext.use(); + } + + child.setAlpha(childAlphaTopLeft * alpha, childAlphaTopRight * alpha, childAlphaBottomLeft * alpha, childAlphaBottomRight * alpha); + + // Render + child.renderWebGLStep(renderer, child, currentContext, undefined, undefined, children, i); + + // Restore original values + child.setAlpha(childAlphaTopLeft, childAlphaTopRight, childAlphaBottomLeft, childAlphaBottomRight); + } + + // Release any remaining context. + if (currentContext !== drawingContext) + { + currentContext.release(); + } +}; + +module.exports = LayerWebGLRenderer; + + +/***/ }, + +/***/ 41432 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circle = __webpack_require__(96503); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var RGB = __webpack_require__(51767); +var Utils = __webpack_require__(70554); + +/** + * @classdesc + * A 2D Light. + * + * These are created by the {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. + * + * Any Game Objects with the Lighting Component, and `setLighting(true)`, + * will then be affected by these Lights. + * If they have a normal map, it will be used. + * If they don't, the Lights will use the default normal map, a flat surface. + * + * They can also simply be used to represent a point light for your own purposes. + * + * Lights cannot be added to Containers. They are designed to exist in the root of a Scene. + * + * @class Light + * @extends Phaser.Geom.Circle + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color of the light. A value between 0 and 1. + * @param {number} g - The green color of the light. A value between 0 and 1. + * @param {number} b - The blue color of the light. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + * @param {number} [z] - The z position of the light. If not given, it will be set to `radius * 0.1`. + */ +var Light = new Class({ + + Extends: Circle, + + Mixins: [ + Components.Origin, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function Light (x, y, radius, r, g, b, intensity, z) + { + Circle.call(this, x, y, radius); + + /** + * The color of the light. + * + * @name Phaser.GameObjects.Light#color + * @type {Phaser.Display.RGB} + * @since 3.50.0 + */ + this.color = new RGB(r, g, b); + + /** + * The intensity of the light. This scales the overall brightness of the light effect. + * A value of 1 is considered normal brightness. Higher values produce a stronger, brighter light. + * + * @name Phaser.GameObjects.Light#intensity + * @type {number} + * @since 3.50.0 + */ + this.intensity = intensity; + + /** + * The z position of the light. + * This affects the relief effect created by the light. + * A higher value will make the light appear more raised. + * + * Lit game objects are considered to be at z=0. + * Thus, if z is larger than the radius of the light, + * the light will not affect them. + * Strong values are in the range of 0 to radius/2. + * + * This is not a true position, and won't be affected by + * perspective or camera position. It won't be set by `setTo`. + * Use `setZ` to set it, or `setZNormal` to set it to a fraction + * of the radius. + * + * @name Phaser.GameObjects.Light#z + * @type {number} + * @since 4.0.0 + */ + this.z = z === undefined ? radius * 0.1 : z; + + /** + * Whether this Light is restricted to a cone. + * + * @name Phaser.GameObjects.Light#coneEnabled + * @type {boolean} + * @default false + * @since 4.2.0 + */ + this.coneEnabled = false; + + /** + * The cone direction, in radians, in world space. + * + * @name Phaser.GameObjects.Light#coneRotation + * @type {number} + * @default 0 + * @since 4.2.0 + */ + this.coneRotation = 0; + + /** + * The inner cone angle, in radians. Fragments inside this angle receive full light. + * + * @name Phaser.GameObjects.Light#coneInnerAngle + * @type {number} + * @default 0 + * @since 4.2.0 + */ + this.coneInnerAngle = 0; + + /** + * The outer cone angle, in radians. Fragments outside this angle receive no light. + * + * @name Phaser.GameObjects.Light#coneOuterAngle + * @type {number} + * @default 0 + * @since 4.2.0 + */ + this.coneOuterAngle = 0; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Light will render or not. + * The relevant bit is 0001, set by the Visible component. The remaining bits are unused by Light + * but are reserved for custom use if required. + * + * @name Phaser.GameObjects.Light#renderFlags + * @type {number} + * @default 15 + * @since 3.0.0 + */ + this.renderFlags = 15; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id + * + * @name Phaser.GameObjects.Light#cameraFilter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cameraFilter = 0; + + this.setScrollFactor(1, 1); + this.setOrigin(); + this.setDisplayOrigin(radius); + }, + + /** + * The width of this Light Game Object. This is the same as `Light.diameter`. + * + * @name Phaser.GameObjects.Light#displayWidth + * @type {number} + * @since 3.60.0 + */ + displayWidth: { + + get: function () + { + return this.diameter; + }, + + set: function (value) + { + this.diameter = value; + } + + }, + + /** + * The height of this Light Game Object. This is the same as `Light.diameter`. + * + * @name Phaser.GameObjects.Light#displayHeight + * @type {number} + * @since 3.60.0 + */ + displayHeight: { + + get: function () + { + return this.diameter; + }, + + set: function (value) + { + this.diameter = value; + } + + }, + + /** + * The width of this Light Game Object. This is the same as `Light.diameter`. + * + * @name Phaser.GameObjects.Light#width + * @type {number} + * @since 3.60.0 + */ + width: { + + get: function () + { + return this.diameter; + }, + + set: function (value) + { + this.diameter = value; + } + + }, + + /** + * The height of this Light Game Object. This is the same as `Light.diameter`. + * + * @name Phaser.GameObjects.Light#height + * @type {number} + * @since 3.60.0 + */ + height: { + + get: function () + { + return this.diameter; + }, + + set: function (value) + { + this.diameter = value; + } + + }, + + /** + * The z position of the light, as a fraction of the radius. + * This affects the relief effect created by the light. + * A higher value will make the light appear more raised. + * Strong values are in the range of 0 to 0.5. + * + * @name Phaser.GameObjects.Light#zNormal + * @type {number} + * @since 4.0.0 + */ + zNormal: { + get: function () + { + return this.z / this.radius; + }, + + set: function (value) + { + this.z = value * this.radius; + } + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.Light#willRender + * @since 3.50.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + return !(Light.RENDER_MASK !== this.renderFlags || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Set the color of the light from a single integer RGB value. + * + * @method Phaser.GameObjects.Light#setColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the light. + * + * @return {this} This Light object. + */ + setColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.color.set(color[0], color[1], color[2]); + + return this; + }, + + /** + * Set the intensity of the light. This scales the overall brightness of the light effect. + * A value of 1 is considered normal brightness. Higher values produce a stronger, brighter light. + * + * @method Phaser.GameObjects.Light#setIntensity + * @since 3.0.0 + * + * @param {number} intensity - The intensity (brightness multiplier) of the light. + * + * @return {this} This Light object. + */ + setIntensity: function (intensity) + { + this.intensity = intensity; + + return this; + }, + + /** + * Set the radius of the light, in pixels. This defines the circular area of influence + * within which lit Game Objects will be affected by this light. + * + * @method Phaser.GameObjects.Light#setRadius + * @since 3.0.0 + * + * @param {number} radius - The radius of the light, in pixels. + * + * @return {this} This Light object. + */ + setRadius: function (radius) + { + this.radius = radius; + + return this; + }, + + /** + * Set the z position of the light. This controls the perceived height of the light above + * the scene, which influences the relief (normal-map shading) effect. Larger values make + * the light appear more elevated. Lit Game Objects are considered to be at z=0, so if z + * exceeds the light's radius the light will not affect them. Strong values are in the + * range of 0 to radius/2. + * + * @method Phaser.GameObjects.Light#setZ + * @since 4.0.0 + * + * @param {number} z - The z position of the light, where 0 is at the same level as lit Game Objects. + * + * @return {this} This Light object. + */ + setZ: function (z) + { + this.z = z; + + return this; + }, + + /** + * Set the z position of the light as a fraction of the radius. + * This affects the relief effect created by the light. + * A higher value will make the light appear more raised. + * Strong values are in the range of 0 to 0.5. + * + * @method Phaser.GameObjects.Light#setZNormal + * @since 4.0.0 + * + * @param {number} z - The normalized z position of the light. + * + * @return {this} This Light object. + */ + setZNormal: function (z) + { + this.z = z * this.radius; + + return this; + }, + + /** + * Restrict this Light to a cone, suitable for flashlights, lanterns and other focal lights. + * + * The `rotation` is in radians, where 0 points to the right in world space. The `innerAngle` + * is the fully-lit cone width. The `outerAngle` is the wider falloff cone width; if omitted, + * the cone has a hard edge. Both angles are full cone widths, not half-angles. + * + * @method Phaser.GameObjects.Light#setCone + * @since 4.2.0 + * + * @param {number} rotation - The direction of the cone, in radians. + * @param {number} innerAngle - The fully-lit cone width, in radians. + * @param {number} [outerAngle=innerAngle] - The outer falloff cone width, in radians. + * + * @return {this} This Light object. + */ + setCone: function (rotation, innerAngle, outerAngle) + { + if (outerAngle === undefined) { outerAngle = innerAngle; } + + innerAngle = Math.max(0, Math.min(Math.PI * 2, innerAngle)); + outerAngle = Math.max(0, Math.min(Math.PI * 2, outerAngle)); + + if (outerAngle < innerAngle) + { + outerAngle = innerAngle; + } + + this.coneEnabled = true; + this.coneRotation = rotation; + this.coneInnerAngle = innerAngle; + this.coneOuterAngle = outerAngle; + + return this; + }, + + /** + * Set the direction of this Light cone, in radians. + * + * @method Phaser.GameObjects.Light#setConeRotation + * @since 4.2.0 + * + * @param {number} rotation - The direction of the cone, in radians. + * + * @return {this} This Light object. + */ + setConeRotation: function (rotation) + { + this.coneRotation = rotation; + + return this; + }, + + /** + * Set the inner and outer cone angles, in radians. + * + * @method Phaser.GameObjects.Light#setConeAngles + * @since 4.2.0 + * + * @param {number} innerAngle - The fully-lit cone width, in radians. + * @param {number} [outerAngle=innerAngle] - The outer falloff cone width, in radians. + * + * @return {this} This Light object. + */ + setConeAngles: function (innerAngle, outerAngle) + { + if (outerAngle === undefined) { outerAngle = innerAngle; } + + innerAngle = Math.max(0, Math.min(Math.PI * 2, innerAngle)); + outerAngle = Math.max(0, Math.min(Math.PI * 2, outerAngle)); + + if (outerAngle < innerAngle) + { + outerAngle = innerAngle; + } + + this.coneInnerAngle = innerAngle; + this.coneOuterAngle = outerAngle; + + return this; + }, + + /** + * Disable cone limiting and make this Light omnidirectional again. + * + * @method Phaser.GameObjects.Light#disableCone + * @since 4.2.0 + * + * @return {this} This Light object. + */ + disableCone: function () + { + this.coneEnabled = false; + + return this; + } + +}); + +/** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * + * @constant {number} RENDER_MASK + * @memberof Phaser.GameObjects.Light + * @default + */ +Light.RENDER_MASK = 15; + +module.exports = Light; + + +/***/ }, + +/***/ 61356 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CircleToRectangle = __webpack_require__(81491); +var Class = __webpack_require__(83419); +var DistanceBetween = __webpack_require__(20339); +var Light = __webpack_require__(41432); +var PointLight = __webpack_require__(80321); +var RGB = __webpack_require__(51767); +var SpliceOne = __webpack_require__(19133); +var StableSort = __webpack_require__(19186); +var Utils = __webpack_require__(70554); + +/** + * @callback LightForEach + * + * @param {Phaser.GameObjects.Light} light - The Light. + */ + +/** + * @classdesc + * The Lights Manager is responsible for managing all of the {@link Phaser.GameObjects.Light} objects + * in a Scene, as well as the ambient light color that applies to all lit Game Objects. + * + * It is created automatically by the Scene Systems and is accessed via `this.lights` within a Scene. + * To use the lighting system, call `this.lights.enable()` and ensure that any Game Objects you want + * to be affected by lighting have `setLighting(true)` applied to them. + * + * The Lights Manager works in conjunction with the Light Filter (WebGL only). Game Objects rendered + * with this filter sample the active lights and the ambient color, and use any normal maps assigned + * to their textures to produce a dynamic lighting effect. Lighting has no effect in Canvas rendering. + * + * Each Scene supports a fixed maximum number of simultaneous lights, set via the `maxLights` property + * in the game config. When more lights exist than the maximum, the manager culls the furthest lights + * from the camera each frame. Use {@link Phaser.GameObjects.LightsManager#addLight} to create a + * Light and {@link Phaser.GameObjects.LightsManager#setAmbientColor} to control the base illumination. + * + * @class LightsManager + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + */ +var LightsManager = new Class({ + + initialize: + + function LightsManager () + { + /** + * The Lights in the Scene. + * + * @name Phaser.GameObjects.LightsManager#lights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lights = []; + + /** + * The ambient color. + * + * @name Phaser.GameObjects.LightsManager#ambientColor + * @type {Phaser.Display.RGB} + * @since 3.50.0 + */ + this.ambientColor = new RGB(0.1, 0.1, 0.1); + + /** + * Whether the Lights Manager is enabled. + * + * @name Phaser.GameObjects.LightsManager#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + * + * @name Phaser.GameObjects.LightsManager#maxLights + * @type {number} + * @readonly + * @since 3.15.0 + */ + this.maxLights = -1; + + /** + * The number of lights processed in the _previous_ frame. + * + * @name Phaser.GameObjects.LightsManager#visibleLights + * @type {number} + * @readonly + * @since 3.50.0 + */ + this.visibleLights = 0; + }, + + /** + * Creates a new Point Light Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * + * The Point Light Game Object provides a way to add a point light effect into your game, + * without the expensive shader processing requirements of the traditional Light Game Object. + * + * The difference is that the Point Light renders using a custom shader, designed to give the + * impression of a point light source, of variable radius, intensity and color, in your game. + * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their + * normal maps for calculations. This makes them extremely fast to render compared to Lights + * and perfect for special effects, such as flickering torches or muzzle flashes. + * + * For maximum performance you should batch Point Light Game Objects together. This means + * ensuring they follow each other consecutively on the display list. Ideally, use a Layer + * Game Object and then add just Point Lights to it, so that it can batch together the rendering + * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in + * your game then it's perfectly safe to mix them into the display list as normal. However, if + * you're using a large number of them, please consider how they are mixed into the display list. + * + * The renderer will automatically cull Point Lights. Those with a radius that does not intersect + * with the Camera will be skipped in the rendering list. This happens automatically and the + * culled state is refreshed every frame, for every camera. + * + * The origin of a Point Light is always 0.5 and it cannot be changed. + * + * Point Lights are a WebGL only feature and do not have a Canvas counterpart. + * + * @method Phaser.GameObjects.LightsManager#addPointLight + * @since 3.50.0 + * + * @param {number} x - The horizontal position of this Point Light in the world. + * @param {number} y - The vertical position of this Point Light in the world. + * @param {number} [color=0xffffff] - The color of the Point Light, given as a hex value. + * @param {number} [radius=128] - The radius of the Point Light. + * @param {number} [intensity=1] - The intensity, or color blend, of the Point Light. + * @param {number} [attenuation=0.1] - The attenuation of the Point Light. This is the reduction of light from the center point. + * + * @return {Phaser.GameObjects.PointLight} The Game Object that was created. + */ + addPointLight: function (x, y, color, radius, intensity, attenuation) + { + return this.systems.displayList.add(new PointLight(this.scene, x, y, color, radius, intensity, attenuation)); + }, + + /** + * Enable the Lights Manager. This activates the lighting system for the Scene, causing all + * Game Objects using the Light Filter to be affected by the configured lights and ambient + * color. On first enable, the `maxLights` value is read from the renderer configuration. + * + * @method Phaser.GameObjects.LightsManager#enable + * @since 3.0.0 + * + * @return {this} This Lights Manager instance. + */ + enable: function () + { + if (this.maxLights === -1) + { + this.maxLights = this.systems.renderer.config.maxLights; + } + + this.active = true; + + return this; + }, + + /** + * Disable the Lights Manager. When disabled, the lighting system no longer affects the rendering + * of Game Objects using the Light Filter, effectively switching them back to unlit rendering. + * The existing lights and ambient color are preserved and will take effect again if the manager + * is re-enabled. + * + * @method Phaser.GameObjects.LightsManager#disable + * @since 3.0.0 + * + * @return {this} This Lights Manager instance. + */ + disable: function () + { + this.active = false; + + return this; + }, + + /** + * Get all lights that can be seen by the given Camera. + * + * It will automatically cull lights that are outside the world view of the Camera. + * + * If more lights are returned than supported by the renderer, the lights are then culled + * based on the distance from the center of the camera. Only those closest are rendered. + * + * @method Phaser.GameObjects.LightsManager#getLights + * @since 3.50.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to cull Lights for. + * + * @return {Phaser.GameObjects.Light[]} The culled Lights. + */ + getLights: function (camera) + { + var lights = this.lights; + var worldView = camera.worldView; + + var visibleLights = []; + + for (var i = 0; i < lights.length; i++) + { + var light = lights[i]; + + if (light.willRender(camera) && CircleToRectangle(light, worldView)) + { + visibleLights.push({ + light: light, + distance: DistanceBetween(light.x, light.y, worldView.centerX, worldView.centerY) + }); + } + } + + if (visibleLights.length > this.maxLights) + { + // We've got too many lights, so sort by distance from camera and cull those far away + // This isn't ideal because it doesn't factor in the radius of the lights, but it'll do for now + // and is significantly better than we had before! + + StableSort(visibleLights, this.sortByDistance); + + visibleLights = visibleLights.slice(0, this.maxLights); + } + + this.visibleLights = visibleLights.length; + + return visibleLights; + }, + + /** + * Sort function to sort lights by distance from the camera. + * The sort is in reverse order, so that the furthest light is culled first. + * + * @method Phaser.GameObjects.LightsManager#sortByDistance + * @since 4.0.0 + * + * @param {number} a - A light entry object with a `distance` property representing its distance from the camera center. + * @param {number} b - A light entry object with a `distance` property representing its distance from the camera center. + * @return {boolean} True if `a` is further than `b`, otherwise false. + */ + sortByDistance: function (a, b) + { + return (a.distance >= b.distance); + }, + + /** + * Set the ambient light color. + * + * @method Phaser.GameObjects.LightsManager#setAmbientColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the ambient light. + * + * @return {this} This Lights Manager instance. + */ + setAmbientColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.ambientColor.set(color[0], color[1], color[2]); + + return this; + }, + + /** + * Returns the maximum number of Lights allowed to appear at once. + * + * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights + * @since 3.0.0 + * + * @return {number} The maximum number of Lights allowed to appear at once. + */ + getMaxVisibleLights: function () + { + return this.maxLights; + }, + + /** + * Get the number of Lights managed by this Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#getLightCount + * @since 3.0.0 + * + * @return {number} The number of Lights managed by this Lights Manager. + */ + getLightCount: function () + { + return this.lights.length; + }, + + /** + * Creates a new {@link Phaser.GameObjects.Light} object, adds it to this Lights Manager, and returns it. + * The Light will influence all Game Objects using the Light Filter that are within its radius, + * using the texture's normal map data to compute shading. You can configure its position, radius, + * color, intensity, and z-height (which affects the angle of the shading effect). + * + * @method Phaser.GameObjects.LightsManager#addLight + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal position of the Light. + * @param {number} [y=0] - The vertical position of the Light. + * @param {number} [radius=128] - The radius of the Light. + * @param {number} [rgb=0xffffff] - The integer RGB color of the light. + * @param {number} [intensity=1] - The intensity of the Light. + * @param {number} [z] - The z position of the light. If omitted, it will be set to `radius * 0.1`. + * + * @return {Phaser.GameObjects.Light} The Light that was added. + */ + addLight: function (x, y, radius, rgb, intensity, z) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 128; } + if (rgb === undefined) { rgb = 0xffffff; } + if (intensity === undefined) { intensity = 1; } + if (z === undefined) { z = radius * 0.1; } + + var color = Utils.getFloatsFromUintRGB(rgb); + + var light = new Light(x, y, radius, color[0], color[1], color[2], intensity, z); + + this.lights.push(light); + + return light; + }, + + /** + * Creates a new cone-limited {@link Phaser.GameObjects.Light} object, adds it to this Lights Manager, + * and returns it. + * + * The cone angles are full cone widths in radians. Fragments inside `innerAngle` receive full light, + * and fragments between `innerAngle` and `outerAngle` are softly attenuated. + * + * @method Phaser.GameObjects.LightsManager#addConeLight + * @since 4.2.0 + * + * @param {number} [x=0] - The horizontal position of the Light. + * @param {number} [y=0] - The vertical position of the Light. + * @param {number} [radius=128] - The radius of the Light. + * @param {number} [rgb=0xffffff] - The integer RGB color of the light. + * @param {number} [intensity=1] - The intensity of the Light. + * @param {number} [rotation=0] - The direction of the cone, in radians. + * @param {number} [innerAngle=Math.PI / 4] - The fully-lit cone width, in radians. + * @param {number} [outerAngle=innerAngle] - The outer falloff cone width, in radians. + * @param {number} [z] - The z position of the light. If omitted, it will be set to `radius * 0.1`. + * + * @return {Phaser.GameObjects.Light} The Light that was added. + */ + addConeLight: function (x, y, radius, rgb, intensity, rotation, innerAngle, outerAngle, z) + { + if (rotation === undefined) { rotation = 0; } + if (innerAngle === undefined) { innerAngle = Math.PI / 4; } + + return this.addLight(x, y, radius, rgb, intensity, z).setCone(rotation, innerAngle, outerAngle); + }, + + /** + * Removes a {@link Phaser.GameObjects.Light} from this Lights Manager. The Light will no longer + * influence the rendering of any Game Objects. The Light object itself is not destroyed; it is + * simply removed from the manager's active list. + * + * @method Phaser.GameObjects.LightsManager#removeLight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Light} light - The Light to remove. + * + * @return {this} This Lights Manager instance. + */ + removeLight: function (light) + { + var index = this.lights.indexOf(light); + + if (index >= 0) + { + SpliceOne(this.lights, index); + } + + return this; + }, + + /** + * Shuts down the Lights Manager and clears all active Lights. This is called automatically + * when a Scene shuts down. The Lights Manager can be re-enabled afterwards by calling + * {@link Phaser.GameObjects.LightsManager#enable}. + * + * @method Phaser.GameObjects.LightsManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.lights.length = 0; + }, + + /** + * Destroy the Lights Manager. + * + * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. + * + * @method Phaser.GameObjects.LightsManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = LightsManager; + + +/***/ }, + +/***/ 88992 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var LightsManager = __webpack_require__(61356); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); + +/** + * @classdesc + * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for rendering objects with dynamic lighting. + * + * Available from within a Scene via `this.lights`. + * + * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * + * ```javascript + * // Enable the Lights Manager because it is disabled by default + * this.lights.enable(); + * + * // Create a Light at [400, 300] with a radius of 200 + * this.lights.addLight(400, 300, 200); + * ``` + * + * For Game Objects to be affected by the Lights when rendered, you will need to set them to use lighting like so: + * + * ```javascript + * sprite.setLighting(true); + * ``` + * + * @class LightsPlugin + * @extends Phaser.GameObjects.LightsManager + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this Lights Plugin belongs to. + */ +var LightsPlugin = new Class({ + + Extends: LightsManager, + + initialize: + + function LightsPlugin (scene) + { + /** + * A reference to the Scene that this Lights Plugin belongs to. + * + * @name Phaser.GameObjects.LightsPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene's systems. + * + * @name Phaser.GameObjects.LightsPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + } + + LightsManager.call(this); + }, + + /** + * Handles the boot event from the Scene's Event Emitter, subscribing to + * the Scene's `shutdown` and `destroy` events so the plugin can clean up + * its resources when the Scene is stopped or destroyed. + * + * @method Phaser.GameObjects.LightsPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on(SceneEvents.SHUTDOWN, this.shutdown, this); + eventEmitter.on(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * Destroy the Lights Plugin. + * + * Cleans up all references. + * + * @method Phaser.GameObjects.LightsPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = undefined; + this.systems = undefined; + } + +}); + +PluginCache.register('LightsPlugin', LightsPlugin, 'lights'); + +module.exports = LightsPlugin; + + +/***/ }, + +/***/ 76435 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var TintModes = __webpack_require__(84322); +var DefaultMesh2DNodes = __webpack_require__(2389); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var Mesh2DRender = __webpack_require__(63635); + +/** + * @classdesc + * A Mesh2D Game Object. + * + * A Mesh2D Game Object is used for the display of 2D meshes. + * It is a WebGL only Game Object. + * It contains a number of textured triangles. + * Each triangle is defined by a set of three vertices, + * with a position and texture coordinate; and a reference to a texture. + * + * Because the triangles define their own texture coordinates, + * Mesh2D does not directly use frame data from the texture. + * You should set up your own texture coordinates, + * either by hand or using a texture atlas. + * + * The Mesh2D game object can batch together with quads from game objects + * like Image, Sprite, and Text. + * It supports several rendering strategies, and it's important to use the correct one. + * + * By default, it does not combine triangles into quads. + * Each triangle is rendered as a single quad. + * This is inefficient, so consider switching to one of the other strategies. + * + * Use the `buildOrderedIndices` method to precompute an optimized index list, + * which arranges triangles into quad-forming pairs, + * synthesizing degenerate triangles where a triangle has no edge-sharing partner. + * You choose the optimization strategy (`0` fast, `1` medium, `2` high), paying the cost once when the topology is stable. + * Use `useOrderedIndices` (and `setUseOrderedIndices`) to toggle between the ordered and unordered lists without rebuilding. + * This strategy is best for static topology, where the triangles do not change. + * (The vertices can change, but the triangles do not.) + * + * Use the `renderAsTriangles` method to render the mesh as individual triangles. + * This is suitable for dynamic topology that cannot be optimized into quads ahead of time. + * However, it uses a separate render node designed for textured triangles, + * so it doesn't batch with quads. + * This strategy is best for dynamic topology, where the arrangement of + * triangles itself changes frequently. + * + * Prefer the ordered index list strategy where possible. + * It needs to do less work at render time. + * + * If you can guarantee that the index list is already ordered, + * you can set `useOrderedIndices` to `true` and generate `indicesOrdered` yourself. + * + * Mesh2D supports lighting. You should be careful not to distort + * the mesh too far, or normal maps will look weird. + * In particular, rotating texture coordinates will rotate the apparent light + * direction. + * + * This is intended to be used as a base for dealing with 2D meshes. + * + * @class Mesh2D + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @webglonly + * @constructor + * @since 4.2.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {number[]} vertices - The vertices of the mesh. Each vertex is a sequence within the array: x, y, u, v. The array has a step of 4. + * @param {number[]} indices - The indices of the mesh. Each index is a sequence: a, b, c, page. The abc values index to vertices in the vertices array. The page value is the index of the texture source in the texture atlas to use for this triangle. Typically 0. The array has a step of 4. + * @param {boolean} [flipV=false] - Whether to flip the texture coordinates vertically. This affects texture coordinates, not the vertices. Set this property if your geometry provides texture coordinates that are opposite to GL texture expectations (which are bottom-up). + */ +var Mesh2D = new Class({ + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Lighting, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.TextureCrop, + Components.Transform, + Components.Visible, + Mesh2DRender + ], + + initialize: function Mesh2D(scene, x, y, texture, vertices, indices, flipV) { + GameObject.call(this, scene, 'Mesh2D'); + + this.setTexture(texture); + this.setPosition(x, y); + this.initRenderNodes(this._defaultRenderNodesMap); + + /** + * The vertices of the mesh. + * Each vertex is a sequence within the array: + * x, y, u, v. + * The array has a step of 4. + * + * - x (offset 0): The x position of the vertex. + * - y (offset 1): The y position of the vertex. + * - u (offset 2): The u texture coordinate of the vertex. + * - v (offset 3): The v texture coordinate of the vertex. + * + * @name Phaser.GameObjects.Mesh2D#vertices + * @type {number[]} + * @since 4.2.0 + */ + this.vertices = vertices; + + /** + * The indices of the mesh. + * Each index is a sequence: a, b, c, page. + * These index to vertices in the vertices array. + * The array has a step of 4. + * + * - a (offset 0): The index of the first vertex. + * - b (offset 1): The index of the second vertex. + * - c (offset 2): The index of the third vertex. + * - page (offset 3): The page of the triangle: which texture source + * in the texture atlas is used for this triangle. Typically 0. + * + * @name Phaser.GameObjects.Mesh2D#indices + * @type {number[]} + * @since 4.2.0 + */ + this.indices = indices; + + /** + * An optimized copy of the `indices` list, built by + * `buildOrderedIndices`. It uses the same internal pattern as + * `indices` (a sequence of `a, b, c, page` with a step of 4), but it + * may be longer, because it can contain synthesized degenerate + * triangles which pad single triangles out to complete quads. + * + * Triangles in this list are arranged in pairs. Each pair is intended + * to be consumed as a single quad: the first triangle is `p, q, r` and + * the second is `q, r, s`, where `q, r` is the shared edge, and `p, s` + * are the corners unique to each triangle. When a triangle has no + * partner, `s` repeats `r` to form a degenerate second triangle. + * + * This is `null` until `buildOrderedIndices` is called. Use + * `useOrderedIndices` to control whether it is used. + * + * @name Phaser.GameObjects.Mesh2D#indicesOrdered + * @type {?number[]} + * @since 4.2.0 + * @default null + */ + this.indicesOrdered = null; + + /** + * Whether to use `indicesOrdered` instead of `indices` when rendering. + * + * This has no effect unless `indicesOrdered` has been populated by + * `buildOrderedIndices`. It is safe to toggle at any time, allowing you + * to switch between the ordered and unordered lists without rebuilding. + * + * @name Phaser.GameObjects.Mesh2D#useOrderedIndices + * @type {boolean} + * @since 4.2.0 + * @default false + */ + this.useOrderedIndices = false; + + /** + * Whether to render this mesh as individual triangles, rather than + * combining triangles into quads. + * + * When `true`, the renderer routes the mesh to a batch handler + * optimized for individual triangles (`gl.TRIANGLES`). This is suitable + * for dynamic topology which cannot be optimized into quads ahead of + * time. When `false`, the mesh is rendered as quads, which batches with + * regular sprites. + * + * @name Phaser.GameObjects.Mesh2D#renderAsTriangles + * @type {boolean} + * @since 4.2.0 + * @default false + */ + this.renderAsTriangles = false; + + /** + * Whether to flip the texture coordinates vertically. + * + * This affects texture coordinates, not the vertices. + * Set this property if your geometry provides texture coordinates + * that are opposite to GL texture expectations (which are bottom-up). + * + * @name Phaser.GameObjects.Mesh2D#flipV + * @type {boolean} + * @since 4.2.0 + * @default false + */ + this.flipV = !!flipV; + + this.tintMode = TintModes.MULTIPLY; + this.tint = 0xffffff; + this.tint2 = 0x000000; + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Mesh2D#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.2.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultMesh2DNodes; + } + }, + + clearTint: function () + { + this.tintMode = TintModes.MULTIPLY; + this.tint = 0xffffff; + this.tint2 = 0x000000; + return this; + }, + + setTint: function (color) + { + this.tint = color; + return this; + }, + + setTint2: function (color) + { + this.tint2 = color; + return this; + }, + + setTintMode: function (mode) + { + this.tintMode = mode; + return this; + }, + + isTinted: function () + { + return this.tint !== 0xffffff || this.tint2 !== 0x000000 || this.tintMode !== TintModes.MULTIPLY; + }, + + /** + * Sets the vertical texture flip state of this Game Object. + * + * @param {boolean} [value=false] - Whether to flip the texture coordinates vertically. + * @returns {this} This Game Object instance. + */ + setFlipV: function (value) + { + this.flipV = !!value; + return this; + }, + + /** + * Sets whether to use `indicesOrdered` instead of `indices` when rendering. + * + * This has no side effects other than setting the property. It does not + * rebuild `indicesOrdered`, so you may toggle freely between the ordered + * and unordered lists. Call `buildOrderedIndices` to populate the ordered + * list. + * + * @method Phaser.GameObjects.Mesh2D#setUseOrderedIndices + * @since 4.2.0 + * @param {boolean} [value=false] - Whether to use the ordered index list. + * @returns {this} This Game Object instance. + */ + setUseOrderedIndices: function (value) + { + this.useOrderedIndices = !!value; + return this; + }, + + /** + * Sets whether to render this mesh as individual triangles. + * + * @method Phaser.GameObjects.Mesh2D#setRenderAsTriangles + * @since 4.2.0 + * @param {boolean} [value=false] - Whether to render the mesh as individual triangles. + * @returns {this} This Game Object instance. + */ + setRenderAsTriangles: function (value) + { + this.renderAsTriangles = !!value; + return this; + }, + + /** + * Builds `indicesOrdered`, an optimized copy of `indices` in which + * triangles are arranged into quad-forming pairs. Each pair consists of + * two triangles `p, q, r` and `q, r, s`: where two triangles share an edge, + * `q, r` is that shared edge and `p, s` are their unique corners; where a + * triangle has no partner, the second triangle of the pair is degenerate + * (`s` repeats `r`), padding the single triangle out to a full quad. + * + * Because this processes the entire `indices` list, you should only call + * it when the topology is stable. The cost depends on the chosen strategy. + * + * @method Phaser.GameObjects.Mesh2D#buildOrderedIndices + * @since 4.2.0 + * @param {number} [strategy=0] - The level of optimization to use. + * + * - `0`: Fast. Each triangle forms its own quad with a synthesized + * degenerate triangle. No edge sharing is detected. This is quick to + * build but the least memory efficient at render time. + * - `1`: Medium. Each triangle checks only the next triangle for a shared + * edge, forming a quad if one is found, otherwise padding with a + * degenerate triangle. + * - `2`: High. Every triangle is checked against every other triangle for a + * shared edge, using an edge lookup to keep this tractable. This is the + * slowest to build but the most memory efficient at render time. + * @param {boolean} [useOrderedIndices] - If defined, also sets the `useOrderedIndices` property. + * @returns {this} This Game Object instance. + */ + buildOrderedIndices: function (strategy, useOrderedIndices) + { + if (strategy === undefined) { strategy = 0; } + + if (useOrderedIndices !== undefined) + { + this.useOrderedIndices = !!useOrderedIndices; + } + + var indices = this.indices; + var triCount = (indices.length / 4) | 0; + + // The multiplier used to canonicalize an edge into a single numeric + // key. It must exceed the largest vertex index, so we use the vertex + // count. + var vCount = (this.vertices.length / 4) | 0; + + // The output list, built up below. + var ordered = []; + + if (strategy === 1) + { + this._buildOrderedIndicesNext(indices, triCount, vCount, ordered); + } + else if (strategy === 2) + { + this._buildOrderedIndicesAll(indices, triCount, vCount, ordered); + } + else + { + this._buildOrderedIndicesFast(indices, triCount, ordered); + } + + this.indicesOrdered = ordered; + + return this; + }, + + /** + * Strategy 0: each triangle becomes its own quad, padded by a degenerate + * triangle. No edge detection is performed. + * + * @method Phaser.GameObjects.Mesh2D#_buildOrderedIndicesFast + * @since 4.2.0 + * @private + * @param {number[]} indices - The source index list. + * @param {number} triCount - The number of triangles in the source list. + * @param {number[]} ordered - The output list to populate. + */ + _buildOrderedIndicesFast: function (indices, triCount, ordered) + { + for (var i = 0; i < triCount; i++) + { + var i4 = i * 4; + this._pushDegenerateQuad( + ordered, + indices[i4], + indices[i4 + 1], + indices[i4 + 2], + indices[i4 + 3] + ); + } + }, + + /** + * Strategy 1: each unconsumed triangle checks only the immediately + * following triangle for a shared edge. Matching triangles form a quad; + * otherwise the triangle is padded with a degenerate triangle. + * + * @method Phaser.GameObjects.Mesh2D#_buildOrderedIndicesNext + * @since 4.2.0 + * @private + * @param {number[]} indices - The source index list. + * @param {number} triCount - The number of triangles in the source list. + * @param {number} vCount - The vertex count, used to canonicalize edges. + * @param {number[]} ordered - The output list to populate. + */ + _buildOrderedIndicesNext: function (indices, triCount, vCount, ordered) + { + for (var i = 0; i < triCount; i++) + { + var i4 = i * 4; + var a = indices[i4]; + var b = indices[i4 + 1]; + var c = indices[i4 + 2]; + var page = indices[i4 + 3]; + + var paired = false; + var j = i + 1; + + if (j < triCount) + { + var j4 = j * 4; + + if (page === indices[j4 + 3]) + { + var quad = this._sharedEdgeQuad( + a, b, c, + indices[j4], indices[j4 + 1], indices[j4 + 2], + vCount + ); + + if (quad) + { + this._pushQuad(ordered, quad[0], quad[1], quad[2], quad[3], page); + + // Skip the consumed partner. + i = j; + paired = true; + } + } + } + + if (!paired) + { + this._pushDegenerateQuad(ordered, a, b, c, page); + } + } + }, + + /** + * Strategy 2: every triangle is matched against every other triangle using + * an edge lookup. Each unconsumed triangle greedily pairs with the first + * unconsumed triangle that shares an edge and texture page. + * + * @method Phaser.GameObjects.Mesh2D#_buildOrderedIndicesAll + * @since 4.2.0 + * @private + * @param {number[]} indices - The source index list. + * @param {number} triCount - The number of triangles in the source list. + * @param {number} vCount - The vertex count, used to canonicalize edges. + * @param {number[]} ordered - The output list to populate. + */ + _buildOrderedIndicesAll: function (indices, triCount, vCount, ordered) + { + // Map from a canonical edge key to the list of triangles which contain + // that edge. Each entry records the partner triangle, the texture page, + // and the vertex opposite the shared edge. + var edgeMap = {}; + + var i, i4, a, b, c, page; + + for (i = 0; i < triCount; i++) + { + i4 = i * 4; + a = indices[i4]; + b = indices[i4 + 1]; + c = indices[i4 + 2]; + page = indices[i4 + 3]; + + this._addEdge(edgeMap, a, b, c, i, page, vCount); + this._addEdge(edgeMap, b, c, a, i, page, vCount); + this._addEdge(edgeMap, c, a, b, i, page, vCount); + } + + var consumed = []; + + for (i = 0; i < triCount; i++) + { + if (consumed[i]) { continue; } + + i4 = i * 4; + a = indices[i4]; + b = indices[i4 + 1]; + c = indices[i4 + 2]; + page = indices[i4 + 3]; + + consumed[i] = true; + + // Each edge of this triangle, with the vertex opposite it. + var found = ( + this._matchEdge(edgeMap, consumed, ordered, i, a, b, c, page, vCount) || + this._matchEdge(edgeMap, consumed, ordered, i, b, c, a, page, vCount) || + this._matchEdge(edgeMap, consumed, ordered, i, c, a, b, page, vCount) + ); + + if (!found) + { + this._pushDegenerateQuad(ordered, a, b, c, page); + } + } + }, + + /** + * Adds a triangle edge to the edge lookup used by strategy 2. + * + * @method Phaser.GameObjects.Mesh2D#_addEdge + * @since 4.2.0 + * @private + * @param {object} edgeMap - The edge lookup to add to. + * @param {number} u - The first vertex of the edge. + * @param {number} v - The second vertex of the edge. + * @param {number} opp - The vertex opposite the edge. + * @param {number} tri - The index of the triangle that owns the edge. + * @param {number} page - The texture page of the triangle. + * @param {number} vCount - The vertex count, used to canonicalize the edge. + */ + _addEdge: function (edgeMap, u, v, opp, tri, page, vCount) + { + var key = (u < v) ? (u * vCount + v) : (v * vCount + u); + var list = edgeMap[key]; + if (!list) + { + list = edgeMap[key] = []; + } + list.push({ tri: tri, opp: opp, page: page }); + }, + + /** + * Attempts to pair triangle `tri` with another unconsumed triangle sharing + * the edge `q, r`. On success it appends a quad to the output list, marks + * the partner consumed, and returns `true`. + * + * @method Phaser.GameObjects.Mesh2D#_matchEdge + * @since 4.2.0 + * @private + * @param {object} edgeMap - The edge lookup to search. + * @param {boolean[]} consumed - The per-triangle consumed flags. + * @param {number[]} ordered - The output list to append a quad to. + * @param {number} tri - The index of the triangle seeking a partner. + * @param {number} p - The vertex of `tri` opposite the shared edge. + * @param {number} q - The first vertex of the shared edge. + * @param {number} r - The second vertex of the shared edge. + * @param {number} page - The texture page of `tri`. + * @param {number} vCount - The vertex count, used to canonicalize the edge. + * @returns {boolean} Whether a partner was found. + */ + _matchEdge: function (edgeMap, consumed, ordered, tri, p, q, r, page, vCount) + { + var key = (q < r) ? (q * vCount + r) : (r * vCount + q); + var list = edgeMap[key]; + if (!list) { return false; } + + for (var i = 0; i < list.length; i++) + { + var entry = list[i]; + if (entry.tri !== tri && !consumed[entry.tri] && entry.page === page) + { + consumed[entry.tri] = true; + this._pushQuad(ordered, p, q, r, entry.opp, page); + return true; + } + } + + return false; + }, + + /** + * Determines the quad formed by two triangles which share an edge, using + * canonical edge keys. Returns `[p, q, r, s]` where `q, r` is the shared + * edge, `p` is the corner unique to the first triangle, and `s` is the + * corner unique to the second. Returns `null` if the triangles do not share + * exactly one edge. + * + * @method Phaser.GameObjects.Mesh2D#_sharedEdgeQuad + * @since 4.2.0 + * @private + * @param {number} a - The first vertex of the first triangle. + * @param {number} b - The second vertex of the first triangle. + * @param {number} c - The third vertex of the first triangle. + * @param {number} d - The first vertex of the second triangle. + * @param {number} e - The second vertex of the second triangle. + * @param {number} f - The third vertex of the second triangle. + * @param {number} vCount - The vertex count, used to canonicalize edges. + * @returns {?number[]} The quad as `[p, q, r, s]`, or `null` if there is no shared edge. + */ + _sharedEdgeQuad: function (a, b, c, d, e, f, vCount) + { + // Canonical edge keys, with the vertex opposite each edge. + var e1 = [ + [ this._edgeKey(a, b, vCount), c, a, b ], + [ this._edgeKey(b, c, vCount), a, b, c ], + [ this._edgeKey(c, a, vCount), b, c, a ] + ]; + var e2 = [ + [ this._edgeKey(d, e, vCount), f ], + [ this._edgeKey(e, f, vCount), d ], + [ this._edgeKey(f, d, vCount), e ] + ]; + + for (var i = 0; i < 3; i++) + { + for (var j = 0; j < 3; j++) + { + if (e1[i][0] === e2[j][0]) + { + // p = first triangle's opposite corner, + // q, r = shared edge, s = second triangle's opposite corner. + return [ e1[i][1], e1[i][2], e1[i][3], e2[j][1] ]; + } + } + } + + return null; + }, + + /** + * Returns the canonical key for the edge between two vertices. + * + * @method Phaser.GameObjects.Mesh2D#_edgeKey + * @since 4.2.0 + * @private + * @param {number} u - The first vertex of the edge. + * @param {number} v - The second vertex of the edge. + * @param {number} vCount - The vertex count, used as the key multiplier. + * @returns {number} The canonical edge key. + */ + _edgeKey: function (u, v, vCount) + { + return (u < v) ? (u * vCount + v) : (v * vCount + u); + }, + + /** + * Appends a quad to the ordered index list as a pair of triangles + * `p, q, r` and `q, r, s`. + * + * @method Phaser.GameObjects.Mesh2D#_pushQuad + * @since 4.2.0 + * @private + * @param {number[]} ordered - The output list to append to. + * @param {number} p - The corner unique to the first triangle. + * @param {number} q - The first vertex of the shared edge. + * @param {number} r - The second vertex of the shared edge. + * @param {number} s - The corner unique to the second triangle. + * @param {number} page - The texture page shared by both triangles. + */ + _pushQuad: function (ordered, p, q, r, s, page) + { + ordered.push( + p, q, r, page, + q, r, s, page + ); + }, + + /** + * Appends a single triangle to the ordered index list, padded out to a quad + * with a degenerate second triangle. + * + * @method Phaser.GameObjects.Mesh2D#_pushDegenerateQuad + * @since 4.2.0 + * @private + * @param {number[]} ordered - The output list to append to. + * @param {number} a - The first vertex of the triangle. + * @param {number} b - The second vertex of the triangle. + * @param {number} c - The third vertex of the triangle. + * @param {number} page - The texture page of the triangle. + */ + _pushDegenerateQuad: function (ordered, a, b, c, page) + { + ordered.push( + a, b, c, page, + b, c, c, page + ); + } +}); + +module.exports = Mesh2D; + + +/***/ }, + +/***/ 2227 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Mesh2D = __webpack_require__(76435); + +/** + * Creates a new Mesh2D Game Object and returns it. + * + * Note: This method will only be available if the Mesh2D Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#mesh2d + * @since 4.2.0 + * + * @param {Phaser.Types.GameObjects.GameObjectConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Mesh2D} The Game Object that was created. + */ +GameObjectCreator.register('mesh2d', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var vertices = GetAdvancedValue(config, 'vertices', []); + var indices = GetAdvancedValue(config, 'indices', []); + var flipV = GetAdvancedValue(config, 'flipV', false); + + var mesh2d = new Mesh2D(this.scene, 0, 0, key, vertices, indices, flipV); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, mesh2d, config); + + return mesh2d; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 2317 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Mesh2D = __webpack_require__(76435); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Mesh2D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Mesh2D Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#mesh2d + * @since 4.2.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {number[]} vertices - The vertices of the mesh. + * @param {number[]} indices - The indices of the mesh. + * @param {boolean} [flipV=false] - Whether to flip the texture vertically. + * + * @return {Phaser.GameObjects.Mesh2D} The Game Object that was created. + */ +GameObjectFactory.register('mesh2d', function (x, y, texture, vertices, indices, flipV) +{ + return this.displayList.add(new Mesh2D(this.scene, x, y, texture, vertices, indices, flipV)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 63635 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = __webpack_require__(43909); +var renderCanvas = NOOP; + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 43909 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Image#renderWebGL + * @since 4.2.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Mesh2D} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var Mesh2DWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + drawingContext.camera.addToRenderList(src); + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + var transformerNode = customRenderNodes.Transformer || defaultRenderNodes.Transformer; + var submitterNode = customRenderNodes.Submitter || defaultRenderNodes.Submitter; + + if (src.renderAsTriangles) + { + // Render each triangle individually, rather than combining triangles + // into quads. Suitable for dynamic topology which cannot be optimized. + var triangleNode = customRenderNodes.BatchHandlerTriangles || defaultRenderNodes.BatchHandlerTriangles; + + // Resolve render options (lighting, smooth pixel art, etc.) using the + // submitter, then hand the raw vertex and index arrays to the triangle + // batch handler. + submitterNode.setRenderOptions(src); + + triangleNode.batchTriangles( + drawingContext, + src, + parentMatrix, + transformerNode, + src.vertices, + src.indices, + submitterNode._renderOptions + ); + + return; + } + + submitterNode.run( + drawingContext, + src, + parentMatrix, + transformerNode + ); +}; + +module.exports = Mesh2DWebGLRenderer; + + +/***/ }, + +/***/ 28103 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DefaultNineSliceNodes = __webpack_require__(30529); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var NineSliceRender = __webpack_require__(78023); +var TintModes = __webpack_require__(84322); +var Vertex = __webpack_require__(82513); + +/** + * @classdesc + * A Nine Slice Game Object allows you to display a texture-based object that + * can be stretched both horizontally and vertically, but that retains + * fixed-sized corners. The dimensions of the corners are set via the + * parameters to this class. + * + * This is extremely useful for UI and button like elements, where you need + * them to expand to accommodate the content without distorting the texture. + * + * The texture you provide for this Game Object should be based on the + * following layout structure: + * + * ``` + * A B + * +---+----------------------+---+ + * C | 1 | 2 | 3 | + * +---+----------------------+---+ + * | | | | + * | 4 | 5 | 6 | + * | | | | + * +---+----------------------+---+ + * D | 7 | 8 | 9 | + * +---+----------------------+---+ + * ``` + * + * When changing this objects width and / or height: + * + * areas 1, 3, 7 and 9 (the corners) will remain unscaled + * areas 2 and 8 will be stretched horizontally only + * areas 4 and 6 will be stretched vertically only + * area 5 will be stretched both horizontally and vertically + * + * You can also create a 3 slice Game Object: + * + * This works in a similar way, except you can only stretch it horizontally. + * Therefore, it requires less configuration: + * + * ``` + * A B + * +---+----------------------+---+ + * | | | | + * C | 1 | 2 | 3 | + * | | | | + * +---+----------------------+---+ + * ``` + * + * When changing this objects width (you cannot change its height) + * + * areas 1 and 3 will remain unscaled + * area 2 will be stretched horizontally + * + * The above configuration concept is adapted from the Pixi NineSlicePlane. + * + * To specify a 3 slice object instead of a 9 slice you should only + * provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice + * you must supply all parameters. + * + * The _minimum_ width this Game Object can be is the total of + * `leftWidth` + `rightWidth`. The _minimum_ height this Game Object + * can be is the total of `topHeight` + `bottomHeight`. + * If you need to display this object at a smaller size, you can scale it. + * + * In terms of performance, using a 3 slice Game Object is the equivalent of + * having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent + * of having 9 Sprites in a row. The vertices of this object are all batched + * together and can co-exist with other Sprites and graphics on the display + * list, without incurring any additional overhead. + * + * This Game Object can now populate its values automatically + * if they have been set within Texture Packer 7.1.0 or above and exported with + * the atlas json. If this is the case, you can just create this Game Object without + * specifying anything more than the texture key and frame and it will pull the + * area data from the atlas. + * + * This object does not support trimmed textures from Texture Packer. + * Trimming interferes with the ability to stretch the texture correctly. + * + * @class NineSlice + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.60.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of the center of this Game Object in the world. + * @param {number} y - The vertical position of the center of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {number} [width=256] - The width of the Nine Slice Game Object. You can adjust the width post-creation. + * @param {number} [height=256] - The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. + * @param {number} [leftWidth=10] - The size of the left vertical column (A). + * @param {number} [rightWidth=10] - The size of the right vertical column (B). + * @param {number} [topHeight=0] - The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. + * @param {number} [bottomHeight=0] - The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. + * @param {boolean} [tileX=false] - When enabled, the scalable horizontal regions are repeated across the object instead of being stretched. Each tile is still slightly stretched so that it remains visible in full, which may cause minor distortion but far less than pure stretching. The texture should be seamless to avoid visible artifacts between tiles. + * @param {boolean} [tileY=false] - When enabled, the scalable vertical regions are repeated across the object instead of being stretched. Each tile is still slightly stretched so that it remains visible in full, which may cause minor distortion but far less than pure stretching. The texture should be seamless to avoid visible artifacts between tiles. + */ +var NineSlice = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.Texture, + Components.Transform, + Components.Visible, + NineSliceRender + ], + + initialize: + + function NineSlice (scene, x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight, tileX, tileY) + { + // if (width === undefined) { width = 256; } + // if (height === undefined) { height = 256; } + + // if (leftWidth === undefined) { leftWidth = 10; } + // if (rightWidth === undefined) { rightWidth = 10; } + // if (topHeight === undefined) { topHeight = 0; } + // if (bottomHeight === undefined) { bottomHeight = 0; } + + GameObject.call(this, scene, 'NineSlice'); + + /** + * Internal width value. Do not modify this property directly. + * + * @name Phaser.GameObjects.NineSlice#_width + * @private + * @type {number} + * @since 3.60.0 + */ + this._width; + + /** + * Internal height value. Do not modify this property directly. + * + * @name Phaser.GameObjects.NineSlice#_height + * @private + * @type {number} + * @since 3.60.0 + */ + this._height; + + /** + * Internal originX value. Do not modify this property directly. + * + * @name Phaser.GameObjects.NineSlice#_originX + * @private + * @type {number} + * @since 3.60.0 + */ + this._originX = 0.5; + + /** + * Internal originY value. Do not modify this property directly. + * + * @name Phaser.GameObjects.NineSlice#_originY + * @private + * @type {number} + * @since 3.60.0 + */ + this._originY = 0.5; + + /** + * Internal component value. Do not modify this property directly. + * + * @name Phaser.GameObjects.NineSlice#_sizeComponent + * @private + * @type {boolean} + * @since 3.60.0 + */ + this._sizeComponent = true; + + /** + * An array of Vertex objects that correspond to the quads that make-up + * this Nine Slice Game Object. They are stored in the following order: + * + * Top Left - Indexes 0 - 5 + * Top Center - Indexes 6 - 11 + * Top Right - Indexes 12 - 17 + * Center Left - Indexes 18 - 23 + * Center - Indexes 24 - 29 + * Center Right - Indexes 30 - 35 + * Bottom Left - Indexes 36 - 41 + * Bottom Center - Indexes 42 - 47 + * Bottom Right - Indexes 48 - 53 + * + * Each quad is represented by 6 Vertex instances. + * + * This array will contain 18 elements for a 3 slice object + * and 54 for a nine slice object. + * + * You should never modify this array once it has been populated. + * + * @name Phaser.GameObjects.NineSlice#vertices + * @type {Phaser.GameObjects.NineSliceVertex[]} + * @since 3.60.0 + */ + this.vertices = []; + + /** + * The size of the left vertical bar (A). + * + * @name Phaser.GameObjects.NineSlice#leftWidth + * @type {number} + * @readonly + * @since 3.60.0 + */ + this.leftWidth; + + /** + * The size of the right vertical bar (B). + * + * @name Phaser.GameObjects.NineSlice#rightWidth + * @type {number} + * @readonly + * @since 3.60.0 + */ + this.rightWidth; + + /** + * The size of the top horizontal bar (C). + * + * If this is a 3 slice object this property will be set to the + * height of the texture being used. + * + * @name Phaser.GameObjects.NineSlice#topHeight + * @type {number} + * @readonly + * @since 3.60.0 + */ + this.topHeight; + + /** + * The size of the bottom horizontal bar (D). + * + * If this is a 3 slice object this property will be set to zero. + * + * @name Phaser.GameObjects.NineSlice#bottomHeight + * @type {number} + * @readonly + * @since 3.60.0 + */ + this.bottomHeight; + + /** + * Indicates whether the scalable horizontal regions of the Nine Slice + * are repeated across the object instead of being stretched. Each tile + * is still slightly stretched so that it remains visible in full. + * + * @name Phaser.GameObjects.NineSlice#tileX + * @type {boolean} + * @readonly + * @since 4.0.0 + */ + this.tileX = tileX || false; + + /** + * Indicates whether the scalable vertical regions of the Nine Slice + * are repeated across the object instead of being stretched. Each tile + * is still slightly stretched so that it remains visible in full. + * + * @name Phaser.GameObjects.NineSlice#tileY + * @type {boolean} + * @readonly + * @since 4.0.0 + */ + this.tileY = tileY || false; + + /** + * Internal horizontal repeat count. Do not modify directly. + * + * @name Phaser.GameObjects.NineSlice#_repeatCountX + * @private + * @type {number} + * @since 4.0.0 + */ + this._repeatCountX = 1; + + /** + * Internal vertical repeat count. Do not modify directly. + * + * @name Phaser.GameObjects.NineSlice#_repeatCountY + * @private + * @type {number} + * @since 4.0.0 + */ + this._repeatCountY = 1; + + /** + * The tint value being applied to the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @name Phaser.GameObjects.NineSlice#tint + * @type {number} + * @default 0xffffff + * @since 3.60.0 + */ + this.tint = 0xffffff; + + /** + * The tint mode to use when applying the tint to the texture. + * + * Available modes are: + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * + * @name Phaser.GameObjects.NineSlice#tintMode + * @type {Phaser.TintModes} + * @default Phaser.TintModes.MULTIPLY + * @since 4.0.0 + */ + this.tintMode = TintModes.MULTIPLY; + + var textureFrame = scene.textures.getFrame(texture, frame); + + /** + * This property is `true` if this Nine Slice Game Object was configured + * with just `leftWidth` and `rightWidth` values, making it a 3-slice + * instead of a 9-slice object. + * + * @name Phaser.GameObjects.NineSlice#is3Slice + * @type {boolean} + * @since 3.60.0 + */ + this.is3Slice = (!topHeight && !bottomHeight); + + if (textureFrame && textureFrame.scale9) + { + // If we're using the scale9 data from the frame, override the values from above + this.is3Slice = textureFrame.is3Slice; + } + + var size = this.is3Slice ? 18 : 54; + + for (var i = 0; i < size; i++) + { + this.vertices.push(new Vertex()); + } + + this.setPosition(x, y); + + this.setTexture(texture, frame); + + this.setSlices(width, height, leftWidth, rightWidth, topHeight, bottomHeight, false); + + this.updateDisplayOrigin(); + + this.initRenderNodes(this._defaultRenderNodesMap); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.NineSlice#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultNineSliceNodes; + } + }, + + /** + * Resets the width, height and slices for this NineSlice Game Object. + * + * This allows you to modify the texture being used by this object and then reset the slice configuration, + * to avoid having to destroy this Game Object in order to use it for a different game element. + * + * Please note that you cannot change a 9-slice to a 3-slice or vice versa. + * + * @method Phaser.GameObjects.NineSlice#setSlices + * @since 3.60.0 + * + * @param {number} [width=256] - The width of the Nine Slice Game Object. You can adjust the width post-creation. + * @param {number} [height=256] - The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. + * @param {number} [leftWidth=10] - The size of the left vertical column (A). + * @param {number} [rightWidth=10] - The size of the right vertical column (B). + * @param {number} [topHeight=0] - The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. + * @param {number} [bottomHeight=0] - The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. + * @param {boolean} [skipScale9=false] - If this Nine Slice was created from Texture Packer scale9 atlas data, set this property to use the given column sizes instead of those specified in the JSON. + * + * @return {this} This Game Object instance. + */ + setSlices: function (width, height, leftWidth, rightWidth, topHeight, bottomHeight, skipScale9) + { + if (leftWidth === undefined) { leftWidth = 10; } + if (rightWidth === undefined) { rightWidth = 10; } + if (topHeight === undefined) { topHeight = 0; } + if (bottomHeight === undefined) { bottomHeight = 0; } + + if (skipScale9 === undefined) { skipScale9 = false; } + + var frame = this.frame; + + var sliceChange = false; + + if (this.is3Slice && skipScale9 && topHeight !== 0 && bottomHeight !== 0) + { + sliceChange = true; + } + + if (sliceChange) + { + console.warn('Cannot change 9 slice to 3 slice'); + } + else + { + if (frame && frame.scale9 && !skipScale9) + { + var data = frame.data.scale9Borders; + + var x = data.x; + var y = data.y; + + leftWidth = x; + rightWidth = frame.width - data.w - x; + topHeight = y; + bottomHeight = frame.height - data.h - y; + + if (width === undefined) + { + width = frame.width; + } + + if (height === undefined) + { + height = frame.height; + } + } + else + { + if (width === undefined) { width = 256; } + if (height === undefined) { height = 256; } + } + + this._width = width; + this._height = height; + + this.leftWidth = leftWidth; + this.rightWidth = rightWidth; + this.topHeight = topHeight; + this.bottomHeight = bottomHeight; + + if (this.is3Slice) + { + height = frame.height; + + this._height = height; + this.topHeight = height; + this.bottomHeight = 0; + } + + this.updateVertices(); + this.updateUVs(); + } + + return this; + }, + + /** + * Updates all of the vertex UV coordinates. This is called automatically + * when the NineSlice Game Object is created, or if the texture frame changes. + * + * Unlike with the `updateVertices` method, you do not need to call this + * method if the Nine Slice changes size. Only if it changes texture frame. + * + * @method Phaser.GameObjects.NineSlice#updateUVs + * @since 3.60.0 + */ + updateUVs: function () + { + var left = this.leftWidth; + var right = this.rightWidth; + var top = this.topHeight; + var bot = this.bottomHeight; + + var width = this.frame.width; + var height = this.frame.height; + + var uL = left / width; + var uR = 1 - right / width; + var vT = top / height; + var vB = 1 - bot / height; + + var idx = 0; + + if (this.is3Slice) + { + this._updateUVRow(idx, uL, uR, 0, vT); + } + else + { + idx = this._updateUVRow(idx, uL, uR, 0, vT); + + for (var j = 0; j < this._repeatCountY; j++) + { + idx = this._updateUVRow(idx, uL, uR, vT, vB); + } + + this._updateUVRow(idx, uL, uR, vB, 1); + } + }, + + /** + * Emits UVs for one row: left cap, `_repeatCountX` tiled middles, right cap. + * + * @method Phaser.GameObjects.NineSlice#_updateUVRow + * @private + * @since 4.0.0 + * + * @param {number} idx - The starting vertex index. + * @param {number} uL - Middle tile U start. + * @param {number} uR - Middle tile U end. + * @param {number} vT - Row V top. + * @param {number} vB - Row V bottom. + * + * @return {number} The new vertex index after this row. + */ + _updateUVRow: function (idx, uL, uR, vT, vB) + { + this.updateQuadUVs(idx, 0, vT, uL, vB); + idx += 6; + + for (var i = 0; i < this._repeatCountX; i++) + { + this.updateQuadUVs(idx, uL, vT, uR, vB); + idx += 6; + } + + this.updateQuadUVs(idx, uR, vT, 1, vB); + idx += 6; + + return idx; + }, + + /** + * Recalculates all of the vertices in this Nine Slice Game Object + * based on the `leftWidth`, `rightWidth`, `topHeight`, `bottomHeight`, + * `tileX` and `tileY` properties, combined with the Game Object size. + * + * This method is called automatically when this object is created + * or if its origin is changed. + * + * You should not typically need to call this method directly, but it + * is left public should you find a need to modify one of those properties + * after creation. + * + * @method Phaser.GameObjects.NineSlice#updateVertices + * @since 3.60.0 + */ + updateVertices: function () + { + var left = this.leftWidth; + var right = this.rightWidth; + var top = this.topHeight; + var bot = this.bottomHeight; + + var width = this.width; + var height = this.height; + var frame = this.frame; + + var repeatCountX = this.tileX + ? this._calcRepeatCount(width - left - right, frame.width - left - right) + : 1; + + var repeatCountY = (this.tileY && !this.is3Slice) + ? this._calcRepeatCount(height - top - bot, frame.height - top - bot) + : 1; + + var needRebuild = this._rebuildVertexArray(repeatCountX, repeatCountY); + + // Key positions in normalized coordinates (-0.5 to 0.5) + var xL = -0.5; + var xML = -0.5 + left / width; + var xMR = 0.5 - right / width; + var xR = 0.5; + + var yT = 0.5; + var yMT = 0.5 - top / height; + + var tileWidth = (xMR - xML) / repeatCountX; + var idx = 0; + + if (this.is3Slice) + { + this._updateVertexRow(idx, xL, xML, xMR, xR, yT, yMT, tileWidth); + } + else + { + var yMB = -0.5 + bot / height; + var yB = -0.5; + var tileHeight = (yMT - yMB) / repeatCountY; + + idx = this._updateVertexRow(idx, xL, xML, xMR, xR, yT, yMT, tileWidth); + + for (var j = 0; j < repeatCountY; j++) + { + var rowTop = yMT - j * tileHeight; + var rowBot = yMT - (j + 1) * tileHeight; + + idx = this._updateVertexRow(idx, xL, xML, xMR, xR, rowTop, rowBot, tileWidth); + } + + this._updateVertexRow(idx, xL, xML, xMR, xR, yMB, yB, tileWidth); + } + + if (needRebuild) + { + this.updateUVs(); + } + }, + + /** + * Returns the number of tile repeats that fit in the given scalable + * region, or 1 if the original size is zero. + * + * @method Phaser.GameObjects.NineSlice#_calcRepeatCount + * @private + * @since 4.0.0 + * + * @param {number} scalableSize - The current scalable region size. + * @param {number} originalSize - The original (texture) scalable region size. + * + * @return {number} The repeat count (at least 1). + */ + _calcRepeatCount: function (scalableSize, originalSize) + { + if (originalSize > 0) + { + return Math.max(1, Math.floor(scalableSize / originalSize)); + } + + return 1; + }, + + /** + * Rebuilds the vertex array if the repeat counts have changed. + * Updates `_repeatCountX` and `_repeatCountY` and resizes `vertices`. + * + * @method Phaser.GameObjects.NineSlice#_rebuildVertexArray + * @private + * @since 4.0.0 + * + * @param {number} repeatCountX - Horizontal repeat count. + * @param {number} repeatCountY - Vertical repeat count. + * + * @return {boolean} `true` if the vertex array was rebuilt. + */ + _rebuildVertexArray: function (repeatCountX, repeatCountY) + { + if (repeatCountX === this._repeatCountX && repeatCountY === this._repeatCountY) + { + return false; + } + + this._repeatCountX = repeatCountX; + this._repeatCountY = repeatCountY; + + var rowCount = this.is3Slice ? 1 : (repeatCountY + 2); + var size = (repeatCountX + 2) * rowCount * 6; + var verts = this.vertices; + + if (verts.length !== size) + { + verts.length = 0; + + for (var k = 0; k < size; k++) + { + verts.push(new Vertex()); + } + } + + return true; + }, + + /** + * Emits vertex positions for one row: left cap quad, `_repeatCountX` + * tiled middle quads, right cap quad. + * + * @method Phaser.GameObjects.NineSlice#_updateVertexRow + * @private + * @since 4.0.0 + * + * @param {number} idx - The starting vertex index. + * @param {number} xL - Left edge X. + * @param {number} xML - Left middle edge X. + * @param {number} xMR - Right middle edge X. + * @param {number} xR - Right edge X. + * @param {number} yT - Row top Y. + * @param {number} yB - Row bottom Y. + * @param {number} tileWidth - Width of each middle tile. + * + * @return {number} The new vertex index after this row. + */ + _updateVertexRow: function (idx, xL, xML, xMR, xR, yT, yB, tileWidth) + { + this.updateQuad(idx, xL, yT, xML, yB); + idx += 6; + + for (var i = 0; i < this._repeatCountX; i++) + { + this.updateQuad(idx, xML + i * tileWidth, yT, xML + (i + 1) * tileWidth, yB); + idx += 6; + } + + this.updateQuad(idx, xMR, yT, xR, yB); + idx += 6; + + return idx; + }, + + /** + * Internally updates the position coordinates across all vertices of the + * given quad offset. + * + * You should not typically need to call this method directly, but it + * is left public should an extended class require it. + * + * @method Phaser.GameObjects.NineSlice#updateQuad + * @since 3.60.0 + * + * @param {number} offset - The offset in the vertices array of the quad to update. + * @param {number} x1 - The top-left X coordinate of the quad, in normalized space (-0.5 to 0.5). + * @param {number} y1 - The top-left Y coordinate of the quad, in normalized space (-0.5 to 0.5). + * @param {number} x2 - The bottom-right X coordinate of the quad, in normalized space (-0.5 to 0.5). + * @param {number} y2 - The bottom-right Y coordinate of the quad, in normalized space (-0.5 to 0.5). + */ + updateQuad: function (offset, x1, y1, x2, y2) + { + var width = this.width; + var height = this.height; + var originX = this.originX; + var originY = this.originY; + + var verts = this.vertices; + + verts[offset + 0].resize(x1, y1, width, height, originX, originY); + verts[offset + 1].resize(x1, y2, width, height, originX, originY); + verts[offset + 2].resize(x2, y1, width, height, originX, originY); + verts[offset + 3].resize(x1, y2, width, height, originX, originY); + verts[offset + 4].resize(x2, y2, width, height, originX, originY); + verts[offset + 5].resize(x2, y1, width, height, originX, originY); + }, + + /** + * Internally updates the UV coordinates across all vertices of the + * given quad offset, based on the frame size. + * + * You should not typically need to call this method directly, but it + * is left public should an extended class require it. + * + * @method Phaser.GameObjects.NineSlice#updateQuadUVs + * @since 3.60.0 + * + * @param {number} offset - The offset in the vertices array of the quad to update. + * @param {number} u1 - The top-left U coordinate of the quad, in the range 0 to 1. + * @param {number} v1 - The top-left V coordinate of the quad, in the range 0 to 1. + * @param {number} u2 - The bottom-right U coordinate of the quad, in the range 0 to 1. + * @param {number} v2 - The bottom-right V coordinate of the quad, in the range 0 to 1. + */ + updateQuadUVs: function (offset, u1, v1, u2, v2) + { + var verts = this.vertices; + + // Adjust for frame offset + // Incoming values will always be in the range 0-1 + var frame = this.frame; + + var fu1 = frame.u0; + var fv1 = frame.v0; + var fu2 = frame.u1; + var fv2 = frame.v1; + + if (fu1 !== 0 || fu2 !== 1) + { + // adjust horizontal + var udiff = fu2 - fu1; + u1 = fu1 + u1 * udiff; + u2 = fu1 + u2 * udiff; + } + + if (fv1 !== 0 || fv2 !== 1) + { + // adjust vertical + var vdiff = fv2 - fv1; + v1 = fv1 + v1 * vdiff; + v2 = fv1 + v2 * vdiff; + } + + verts[offset + 0].setUVs(u1, v1); + verts[offset + 1].setUVs(u1, v2); + verts[offset + 2].setUVs(u2, v1); + verts[offset + 3].setUVs(u1, v2); + verts[offset + 4].setUVs(u2, v2); + verts[offset + 5].setUVs(u2, v1); + }, + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'multiply', + * which results in no visible change to the texture. + * + * @method Phaser.GameObjects.NineSlice#clearTint + * @webglOnly + * @since 3.60.0 + * + * @return {this} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + this.setTintMode(); + + return this; + }, + + /** + * Sets a tint on this Game Object. + * + * The tint applies a color to the pixel color values + * from the GameObject's texture in one of several modes, + * set with `setTintMode` or the `tintMode` property. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property. + * + * To remove a tint call `clearTint`, or call this method with no parameters. + * + * @method Phaser.GameObjects.NineSlice#setTint + * @webglOnly + * @since 3.60.0 + * + * @param {number} [color=0xffffff] - The tint being applied to the entire Game Object. + * + * @return {this} This Game Object instance. + */ + setTint: function (color) + { + if (color === undefined) { color = 0xffffff; } + + this.tint = color; + + return this; + }, + + /** + * Sets the tint mode for this Game Object. + * + * The tint mode applies a color to the pixel color values + * from the GameObject's texture in one of several modes: + * + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * + * @method Phaser.GameObjects.NineSlice#setTintMode + * @webglOnly + * @since 4.0.0 + * + * @param {Phaser.TintModes} [mode=Phaser.TintModes.MULTIPLY] - The tint mode to use. + * + * @return {this} This Game Object instance. + */ + setTintMode: function (mode) + { + if (mode === undefined) { mode = TintModes.MULTIPLY; } + + this.tintMode = mode; + return this; + }, + + /** + * Does this Game Object have a tint applied? + * + * It checks to see if the tint property is set to a value other than 0xffffff + * or the tint mode is not the default Phaser.TintModes.MULTIPLY. + * This indicates that a Game Object is tinted. + * + * @name Phaser.GameObjects.NineSlice#isTinted + * @type {boolean} + * @webglOnly + * @readonly + * @since 3.60.0 + */ + isTinted: { + + get: function () + { + return (this.tint !== 0xffffff || this.tintMode !== TintModes.MULTIPLY); + } + + }, + + /** + * The displayed width of this Game Object. + * + * Setting this value will adjust the way in which this Nine Slice + * object scales horizontally, if configured to do so. + * + * The _minimum_ width this Game Object can be is the total of + * `leftWidth` + `rightWidth`. If you need to display this object + * at a smaller size, you can also scale it. + * + * @name Phaser.GameObjects.NineSlice#width + * @type {number} + * @since 3.60.0 + */ + width: { + + get: function () + { + return this._width; + }, + + set: function (value) + { + this._width = Math.max(value, this.leftWidth + this.rightWidth); + + this.updateVertices(); + } + + }, + + /** + * The displayed height of this Game Object. + * + * Setting this value will adjust the way in which this Nine Slice + * object scales vertically, if configured to do so. + * + * The _minimum_ height this Game Object can be is the total of + * `topHeight` + `bottomHeight`. If you need to display this object + * at a smaller size, you can also scale it. + * + * If this is a 3-slice object, you can only stretch it horizontally + * and changing the height will be ignored. + * + * @name Phaser.GameObjects.NineSlice#height + * @type {number} + * @since 3.60.0 + */ + height: { + + get: function () + { + return this._height; + }, + + set: function (value) + { + if (!this.is3Slice) + { + this._height = Math.max(value, this.topHeight + this.bottomHeight); + + this.updateVertices(); + } + } + + }, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.NineSlice#displayWidth + * @type {number} + * @since 3.60.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.NineSlice#displayHeight + * @type {number} + * @since 3.60.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the size of this Game Object. + * + * For a Nine Slice Game Object this means it will be stretched (or shrunk) horizontally + * and vertically depending on the dimensions given to this method, in accordance with + * how it has been configured for the various corner sizes. + * + * If this is a 3-slice object, you can only stretch it horizontally + * and changing the height will be ignored. + * + * If you have enabled this Game Object for input, changing the size will also change the + * size of the hit area. + * + * @method Phaser.GameObjects.NineSlice#setSize + * @since 3.60.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + this.updateDisplayOrigin(); + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = this.width; + input.hitArea.height = this.height; + } + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.NineSlice#setDisplaySize + * @since 3.60.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.NineSlice#originX + * @type {number} + * @since 3.60.0 + */ + originX: { + + get: function () + { + return this._originX; + }, + + set: function (value) + { + this._originX = value; + this.updateVertices(); + } + + }, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.NineSlice#originY + * @type {number} + * @since 3.60.0 + */ + originY: { + + get: function () + { + return this._originY; + }, + + set: function (value) + { + this._originY = value; + this.updateVertices(); + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.NineSlice#setOrigin + * @since 3.60.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this._originX = x; + this._originY = y; + + this.updateVertices(); + + return this.updateDisplayOrigin(); + }, + + /** + * Resets the size of this Nine Slice Game Object to match the current texture frame. + * + * For a 3-slice object, this sets the height to match the frame height and refreshes + * the UV coordinates. For a 9-slice object, only the UVs are refreshed. This is called + * automatically when the texture frame changes and should not normally need to be + * called directly. + * + * @method Phaser.GameObjects.NineSlice#setSizeToFrame + * @since 3.60.0 + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function () + { + if (this.is3Slice) + { + var height = this.frame.height; + + this._height = height; + this.topHeight = height; + this.bottomHeight = 0; + } + + this.updateUVs(); + + return this; + }, + + /** + * Handles the pre-destroy step for the Nine Slice, which removes the vertices. + * + * @method Phaser.GameObjects.NineSlice#preDestroy + * @private + * @since 3.60.0 + */ + preDestroy: function () + { + this.vertices = []; + } + +}); + +module.exports = NineSlice; + + +/***/ }, + +/***/ 28279 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var NineSlice = __webpack_require__(28103); + +/** + * Creates a new Nine Slice Game Object and returns it. + * + * Note: This method will only be available if the Nine Slice Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#nineslice + * @since 3.60.0 + * + * @param {Phaser.Types.GameObjects.NineSlice.NineSliceConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.NineSlice} The Game Object that was created. + */ +GameObjectCreator.register('nineslice', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var width = GetValue(config, 'width', 256); + var height = GetValue(config, 'height', 256); + var leftWidth = GetValue(config, 'leftWidth', 10); + var rightWidth = GetValue(config, 'rightWidth', 10); + var topHeight = GetValue(config, 'topHeight', 0); + var bottomHeight = GetValue(config, 'bottomHeight', 0); + + var tileX = GetValue(config, 'tileX', false); + var tileY = GetValue(config, 'tileY', false); + + var nineslice = new NineSlice(this.scene, 0, 0, key, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight, tileX, tileY); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, nineslice, config); + + return nineslice; +}); + + +/***/ }, + +/***/ 47521 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NineSlice = __webpack_require__(28103); +var GameObjectFactory = __webpack_require__(39429); + +/** + * A Nine Slice Game Object allows you to display a texture-based object that + * can be stretched both horizontally and vertically, but that retains + * fixed-sized corners. The dimensions of the corners are set via the + * parameters to this class. + * + * This is extremely useful for UI and button like elements, where you need + * them to expand to accommodate the content without distorting the texture. + * + * The texture you provide for this Game Object should be based on the + * following layout structure: + * + * ``` + * A B + * +---+----------------------+---+ + * C | 1 | 2 | 3 | + * +---+----------------------+---+ + * | | | | + * | 4 | 5 | 6 | + * | | | | + * +---+----------------------+---+ + * D | 7 | 8 | 9 | + * +---+----------------------+---+ + * ``` + * + * When changing this object's width and / or height: + * + * areas 1, 3, 7 and 9 (the corners) will remain unscaled + * areas 2 and 8 will be stretched horizontally only + * areas 4 and 6 will be stretched vertically only + * area 5 will be stretched both horizontally and vertically + * + * You can also create a 3 slice Game Object: + * + * This works in a similar way, except you can only stretch it horizontally. + * Therefore, it requires less configuration: + * + * ``` + * A B + * +---+----------------------+---+ + * | | | | + * C | 1 | 2 | 3 | + * | | | | + * +---+----------------------+---+ + * ``` + * + * When changing this object's width (you cannot change its height) + * + * areas 1 and 3 will remain unscaled + * area 2 will be stretched horizontally + * + * The above configuration concept is adapted from the Pixi NineSlicePlane. + * + * To specify a 3 slice object instead of a 9 slice you should only + * provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice + * you must supply all parameters. + * + * The _minimum_ width this Game Object can be is the total of + * `leftWidth` + `rightWidth`. The _minimum_ height this Game Object + * can be is the total of `topHeight` + `bottomHeight`. + * If you need to display this object at a smaller size, you can scale it. + * + * In terms of performance, using a 3 slice Game Object is the equivalent of + * having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent + * of having 9 Sprites in a row. The vertices of this object are all batched + * together and can co-exist with other Sprites and graphics on the display + * list, without incurring any additional overhead. + * + * As of Phaser 3.60 this Game Object is WebGL only. + * + * @method Phaser.GameObjects.GameObjectFactory#nineslice + * @webglOnly + * @since 3.60.0 + * + * @param {number} x - The horizontal position of the center of this Game Object in the world. + * @param {number} y - The vertical position of the center of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {number} [width=256] - The width of the Nine Slice Game Object. You can adjust the width post-creation. + * @param {number} [height=256] - The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. + * @param {number} [leftWidth=10] - The size of the left vertical column (A). + * @param {number} [rightWidth=10] - The size of the right vertical column (B). + * @param {number} [topHeight=0] - The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. + * @param {number} [bottomHeight=0] - The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. + * @param {boolean} [tileX=false] - Whether to tile the horizontal regions instead of stretching them. Some stretching will still occur to keep the tile count a whole number. + * @param {boolean} [tileY=false] - Whether to tile the vertical regions instead of stretching them. Some stretching will still occur to keep the tile count a whole number. + * + * @return {Phaser.GameObjects.NineSlice} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('nineslice', function (x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight, tileX, tileY) + { + return this.displayList.add(new NineSlice(this.scene, x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight, tileX, tileY)); + }); +} + + +/***/ }, + +/***/ 78023 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(52230); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 82513 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * Represents a single vertex within a NineSlice Game Object. + * + * A NineSlice Game Object is divided into a 3x3 grid of regions, each defined by a mesh + * of vertices. This class stores all the data needed for one vertex: its normalized position + * (x, y inherited from Vector2), its projected screen-space position (vx, vy), and its + * UV texture coordinates (u, v) used during rendering. + * + * You do not typically create NineSliceVertex instances directly. They are created and + * managed internally by the NineSlice Game Object. + * + * @class NineSliceVertex + * @memberof Phaser.GameObjects + * @constructor + * @extends Phaser.Math.Vector2 + * @since 4.0.0 + * + * @param {number} x - The x position of the vertex. + * @param {number} y - The y position of the vertex. + * @param {number} u - The UV u coordinate of the vertex. + * @param {number} v - The UV v coordinate of the vertex. + */ +var Vertex = new Class({ + + Extends: Vector2, + + initialize: + + function Vertex (x, y, u, v) + { + Vector2.call(this, x, y); + + /** + * The projected x coordinate of this vertex. + * + * @name Phaser.GameObjects.NineSliceVertex#vx + * @type {number} + * @since 4.0.0 + */ + this.vx = 0; + + /** + * The projected y coordinate of this vertex. + * + * @name Phaser.GameObjects.NineSliceVertex#vy + * @type {number} + * @since 4.0.0 + */ + this.vy = 0; + + /** + * UV u coordinate of this vertex. + * + * @name Phaser.GameObjects.NineSliceVertex#u + * @type {number} + * @since 4.0.0 + */ + this.u = u; + + /** + * UV v coordinate of this vertex. + * + * @name Phaser.GameObjects.NineSliceVertex#v + * @type {number} + * @since 4.0.0 + */ + this.v = v; + }, + + /** + * Sets the UV texture coordinates of this vertex. + * + * @method Phaser.GameObjects.NineSliceVertex#setUVs + * @since 4.0.0 + * + * @param {number} u - The UV u coordinate of the vertex. + * @param {number} v - The UV v coordinate of the vertex. + * + * @return {this} This Vertex. + */ + setUVs: function (u, v) + { + this.u = u; + this.v = v; + + return this; + }, + + /** + * Updates this vertex's position and calculates its projected screen-space coordinates. + * + * Sets the normalized `x` and `y` position, then scales them by the parent object's + * `width` and `height` to produce the projected `vx` and `vy` values. The origin + * offset of the parent object is then factored in, shifting `vx` and `vy` so that the + * mesh is correctly aligned relative to the object's origin point. + * + * @method Phaser.GameObjects.NineSliceVertex#resize + * @since 4.0.0 + * + * @param {number} x - The x position of the vertex. + * @param {number} y - The y position of the vertex. + * @param {number} width - The width of the parent object. + * @param {number} height - The height of the parent object. + * @param {number} originX - The originX of the parent object. + * @param {number} originY - The originY of the parent object. + * + * @return {this} This Vertex. + */ + resize: function (x, y, width, height, originX, originY) + { + this.x = x; + this.y = y; + + this.vx = this.x * width; + this.vy = -this.y * height; + + if (originX < 0.5) + { + this.vx += width * (0.5 - originX); + } + else if (originX > 0.5) + { + this.vx -= width * (originX - 0.5); + } + + if (originY < 0.5) + { + this.vy += height * (0.5 - originY); + } + else if (originY > 0.5) + { + this.vy -= height * (originY - 0.5); + } + + return this; + } +}); + +module.exports = Vertex; + + +/***/ }, + +/***/ 52230 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); + +var fixedRenderOptions = { multiTexturing: true }; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.NineSlice#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.NineSlice} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var NineSliceWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var verts = src.vertices; + var totalVerts = verts.length; + + if (totalVerts === 0) + { + return; + } + + var camera = drawingContext.camera; + + camera.addToRenderList(src); + + var alpha = src.alpha; + var batchHandler = src.customRenderNodes.BatchHandler || src.defaultRenderNodes.BatchHandler; + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + var color = Utils.getTintAppendFloatAlpha(src.tint, alpha); + var glTexture = src.frame.source.glTexture; + var tintEffect = src.tintMode; + + var quad, vtl, vbr; + + for (var i = 0; i < totalVerts; i += 6) + { + // Of the 6 vertices, we only need these 2 to define a quad. + // They are the top-left and bottom-right. + vtl = verts[i + 1]; + vbr = verts[i + 2]; + + quad = calcMatrix.setQuad( + vtl.vx, vtl.vy, + vbr.vx, vbr.vy + ); + + batchHandler.batch( + drawingContext, + + glTexture, + + // Transformed quad in order TL, BL, TR, BR: + quad[0], quad[1], + quad[2], quad[3], + quad[6], quad[7], + quad[4], quad[5], + + // Texture coordinates in X, Y, Width, Height: + vtl.u, vtl.v, vbr.u - vtl.u, vbr.v - vtl.v, + + tintEffect, + + // Tint colors in order TL, BL, TR, BR: + color, color, color, color, + + // Render options: + fixedRenderOptions + ); + } +}; + +module.exports = NineSliceWebGLRenderer; + + +/***/ }, + +/***/ 35387 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Class = __webpack_require__(83419); +var Shader = __webpack_require__(20071); +var Color = __webpack_require__(40987); +var NoiseFrag = __webpack_require__(16421); + +/** + * @classdesc + * A Noise Game Object. + * + * This game object is a quad which displays random noise. + * You can manipulate this object like any other, make it interactive, + * and use it in filters and masks to create visually stunning effects. + * + * Behind the scenes, a Noise is a {@link Phaser.GameObjects.Shader} + * using a specific shader program. + * + * Noise or 'white noise' is simply random values. + * These are created by hashing the offset pixel coordinates, + * so the same noise is always created at the same position. + * This creates a reproducible effect. + * + * You can set the color and transparency of the noise. + * + * You can scroll the noise by animating the `noiseOffset` property. + * Note that floating-point precision is very important to this effect. + * Scrolling very large distances may cause blockiness in the output. + * Scrolling very small distances may cause the output to change completely, + * as it is not processing the same exact values. + * If you scroll by an exact fraction of the resolution of the object, + * the output will remain mostly the same, + * but it is not guaranteed to be stable. + * It's more effective to use `setRenderToTexture` and use this as a texture + * in a TileSprite. + * + * You can set `noisePower` to sculpt the output levels. + * Higher power reduces higher values. + * Lower power reduces lower values. + * + * @class Noise + * @extends Phaser.GameObjects.Shader + * @memberof Phaser.GameObjects + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Types.GameObjects.Noise.NoiseQuadConfig} [config] - The configuration for this Game Object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + */ +var Noise = new Class({ + Extends: Shader, + + initialize: function Noise (scene, config, x, y, width, height) + { + if (!config) { config = {}; } + + var shaderConfig = { + name: 'noise', + fragmentSource: NoiseFrag, + setupUniforms: this._setupUniforms + }; + + Shader.call(this, scene, shaderConfig, x, y, width, height); + + this.type = 'Noise'; + + /** + * The offset of the noise in each dimension: [ x, y ]. + * Animate x and y to scroll the noise pattern. + * + * This must be an array of 2 numbers. + * + * @name Phaser.GameObjects.Noise#noiseOffset + * @type {number[]} + * @default [ 0, 0 ] + * @since 4.0.0 + */ + this.noiseOffset = [ 0, 0 ]; + if (config.noiseOffset) + { + this.noiseOffset = config.noiseOffset; + } + + /** + * The power to apply to the noise value. + * This can enhance/suppress high/low noise. + * + * @name Phaser.GameObjects.Noise#noisePower + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noisePower = config.noisePower === undefined ? 1 : config.noisePower; + + /** + * The color mapped to low noise values (approaching 0). + * + * The default is black. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.Noise#noiseColorStart + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorStart = new Color(0, 0, 0); + + /** + * The color mapped to high noise values (approaching 1). + * + * The default is white. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.Noise#noiseColorEnd + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorEnd = new Color(255, 255, 255); + + if (config.noiseColorStart !== undefined || config.noiseColorEnd !== undefined) + { + this.setNoiseColor(config.noiseColorStart, config.noiseColorEnd); + } + + /** + * Whether to render channel noise separately, + * creating many colors of output. + * + * @name Phaser.GameObjects.Noise#noiseRandomChannels + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.noiseRandomChannels = !!config.noiseRandomChannels; + + /** + * Whether to render a random normal value per pixel. + * The normal is in the hemisphere facing the camera. + * + * This value overrides `noiseRandomChannels`. + * + * @name Phaser.GameObjects.Noise#noiseRandomNormal + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.noiseRandomNormal = !!config.noiseRandomNormal; + }, + + /** + * Set the colors of the noise, from a variety of color formats. + * + * - A number is expected to be a 24 or 32 bit RGB or ARGB value. + * - A string is expected to be a hex code. + * - An array of numbers is expected to be RGB or RGBA in the range 0-1. + * - A Color object can be used. + * + * @method Phaser.GameObjects.Noise#setNoiseColor + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} [start=0x000000] - The color mapped to low noise values (approaching 0). + * @param {number | string | number[] | Phaser.Display.Color} [end=0xffffff] - The color mapped to high noise values (approaching 1). + * @return {this} This game object. + */ + setNoiseColor: function (start, end) + { + var alpha; + + if (start === undefined) + { + start = 0x000000; + } + if (end === undefined) + { + end = 0xffffff; + } + + if (typeof start === 'number') + { + Color.IntegerToColor(start, this.noiseColorStart); + } + else if (typeof start === 'string') + { + Color.HexStringToColor(start, this.noiseColorStart); + } + else if (Array.isArray(start)) + { + alpha = (start[3] === undefined) ? 1 : start[3]; + this.noiseColorStart.setGLTo(start[0], start[1], start[2], alpha); + } + else if (start instanceof Color) + { + this.noiseColorStart.setTo(start.red, start.green, start.blue, start.alpha); + } + + if (typeof end === 'number') + { + Color.IntegerToColor(end, this.noiseColorEnd); + } + else if (typeof end === 'string') + { + Color.HexStringToColor(end, this.noiseColorEnd); + } + else if (Array.isArray(end)) + { + alpha = (end[3] === undefined) ? 1 : end[3]; + this.noiseColorEnd.setGLTo(end[0], end[1], end[2], alpha); + } + else if (end instanceof Color) + { + this.noiseColorEnd.setTo(end.red, end.green, end.blue, end.alpha); + } + + return this; + }, + + /** + * The function which sets uniforms for the shader. + * This is provided to the Shader base class as `setupUniforms`. + * You should not override `setupUniforms` on this object. + * + * @method Phaser.GameObjects.Noise#_setupUniforms + * @private + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + _setupUniforms: function (setUniform) + { + setUniform('uOffset', this.noiseOffset); + setUniform('uColorStart', this.noiseColorStart.gl); + setUniform('uColorEnd', this.noiseColorEnd.gl); + setUniform('uPower', this.noisePower); + + var mode = 0; + if (this.noiseRandomChannels) { mode = 1; } + if (this.noiseRandomNormal) { mode = 2; } + setUniform('uMode', mode); + } +}); + +module.exports = Noise; + + +/***/ }, + +/***/ 39931 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Noise = __webpack_require__(35387); + +/** + * Creates a new Noise Game Object and returns it. + * + * A Noise Game Object renders procedural noise — such as Perlin or simplex noise — directly + * onto a WebGL quad using a shader. It is useful for generating dynamic visual effects such + * as clouds, fog, terrain previews, animated backgrounds, or any effect that benefits from + * smooth, organic-looking randomness. The noise pattern is generated entirely on the GPU, + * making it very efficient to animate each frame. + * + * Note: This method will only be available if the Noise Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#noise + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.Noise.NoiseConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Noise} The Game Object that was created. + */ +GameObjectCreator.register('noise', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var noise = new Noise(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, noise, config); + + return noise; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 34757 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Noise = __webpack_require__(35387); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Noise Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Noise Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#noise + * @webglOnly + * @since 4.0.0 + * + * @param {(string|Phaser.Types.GameObjects.Noise.NoiseQuadConfig)} [config] - The configuration object this Noise will use. This defines the shape and appearance of the noise texture. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object, in pixels. + * @param {number} [height=128] - The height of the Game Object, in pixels. + * + * @return {Phaser.GameObjects.Noise} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('noise', function (config, x, y, width, height) + { + return this.displayList.add(new Noise(this.scene, config, x, y, width, height)); + }); +} + + +/***/ }, + +/***/ 51513 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Class = __webpack_require__(83419); +var Shader = __webpack_require__(20071); +var Color = __webpack_require__(40987); +var NoiseWorley2DFrag = __webpack_require__(17205); + +/** + * @classdesc + * A NoiseCell2D Game Object. + * + * This game object is a quad which displays cellular noise. + * You can manipulate this object like any other, make it interactive, + * and use it in filters and masks to create visually stunning effects. + * + * Behind the scenes, a NoiseCell2D is a {@link Phaser.GameObjects.Shader} + * using a specific shader program. + * + * Cellular noise, also called Worley Noise or Voronoi Noise, + * consists of a pattern of cells. This is good for modeling natural phenomena + * like waves, clouds, or scales. + * + * You can set the color and transparency, cell count, variation, + * and seed value of the noise. + * You can change the detail level by increasing `noiseIterations`. + * You can change the noise mode to output sharp edges, soft edges, + * or flat colors for the cells. + * + * You can scroll the noise by animating the `noiseOffset` property. + * + * You can set `noiseNormalMap` to output a normal map. + * This is a quick way to add texture for lighting. + * + * @class NoiseCell2D + * @extends Phaser.GameObjects.Shader + * @memberof Phaser.GameObjects + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Types.GameObjects.NoiseCell2D.NoiseCell2DQuadConfig} [config] - The configuration for this Game Object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + */ +var NoiseCell2D = new Class({ + Extends: Shader, + + initialize: function NoiseCell2D (scene, config, x, y, width, height) + { + if (!config) { config = {}; } + + var shaderConfig = { + name: 'noiseCell2D', + fragmentSource: NoiseWorley2DFrag, + shaderAdditions: [ + { + name: 'MODE_DISTANCE', + tags: [ 'MODE' ], + additions: { + fragmentMode: '#define MODE_DISTANCE' + } + }, + { + name: 'ITERATION_COUNT_1', + tags: [ 'ITERATION_COUNT' ], + additions: { + fragmentIterations: '#define ITERATION_COUNT 1.0' + } + }, + { + name: 'NORMALMAP', + tags: [ 'NORMALMAP' ], + additions: { + fragmentNormalMap: '#define NORMAL_MAP\n#extension GL_OES_standard_derivatives : enable' + }, + disable: !config.noiseNormalMap + } + ], + setupUniforms: this._setupUniforms, + updateShaderConfig: this._updateShaderConfig + }; + + Shader.call(this, scene, shaderConfig, x, y, width, height); + + this.type = 'NoiseCell2D'; + + /** + * The number of cells in each dimension. + * + * This must be an array of 2 numbers. + * + * Try to keep the cell count between 2 + * and about an eighth of the resolution of the texture. + * A cell count of 1 has no room to vary. + * A cell count greater than the resolution of the texture + * will essentially be expensive white noise. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseCells + * @type {number[]} + * @default [ 32, 32 ] + * @since 4.0.0 + */ + this.noiseCells = [ 32, 32 ]; + if (config.noiseCells) + { + this.noiseCells = config.noiseCells; + } + + /** + * How many cells wide the pattern is. + * + * By default, this is set to the same dimensions as `noiseCells`. + * This causes the output to wrap seamlessly at the edges. + * To restore wrapping if you changed settings, call `this.wrapNoise()`. + * + * A lower value causes the output to repeat. + * + * A higher value breaks visible wrapping. + * The cell pattern still repeats off-camera. + * Try to keep this value as low as possible, + * as it helps avoid floating-point precision errors. + * + * This must be an array of 2 numbers. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseWrap + * @type {number[]} + * @default [ 32, 32 ] + * @since 4.0.0 + */ + this.noiseWrap = [ + this.noiseCells[0], + this.noiseCells[1] + ]; + if (config.noiseWrap) + { + this.noiseWrap = config.noiseWrap; + } + + /** + * The offset of the noise in each dimension: [ x, y ]. + * Animate x and y to scroll the noise pattern. + * + * This must be an array of 2 numbers. + * + * Moving too far from 0 will introduce floating-point precision issues. + * This can cause the noise to appear blocky. + * We start to see obvious blockiness at offsets of a few thousand, + * so stay below that. + * + * @example + * // Scroll the noise pattern without changing the pattern. + * noise.noiseOffset[0] = Math.sin(scene.time.now / 10000); + * noise.noiseOffset[1] = Math.cos(scene.time.now / 10000); + * + * @name Phaser.GameObjects.NoiseCell2D#noiseOffset + * @type {number[]} + * @default [ 0, 0 ] + * @since 4.0.0 + */ + this.noiseOffset = [ 0, 0 ]; + if (config.noiseOffset) + { + this.noiseOffset = config.noiseOffset; + } + + /** + * How much each cell can vary from its grid position. + * High values break further from the grid. + * + * At 0, cells are perfectly square. + * At 1, cells are fully chaotic. + * Never go higher than 1, as this can distort the cell matrix so much + * that the nearest cell is outside the sampling range, + * causing seams in the noise. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseVariation + * @type {number[]} + * @default [ 1, 1 ] + * @since 4.0.0 + */ + this.noiseVariation = [ 1, 1 ]; + if (config.noiseVariation) + { + this.noiseVariation = config.noiseVariation; + } + + /** + * How many octaves of noise to apply. + * This adds fine detail to the noise, at the cost of performance. + * + * Each octave of noise has twice the resolution, + * and contributes half as much to the output. + * + * This value should be an integer of 1 or higher. + * Values above 5 or so have increasingly little effect. + * Each iteration has a cost, so only use as much as you need! + * + * @name Phaser.GameObjects.NoiseCell2D#noiseIterations + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseIterations = 1; + if (config.noiseIterations) + { + this.noiseIterations = config.noiseIterations; + } + + /** + * What mode to output the noise in. + * + * - 0: Sharp boundaries between cells. + * - 1: Index mode. Cells have a single flat color. + * It is random and may not be unique. + * - 2: Smooth boundaries between cells. + * Use `noiseSmoothing` to control smoothness. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseMode + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.noiseMode = 0; + if (config.noiseMode) + { + this.noiseMode = config.noiseMode; + } + + /** + * How much smoothing to apply in smoothing mode. + * + * The default value is 1, which applies moderate smoothing between cells. + * The value is a factor. + * Values from 0-1 reduce the smoothing. + * Values above 1 intensify the smoothing. + * Intensification slows above 4 or so. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseSmoothing + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseSmoothing = 1; + if (config.noiseSmoothing) + { + this.noiseSmoothing = config.noiseSmoothing; + } + + /** + * Whether to convert the noise output to a normal map. + * + * This works properly with noise modes 0 and 2, which form curves. + * + * Control the curvature strength with `noiseNormalScale`. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseNormalMap + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.noiseNormalMap = !!config.noiseNormalMap; + + /** + * Curvature strength of normal map output. + * This is used when `noiseNormalMap` is enabled. + * + * The default is 1. Higher values produce more curvature; + * lower values are flatter. + * + * Surface angle is determined by the rate of change of the noise. + * Noise with more iterations tends to change more rapidly, + * thus have more pronounced normals. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseNormalScale + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseNormalScale = 1; + if (config.noiseNormalScale !== undefined) + { + this.noiseNormalScale = config.noiseNormalScale; + } + + /** + * The color of the middle of the cells. + * + * The default is black. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseColorStart + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorStart = new Color(0, 0, 0); + + /** + * The color of the edge of the cells. + * + * The default is white. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseColorEnd + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorEnd = new Color(255, 255, 255); + + if (config.noiseColorStart !== undefined || config.noiseColorEnd !== undefined) + { + this.setNoiseColor(config.noiseColorStart, config.noiseColorEnd); + } + + /** + * Seed values for the noise. + * Vary these to change the shape of cells in the pattern. + * A different seed creates a completely different pattern. + * + * This must be an array of 8 numbers. + * + * Noise seed values should be fairly small. + * Numbers between 0 and 1, or 0 and 8, are recommended. + * Very large seed values may lose floating-point precision + * and cause the noise to appear blocky. + * + * @name Phaser.GameObjects.NoiseCell2D#noiseSeed + * @type {number[]} + * @default [ 1, 2, 3, 4, 5, 6, 7, 8 ] + * @since 4.0.0 + */ + this.noiseSeed = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; + if (config.noiseSeed) { this.noiseSeed = config.noiseSeed; } + if (config.randomizeNoiseSeed) + { + this.randomizeNoiseSeed(); + } + + /** + * Whether to jitter shader inputs to force continuous high precision. + * This is an advanced setting. + * + * Chromium browsers seem to switch between WebGL rendering modes, + * which changes the precision available to the noise shader. + * This can change the noise calculation, causing parts of the output + * to flicker unpredictably. + * The `keepAwake` setting adds an imperceptible amount to the offset + * during rendering, which seems to force Chromium to be consistent + * and eliminate the flickering. + * + * Don't disable this unless you know what you're doing. + * It prevents an unpredictable problem that might not appear in your + * browser or device, but will appear for other users. + * + * @name Phaser.GameObjects.NoiseCell2D#keepAwake + * @type {boolean} + * @default true + * @since 4.0.0 + */ + this.keepAwake = true; + }, + + /** + * Set the colors of the noise, from a variety of color formats. + * + * - A number is expected to be a 24 or 32 bit RGB or ARGB value. + * - A string is expected to be a hex code. + * - An array of numbers is expected to be RGB or RGBA in the range 0-1. + * - A Color object can be used. + * + * @method Phaser.GameObjects.NoiseCell2D#setNoiseColor + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} [start=0x000000] - The color in the middle of the cells. + * @param {number | string | number[] | Phaser.Display.Color} [end=0xffffff] - The color at the edge of the cells. + * @return {this} This game object. + */ + setNoiseColor: function (start, end) + { + var alpha; + + if (start === undefined) + { + start = 0x000000; + } + if (end === undefined) + { + end = 0xffffff; + } + + if (typeof start === 'number') + { + Color.IntegerToColor(start, this.noiseColorStart); + } + else if (typeof start === 'string') + { + Color.HexStringToColor(start, this.noiseColorStart); + } + else if (Array.isArray(start)) + { + alpha = (start[3] === undefined) ? 1 : start[3]; + this.noiseColorStart.setGLTo(start[0], start[1], start[2], alpha); + } + else if (start instanceof Color) + { + this.noiseColorStart.setTo(start.red, start.green, start.blue, start.alpha); + } + + if (typeof end === 'number') + { + Color.IntegerToColor(end, this.noiseColorEnd); + } + else if (typeof end === 'string') + { + Color.HexStringToColor(end, this.noiseColorEnd); + } + else if (Array.isArray(end)) + { + alpha = (end[3] === undefined) ? 1 : end[3]; + this.noiseColorEnd.setGLTo(end[0], end[1], end[2], alpha); + } + else if (end instanceof Color) + { + this.noiseColorEnd.setTo(end.red, end.green, end.blue, end.alpha); + } + + return this; + }, + + /** + * Randomize the noise seed, creating a unique pattern. + * + * @method Phaser.GameObjects.NoiseCell2D#randomizeNoiseSeed + * @since 4.0.0 + * @return {this} This game object. + */ + randomizeNoiseSeed: function () + { + var len = this.noiseSeed.length; + for (var i = 0; i < len; i++) + { + this.noiseSeed[i] = Math.random(); + } + return this; + }, + + /** + * Set the noise texture to wrap seamlessly. + * + * This sets `noiseWrap` to equal `noiseCells` in all dimensions. + * + * @method Phaser.GameObjects.NoiseCell2D#wrapNoise + * @since 4.0.0 + * @return {this} This game object. + */ + wrapNoise: function () + { + var len = this.noiseWrap.length; + for (var i = 0; i < len; i++) + { + this.noiseWrap[i] = this.noiseCells[i]; + } + return this; + }, + + /** + * The function which sets uniforms for the shader. + * This is provided to the Shader base class as `setupUniforms`. + * You should not override `setupUniforms` on this object. + * + * @method Phaser.GameObjects.NoiseCell2D#_setupUniforms + * @private + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + _setupUniforms: function (setUniform) + { + if (this.keepAwake) + { + var wakeValue = Math.sin(this.scene.time.now) / 4096 / 256; + setUniform('uCellOffset', [ + this.noiseOffset[0] + wakeValue, + this.noiseOffset[1] + wakeValue + ]); + } + else + { + setUniform('uCellOffset', this.noiseOffset); + } + + setUniform('uSeedX', this.noiseSeed.slice(0, 2)); + setUniform('uSeedY', this.noiseSeed.slice(2, 4)); + setUniform('uCells', this.noiseCells); + setUniform('uVariation', this.noiseVariation); + setUniform('uWrap', this.noiseWrap); + setUniform('uSmoothing', this.noiseSmoothing); + setUniform('uNormalScale', this.noiseNormalScale); + setUniform('uColorStart', this.noiseColorStart.gl); + setUniform('uColorEnd', this.noiseColorEnd.gl); + }, + + /** + * The function which updates shader configuration. + * This is provided to the Shader base class as `updateShaderConfig`. + * You should not override `updateShaderConfig` on this object. + * + * @method Phaser.GameObjects.NoiseCell2D#_updateShaderConfig + * @private + * @since 4.0.0 + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + * @param {Phaser.GameObjects.Gradient} gameObject - The game object which is rendering. + * @param {Phaser.Renderer.WebGL.RenderNodes.ShaderQuad} renderNode - The render node currently rendering. + */ + _updateShaderConfig: function (drawingContext, gameObject, renderNode) + { + var iterations = Math.max(1, Math.floor(gameObject.noiseIterations)); + var iterationAdd = renderNode.programManager.getAdditionsByTag('ITERATION_COUNT')[0]; + iterationAdd.name = 'ITERATION_COUNT_' + iterations; + iterationAdd.additions.fragmentIterations = '#define ITERATION_COUNT ' + iterations + '.0'; + + var mode = 'MODE_DISTANCE'; + switch (gameObject.noiseMode) + { + case 1: + { + mode = 'MODE_INDEX'; + break; + } + case 2: + { + mode = 'MODE_DISTANCE_SMOOTH'; + break; + } + } + var modeAdd = renderNode.programManager.getAdditionsByTag('MODE')[0]; + modeAdd.name = mode; + modeAdd.additions.fragmentMode = '#define ' + mode; + + var normalAdd = renderNode.programManager.getAdditionsByTag('NORMALMAP')[0]; + normalAdd.disable = !gameObject.noiseNormalMap; + } +}); + +module.exports = NoiseCell2D; + + +/***/ }, + +/***/ 98292 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var NoiseCell2D = __webpack_require__(51513); + +/** + * Creates a new NoiseCell2D Game Object and returns it. + * + * Note: This method will only be available if the NoiseCell2D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#noisecell2d + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.NoiseCell2D.NoiseCell2DConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.NoiseCell2D} The Game Object that was created. + */ +GameObjectCreator.register('noisecell2d', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var noisecell2d = new NoiseCell2D(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, noisecell2d, config); + + return noisecell2d; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 26590 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var NoiseCell2D = __webpack_require__(51513); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new NoiseCell2D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the NoiseCell2D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#noisecell2d + * @webglOnly + * @since 4.0.0 + * + * @param {(string|Phaser.Types.GameObjects.NoiseCell2D.NoiseCell2DQuadConfig)} [config] - The configuration object this NoiseCell2D will use. This defines the shape and appearance of the NoiseCell2D texture. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * + * @return {Phaser.GameObjects.NoiseCell2D} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('noisecell2d', function (config, x, y, width, height) + { + return this.displayList.add(new NoiseCell2D(this.scene, config, x, y, width, height)); + }); +} + + +/***/ }, + +/***/ 15686 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Class = __webpack_require__(83419); +var Shader = __webpack_require__(20071); +var Color = __webpack_require__(40987); +var NoiseWorley3DFrag = __webpack_require__(79814); + +/** + * @classdesc + * A NoiseCell3D Game Object. + * + * This game object is a quad which displays cellular noise. + * You can manipulate this object like any other, make it interactive, + * and use it in filters and masks to create visually stunning effects. + * + * Behind the scenes, a NoiseCell3D is a {@link Phaser.GameObjects.Shader} + * using a specific shader program. + * + * Cellular noise, also called Worley Noise or Voronoi Noise, + * consists of a pattern of cells. This is good for modeling natural phenomena + * like waves, clouds, or scales. + * + * You can set the color and transparency, cell count, variation, + * and seed value of the noise. + * You can change the detail level by increasing `noiseIterations`. + * You can change the noise mode to output sharp edges, soft edges, + * or flat colors for the cells. + * + * You can scroll the noise by animating the `noiseOffset` property. + * + * You can set `noiseNormalMap` to output a normal map. + * This is a quick way to add texture for lighting. + * + * The 3D version of NoiseCell has one extra dimension: Z. + * The shader only renders the XY slice through the noise field. + * Because the centers of cells typically lie elsewhere in the hypervolume, + * cells appear with variation in brightness. + * You can scroll on the Z axis to shift the slice, smoothly changing the cell pattern. + * + * @class NoiseCell3D + * @extends Phaser.GameObjects.Shader + * @memberof Phaser.GameObjects + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Types.GameObjects.NoiseCell3D.NoiseCell3DQuadConfig} [config] - The configuration for this Game Object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + */ +var NoiseCell3D = new Class({ + Extends: Shader, + + initialize: function NoiseCell3D (scene, config, x, y, width, height) + { + if (!config) { config = {}; } + + var shaderConfig = { + name: 'noiseCell3D', + fragmentSource: NoiseWorley3DFrag, + shaderAdditions: [ + { + name: 'MODE_DISTANCE', + tags: [ 'MODE' ], + additions: { + fragmentMode: '#define MODE_DISTANCE' + } + }, + { + name: 'ITERATION_COUNT_1', + tags: [ 'ITERATION_COUNT' ], + additions: { + fragmentIterations: '#define ITERATION_COUNT 1.0' + } + }, + { + name: 'NORMALMAP', + tags: [ 'NORMALMAP' ], + additions: { + fragmentNormalMap: '#define NORMAL_MAP\n#extension GL_OES_standard_derivatives : enable' + }, + disable: !config.noiseNormalMap + } + ], + setupUniforms: this._setupUniforms, + updateShaderConfig: this._updateShaderConfig + }; + + Shader.call(this, scene, shaderConfig, x, y, width, height); + + this.type = 'NoiseCell3D'; + + /** + * The number of cells in each dimension. + * + * This must be an array of 3 numbers. + * + * Try to keep the cell count between 2 + * and about an eighth of the resolution of the texture. + * A cell count of 1 has no room to vary. + * A cell count greater than the resolution of the texture + * will essentially be expensive white noise. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseCells + * @type {number[]} + * @default [ 32, 32, 32 ] + * @since 4.0.0 + */ + this.noiseCells = [ 32, 32, 32 ]; + if (config.noiseCells) + { + this.noiseCells = config.noiseCells; + } + + /** + * How many cells wide the pattern is. + * + * By default, this is set to the same dimensions as `noiseCells`. + * This causes the output to wrap seamlessly at the edges. + * To restore wrapping if you changed settings, call `this.wrapNoise()`. + * + * A lower value causes the output to repeat. + * + * A higher value breaks visible wrapping. + * The cell pattern still repeats off-camera. + * Try to keep this value as low as possible, + * as it helps avoid floating-point precision errors. + * + * This must be an array of 3 numbers. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseWrap + * @type {number[]} + * @default [ 32, 32, 32 ] + * @since 4.0.0 + */ + this.noiseWrap = [ + this.noiseCells[0], + this.noiseCells[1], + this.noiseCells[2] + ]; + if (config.noiseWrap) + { + this.noiseWrap = config.noiseWrap; + } + + /** + * The offset of the noise in each dimension: [ x, y, z ]. + * Animate x and y to scroll the noise pattern. + * Animate z to smoothly change the noise pattern. + * + * This must be an array of 3 numbers. + * + * Moving too far from 0 will introduce floating-point precision issues. + * This can cause the noise to appear blocky. + * We start to see obvious blockiness at offsets of a few thousand, + * so stay below that. + * + * You can evolve the noise pattern by scrolling the Z axis. + * However, this will eventually meet those floating-point precision issues. + * + * @example + * // Scroll the noise pattern without changing the pattern. + * noise.noiseOffset[0] = Math.sin(scene.time.now / 10000); + * noise.noiseOffset[1] = Math.cos(scene.time.now / 10000); + * + * // Evolve the noise pattern along the Z axis. + * noise.noiseOffset[2] = scene.time.now / 1000; + * + * @name Phaser.GameObjects.NoiseCell3D#noiseOffset + * @type {number[]} + * @default [ 0, 0, 0 ] + * @since 4.0.0 + */ + this.noiseOffset = [ 0, 0, 0 ]; + if (config.noiseOffset) + { + this.noiseOffset = config.noiseOffset; + } + + /** + * How much each cell can vary from its grid position. + * High values break further from the grid. + * + * At 0, cells are perfectly square. + * At 1, cells are fully chaotic. + * Never go higher than 1, as this can distort the cell matrix so much + * that the nearest cell is outside the sampling range, + * causing seams in the noise. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseVariation + * @type {number[]} + * @default [ 1, 1, 1 ] + * @since 4.0.0 + */ + this.noiseVariation = [ 1, 1, 1 ]; + if (config.noiseVariation) + { + this.noiseVariation = config.noiseVariation; + } + + /** + * How many octaves of noise to apply. + * This adds fine detail to the noise, at the cost of performance. + * + * Each octave of noise has twice the resolution, + * and contributes half as much to the output. + * + * This value should be an integer of 1 or higher. + * Values above 5 or so have increasingly little effect. + * Each iteration has a cost, so only use as much as you need! + * + * @name Phaser.GameObjects.NoiseCell3D#noiseIterations + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseIterations = 1; + if (config.noiseIterations) + { + this.noiseIterations = config.noiseIterations; + } + + /** + * What mode to output the noise in. + * + * - 0: Sharp boundaries between cells. + * - 1: Index mode. Cells have a single flat color. + * The color assigned to each cell is random and may not be unique across cells. + * - 2: Smooth boundaries between cells. + * Use `noiseSmoothing` to control smoothness. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseMode + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.noiseMode = 0; + if (config.noiseMode) + { + this.noiseMode = config.noiseMode; + } + + /** + * How much smoothing to apply in smoothing mode. + * + * The default value is 1, which applies moderate smoothing between cells. + * The value is a factor. + * Values from 0-1 reduce the smoothing. + * Values above 1 intensify the smoothing. + * Intensification slows above 4 or so. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseSmoothing + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseSmoothing = 1; + if (config.noiseSmoothing) + { + this.noiseSmoothing = config.noiseSmoothing; + } + + /** + * Whether to convert the noise output to a normal map. + * + * This works properly with noise modes 0 and 2, which form curves. + * + * Control the curvature strength with `noiseNormalScale`. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseNormalMap + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.noiseNormalMap = !!config.noiseNormalMap; + + /** + * Curvature strength of normal map output. + * This is used when `noiseNormalMap` is enabled. + * + * The default is 1. Higher values produce more curvature; + * lower values are flatter. + * + * Surface angle is determined by the rate of change of the noise. + * Noise with more iterations tends to change more rapidly, + * thus have more pronounced normals. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseNormalScale + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseNormalScale = 1; + if (config.noiseNormalScale !== undefined) + { + this.noiseNormalScale = config.noiseNormalScale; + } + + /** + * The color of the middle of the cells. + * + * The default is black. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseColorStart + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorStart = new Color(0, 0, 0); + + /** + * The color of the edge of the cells. + * + * The default is white. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseColorEnd + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorEnd = new Color(255, 255, 255); + + if (config.noiseColorStart !== undefined || config.noiseColorEnd !== undefined) + { + this.setNoiseColor(config.noiseColorStart, config.noiseColorEnd); + } + + /** + * Seed values for the noise. + * Vary these to change the shape of cells in the pattern. + * A different seed creates a completely different pattern. + * + * This must be an array of 12 numbers. + * + * Noise seed values should be fairly small. + * Numbers between 0 and 1, or 0 and 12, are recommended. + * Very large seed values may lose floating-point precision + * and cause the noise to appear blocky. + * + * @name Phaser.GameObjects.NoiseCell3D#noiseSeed + * @type {number[]} + * @default [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] + * @since 4.0.0 + */ + this.noiseSeed = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; + if (config.noiseSeed) { this.noiseSeed = config.noiseSeed; } + if (config.randomizeNoiseSeed) + { + this.randomizeNoiseSeed(); + } + + /** + * Whether to jitter shader inputs to force continuous high precision. + * This is an advanced setting. + * + * Chromium browsers seem to switch between WebGL rendering modes, + * which changes the precision available to the noise shader. + * This can change the noise calculation, causing parts of the output + * to flicker unpredictably. + * The `keepAwake` setting adds an imperceptible amount to the offset + * during rendering, which seems to force Chromium to be consistent + * and eliminate the flickering. + * + * Don't disable this unless you know what you're doing. + * It prevents an unpredictable problem that might not appear in your + * browser or device, but will appear for other users. + * + * @name Phaser.GameObjects.NoiseCell3D#keepAwake + * @type {boolean} + * @default true + * @since 4.0.0 + */ + this.keepAwake = true; + }, + + /** + * Set the colors of the noise, from a variety of color formats. + * + * - A number is expected to be a 24 or 32 bit RGB or ARGB value. + * - A string is expected to be a hex code. + * - An array of numbers is expected to be RGB or RGBA in the range 0-1. + * - A Color object can be used. + * + * @method Phaser.GameObjects.NoiseCell3D#setNoiseColor + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} [start=0x000000] - The color in the middle of the cells. + * @param {number | string | number[] | Phaser.Display.Color} [end=0xffffff] - The color at the edge of the cells. + * @return {this} This game object. + */ + setNoiseColor: function (start, end) + { + var alpha; + + if (start === undefined) + { + start = 0x000000; + } + if (end === undefined) + { + end = 0xffffff; + } + + if (typeof start === 'number') + { + Color.IntegerToColor(start, this.noiseColorStart); + } + else if (typeof start === 'string') + { + Color.HexStringToColor(start, this.noiseColorStart); + } + else if (Array.isArray(start)) + { + alpha = (start[3] === undefined) ? 1 : start[3]; + this.noiseColorStart.setGLTo(start[0], start[1], start[2], alpha); + } + else if (start instanceof Color) + { + this.noiseColorStart.setTo(start.red, start.green, start.blue, start.alpha); + } + + if (typeof end === 'number') + { + Color.IntegerToColor(end, this.noiseColorEnd); + } + else if (typeof end === 'string') + { + Color.HexStringToColor(end, this.noiseColorEnd); + } + else if (Array.isArray(end)) + { + alpha = (end[3] === undefined) ? 1 : end[3]; + this.noiseColorEnd.setGLTo(end[0], end[1], end[2], alpha); + } + else if (end instanceof Color) + { + this.noiseColorEnd.setTo(end.red, end.green, end.blue, end.alpha); + } + + return this; + }, + + /** + * Randomize the noise seed, creating a unique pattern. + * + * @method Phaser.GameObjects.NoiseCell3D#randomizeNoiseSeed + * @since 4.0.0 + * @return {this} This game object. + */ + randomizeNoiseSeed: function () + { + var len = this.noiseSeed.length; + for (var i = 0; i < len; i++) + { + this.noiseSeed[i] = Math.random(); + } + return this; + }, + + /** + * Set the noise texture to wrap seamlessly. + * + * This sets `noiseWrap` to equal `noiseCells` in all dimensions. + * + * @method Phaser.GameObjects.NoiseCell3D#wrapNoise + * @since 4.0.0 + * @return {this} This game object. + */ + wrapNoise: function () + { + var len = this.noiseWrap.length; + for (var i = 0; i < len; i++) + { + this.noiseWrap[i] = this.noiseCells[i]; + } + return this; + }, + + /** + * The function which sets uniforms for the shader. + * This is provided to the Shader base class as `setupUniforms`. + * You should not override `setupUniforms` on this object. + * + * @method Phaser.GameObjects.NoiseCell3D#_setupUniforms + * @private + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + _setupUniforms: function (setUniform) + { + if (this.keepAwake) + { + var wakeValue = Math.sin(this.scene.time.now) / 4096 / 256; + setUniform('uCellOffset', [ + this.noiseOffset[0] + wakeValue, + this.noiseOffset[1] + wakeValue, + this.noiseOffset[2] + wakeValue + ]); + } + else + { + setUniform('uCellOffset', this.noiseOffset); + } + + setUniform('uSeedX', this.noiseSeed.slice(0, 3)); + setUniform('uSeedY', this.noiseSeed.slice(3, 6)); + setUniform('uSeedZ', this.noiseSeed.slice(6, 9)); + setUniform('uCells', this.noiseCells); + setUniform('uVariation', this.noiseVariation); + setUniform('uWrap', this.noiseWrap); + setUniform('uSmoothing', this.noiseSmoothing); + setUniform('uNormalScale', this.noiseNormalScale); + setUniform('uColorStart', this.noiseColorStart.gl); + setUniform('uColorEnd', this.noiseColorEnd.gl); + }, + + /** + * The function which updates shader configuration. + * This is provided to the Shader base class as `updateShaderConfig`. + * You should not override `updateShaderConfig` on this object. + * + * @method Phaser.GameObjects.NoiseCell3D#_updateShaderConfig + * @private + * @since 4.0.0 + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + * @param {Phaser.GameObjects.Gradient} gameObject - The game object which is rendering. + * @param {Phaser.Renderer.WebGL.RenderNodes.ShaderQuad} renderNode - The render node currently rendering. + */ + _updateShaderConfig: function (drawingContext, gameObject, renderNode) + { + var iterations = Math.max(1, Math.floor(gameObject.noiseIterations)); + var iterationAdd = renderNode.programManager.getAdditionsByTag('ITERATION_COUNT')[0]; + iterationAdd.name = 'ITERATION_COUNT_' + iterations; + iterationAdd.additions.fragmentIterations = '#define ITERATION_COUNT ' + iterations + '.0'; + + var mode = 'MODE_DISTANCE'; + switch (gameObject.noiseMode) + { + case 1: + { + mode = 'MODE_INDEX'; + break; + } + case 2: + { + mode = 'MODE_DISTANCE_SMOOTH'; + break; + } + } + var modeAdd = renderNode.programManager.getAdditionsByTag('MODE')[0]; + modeAdd.name = mode; + modeAdd.additions.fragmentMode = '#define ' + mode; + + var normalAdd = renderNode.programManager.getAdditionsByTag('NORMALMAP')[0]; + normalAdd.disable = !gameObject.noiseNormalMap; + } +}); + +module.exports = NoiseCell3D; + + +/***/ }, + +/***/ 97044 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var NoiseCell3D = __webpack_require__(15686); + +/** + * Creates a new NoiseCell3D Game Object and returns it. + * + * Note: This method will only be available if the NoiseCell3D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#noisecell3d + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.NoiseCell3D.NoiseCell3DConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.NoiseCell3D} The Game Object that was created. + */ +GameObjectCreator.register('noisecell3d', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var noisecell3d = new NoiseCell3D(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, noisecell3d, config); + + return noisecell3d; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 89918 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var NoiseCell3D = __webpack_require__(15686); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new NoiseCell3D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the NoiseCell3D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#noisecell3d + * @webglOnly + * @since 4.0.0 + * + * @param {(string|Phaser.Types.GameObjects.NoiseCell3D.NoiseCell3DQuadConfig)} [config] - The configuration object this NoiseCell3D will use. This defines the shape and appearance of the NoiseCell3D texture. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * + * @return {Phaser.GameObjects.NoiseCell3D} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('noisecell3d', function (config, x, y, width, height) + { + return this.displayList.add(new NoiseCell3D(this.scene, config, x, y, width, height)); + }); +} + + +/***/ }, + +/***/ 41946 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Class = __webpack_require__(83419); +var Shader = __webpack_require__(20071); +var Color = __webpack_require__(40987); +var NoiseWorley4DFrag = __webpack_require__(99595); + +/** + * @classdesc + * A NoiseCell4D Game Object. + * + * This game object is a quad which displays cellular noise. + * You can manipulate this object like any other, make it interactive, + * and use it in filters and masks to create visually stunning effects. + * + * Behind the scenes, a NoiseCell4D is a {@link Phaser.GameObjects.Shader} + * using a specific shader program. + * + * Cellular noise, also called Worley Noise or Voronoi Noise, + * consists of a pattern of cells. This is good for modeling natural phenomena + * like waves, clouds, or scales. + * + * You can set the color and transparency, cell count, variation, + * and seed value of the noise. + * You can change the detail level by increasing `noiseIterations`. + * You can change the noise mode to output sharp edges, soft edges, + * or flat colors for the cells. + * + * You can scroll the noise by animating the `noiseOffset` property. + * + * You can set `noiseNormalMap` to output a normal map. + * This is a quick way to add texture for lighting. + * + * The 4D version of NoiseCell has two extra dimensions: Z and W. + * The shader only renders the XY slice through the noise field. + * Because the centers of cells typically lie elsewhere in the hypervolume, + * cells appear with variation in brightness. + * You can scroll on the Z axis to shift the slice, smoothly changing the cell pattern. + * In 4D, you can instead move the ZW offset in a circle, + * creating a constantly changing pattern which repeats without reversing + * or resetting. + * This ZW circling technique is advised for long-term effects, + * because it avoids large offsets which can cause floating-point precision issues. + * + * @class NoiseCell4D + * @extends Phaser.GameObjects.Shader + * @memberof Phaser.GameObjects + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Types.GameObjects.NoiseCell4D.NoiseCell4DQuadConfig} [config] - The configuration for this Game Object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + */ +var NoiseCell4D = new Class({ + Extends: Shader, + + initialize: function NoiseCell4D (scene, config, x, y, width, height) + { + if (!config) { config = {}; } + + var shaderConfig = { + name: 'noiseCell4D', + fragmentSource: NoiseWorley4DFrag, + shaderAdditions: [ + { + name: 'MODE_DISTANCE', + tags: [ 'MODE' ], + additions: { + fragmentMode: '#define MODE_DISTANCE' + } + }, + { + name: 'ITERATION_COUNT_1', + tags: [ 'ITERATION_COUNT' ], + additions: { + fragmentIterations: '#define ITERATION_COUNT 1.0' + } + }, + { + name: 'NORMALMAP', + tags: [ 'NORMALMAP' ], + additions: { + fragmentNormalMap: '#define NORMAL_MAP\n#extension GL_OES_standard_derivatives : enable' + }, + disable: !config.noiseNormalMap + } + ], + setupUniforms: this._setupUniforms, + updateShaderConfig: this._updateShaderConfig + }; + + Shader.call(this, scene, shaderConfig, x, y, width, height); + + this.type = 'NoiseCell4D'; + + /** + * The number of cells in each dimension. + * + * This must be an array of 4 numbers. + * + * Try to keep the cell count between 2 + * and about an eighth of the resolution of the texture. + * A cell count of 1 has no room to vary. + * A cell count greater than the resolution of the texture + * will essentially be expensive white noise. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseCells + * @type {number[]} + * @default [ 32, 32, 32, 32 ] + * @since 4.0.0 + */ + this.noiseCells = [ 32, 32, 32, 32 ]; + if (config.noiseCells) + { + this.noiseCells = config.noiseCells; + } + + /** + * How many cells wide the pattern is. + * + * By default, this is set to the same dimensions as `noiseCells`. + * This causes the output to wrap seamlessly at the edges. + * To restore wrapping if you changed settings, call `this.wrapNoise()`. + * + * A lower value causes the output to repeat. + * + * A higher value breaks visible wrapping. + * The cell pattern still repeats off-camera. + * Try to keep this value as low as possible, + * as it helps avoid floating-point precision errors. + * + * This must be an array of 4 numbers. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseWrap + * @type {number[]} + * @default [ 32, 32, 32, 32 ] + * @since 4.0.0 + */ + this.noiseWrap = [ + this.noiseCells[0], + this.noiseCells[1], + this.noiseCells[2], + this.noiseCells[3] + ]; + if (config.noiseWrap) + { + this.noiseWrap = config.noiseWrap; + } + + /** + * The offset of the noise in each dimension: [ x, y, z, w ]. + * Animate x and y to scroll the noise pattern. + * Animate z and w to smoothly change the noise pattern. + * + * This must be an array of 4 numbers. + * + * Moving too far from 0 will introduce floating-point precision issues. + * This can cause the noise to appear blocky. + * We start to see obvious blockiness at offsets of a few thousand, + * so stay below that. + * + * You can evolve the noise pattern by scrolling the Z axis. + * However, this will eventually meet those floating-point precision issues. + * + * In four dimensions, you can instead evolve the noise pattern + * by moving along a circle in the ZW plane. + * This changes the pattern smoothly, without leaving the safe region, + * and without needing to stop and reverse or reset. + * 4D noise is very useful for continuously scrolling patterns. + * + * @example + * // Scroll the noise pattern without changing the pattern. + * noise.noiseOffset[0] = Math.sin(scene.time.now / 10000); + * noise.noiseOffset[1] = Math.cos(scene.time.now / 10000); + * + * // Evolve the noise pattern along a circle in the ZW plane. + * noise.noiseOffset[2] = Math.sin(scene.time.now / 1000) / 32; + * noise.noiseOffset[3] = Math.cos(scene.time.now / 1000) / 32; + * + * @name Phaser.GameObjects.NoiseCell4D#noiseOffset + * @type {number[]} + * @default [ 0, 0, 0, 0 ] + * @since 4.0.0 + */ + this.noiseOffset = [ 0, 0, 0, 0 ]; + if (config.noiseOffset) + { + this.noiseOffset = config.noiseOffset; + } + + /** + * How much each cell can vary from its grid position. + * High values break further from the grid. + * + * At 0, cells are perfectly square. + * At 1, cells are fully chaotic. + * Never go higher than 1, as this can distort the cell matrix so much + * that the nearest cell is outside the sampling range, + * causing seams in the noise. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseVariation + * @type {number[]} + * @default [ 1, 1, 1, 1 ] + * @since 4.0.0 + */ + this.noiseVariation = [ 1, 1, 1, 1 ]; + if (config.noiseVariation) + { + this.noiseVariation = config.noiseVariation; + } + + /** + * How many octaves of noise to apply. + * This adds fine detail to the noise, at the cost of performance. + * + * Each octave of noise has twice the resolution, + * and contributes half as much to the output. + * + * This value should be an integer of 1 or higher. + * Values above 5 or so have increasingly little effect. + * Each iteration has a cost, so only use as much as you need! + * + * @name Phaser.GameObjects.NoiseCell4D#noiseIterations + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseIterations = 1; + if (config.noiseIterations) + { + this.noiseIterations = config.noiseIterations; + } + + /** + * What mode to output the noise in. + * + * - 0: Sharp boundaries between cells. + * - 1: Index mode. Cells have a single flat color. + * It is random and may not be unique. + * - 2: Smooth boundaries between cells. + * Use `noiseSmoothing` to control smoothness. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseMode + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.noiseMode = 0; + if (config.noiseMode) + { + this.noiseMode = config.noiseMode; + } + + /** + * How much smoothing to apply in smoothing mode. + * + * The default value is 1, which applies moderate smoothing between cells. + * The value is a factor. + * Values from 0-1 reduce the smoothing. + * Values above 1 intensify the smoothing. + * Intensification slows above 4 or so. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseSmoothing + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseSmoothing = 1; + if (config.noiseSmoothing) + { + this.noiseSmoothing = config.noiseSmoothing; + } + + /** + * Whether to convert the noise output to a normal map. + * + * This works properly with noise modes 0 and 2, which form curves. + * + * Control the curvature strength with `noiseNormalScale`. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseNormalMap + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.noiseNormalMap = !!config.noiseNormalMap; + + /** + * Curvature strength of normal map output. + * This is used when `noiseNormalMap` is enabled. + * + * The default is 1. Higher values produce more curvature; + * lower values are flatter. + * + * Surface angle is determined by the rate of change of the noise. + * Noise with more iterations tends to change more rapidly, + * thus have more pronounced normals. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseNormalScale + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseNormalScale = 1; + if (config.noiseNormalScale !== undefined) + { + this.noiseNormalScale = config.noiseNormalScale; + } + + /** + * The color of the middle of the cells. + * + * The default is black. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseColorStart + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorStart = new Color(0, 0, 0); + + /** + * The color of the edge of the cells. + * + * The default is white. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseColorEnd + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorEnd = new Color(255, 255, 255); + + if (config.noiseColorStart !== undefined || config.noiseColorEnd !== undefined) + { + this.setNoiseColor(config.noiseColorStart, config.noiseColorEnd); + } + + /** + * Seed values for the noise. + * Vary these to change the shape of cells in the pattern. + * A different seed creates a completely different pattern. + * + * This must be an array of 16 numbers. + * + * Noise seed values should be fairly small. + * Numbers between 0 and 1, or 0 and 16, are recommended. + * Very large seed values may lose floating-point precision + * and cause the noise to appear blocky. + * + * @name Phaser.GameObjects.NoiseCell4D#noiseSeed + * @type {number[]} + * @default [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] + * @since 4.0.0 + */ + this.noiseSeed = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; + if (config.noiseSeed) { this.noiseSeed = config.noiseSeed; } + if (config.randomizeNoiseSeed) + { + this.randomizeNoiseSeed(); + } + + /** + * Whether to jitter shader inputs to force continuous high precision. + * This is an advanced setting. + * + * Chromium browsers seem to switch between WebGL rendering modes, + * which changes the precision available to the noise shader. + * This can change the noise calculation, causing parts of the output + * to flicker unpredictably. + * The `keepAwake` setting adds an imperceptible amount to the offset + * during rendering, which seems to force Chromium to be consistent + * and eliminate the flickering. + * + * Don't disable this unless you know what you're doing. + * It prevents an unpredictable problem that might not appear in your + * browser or device, but will appear for other users. + * + * @name Phaser.GameObjects.NoiseCell4D#keepAwake + * @type {boolean} + * @default true + * @since 4.0.0 + */ + this.keepAwake = true; + }, + + /** + * Set the colors of the noise, from a variety of color formats. + * + * - A number is expected to be a 24 or 32 bit RGB or ARGB value. + * - A string is expected to be a hex code. + * - An array of numbers is expected to be RGB or RGBA in the range 0-1. + * - A Color object can be used. + * + * @method Phaser.GameObjects.NoiseCell4D#setNoiseColor + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} [start=0x000000] - The color in the middle of the cells. + * @param {number | string | number[] | Phaser.Display.Color} [end=0xffffff] - The color at the edge of the cells. + * @return {this} This game object. + */ + setNoiseColor: function (start, end) + { + var alpha; + + if (start === undefined) + { + start = 0x000000; + } + if (end === undefined) + { + end = 0xffffff; + } + + if (typeof start === 'number') + { + Color.IntegerToColor(start, this.noiseColorStart); + } + else if (typeof start === 'string') + { + Color.HexStringToColor(start, this.noiseColorStart); + } + else if (Array.isArray(start)) + { + alpha = (start[3] === undefined) ? 1 : start[3]; + this.noiseColorStart.setGLTo(start[0], start[1], start[2], alpha); + } + else if (start instanceof Color) + { + this.noiseColorStart.setTo(start.red, start.green, start.blue, start.alpha); + } + + if (typeof end === 'number') + { + Color.IntegerToColor(end, this.noiseColorEnd); + } + else if (typeof end === 'string') + { + Color.HexStringToColor(end, this.noiseColorEnd); + } + else if (Array.isArray(end)) + { + alpha = (end[3] === undefined) ? 1 : end[3]; + this.noiseColorEnd.setGLTo(end[0], end[1], end[2], alpha); + } + else if (end instanceof Color) + { + this.noiseColorEnd.setTo(end.red, end.green, end.blue, end.alpha); + } + + return this; + }, + + /** + * Randomize the noise seed, creating a unique pattern. + * + * @method Phaser.GameObjects.NoiseCell4D#randomizeNoiseSeed + * @since 4.0.0 + * @return {this} This game object. + */ + randomizeNoiseSeed: function () + { + var len = this.noiseSeed.length; + for (var i = 0; i < len; i++) + { + this.noiseSeed[i] = Math.random(); + } + return this; + }, + + /** + * Set the noise texture to wrap seamlessly. + * + * This sets `noiseWrap` to equal `noiseCells` in all dimensions. + * + * @method Phaser.GameObjects.NoiseCell4D#wrapNoise + * @since 4.0.0 + * @return {this} This game object. + */ + wrapNoise: function () + { + var len = this.noiseWrap.length; + for (var i = 0; i < len; i++) + { + this.noiseWrap[i] = this.noiseCells[i]; + } + return this; + }, + + /** + * The function which sets uniforms for the shader. + * This is provided to the Shader base class as `setupUniforms`. + * You should not override `setupUniforms` on this object. + * + * @method Phaser.GameObjects.NoiseCell4D#_setupUniforms + * @private + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + _setupUniforms: function (setUniform) + { + if (this.keepAwake) + { + var wakeValue = Math.sin(this.scene.time.now) / 4096 / 256; + setUniform('uCellOffset', [ + this.noiseOffset[0] + wakeValue, + this.noiseOffset[1] + wakeValue, + this.noiseOffset[2] + wakeValue, + this.noiseOffset[3] + wakeValue + ]); + } + else + { + setUniform('uCellOffset', this.noiseOffset); + } + + setUniform('uSeedX', this.noiseSeed.slice(0, 4)); + setUniform('uSeedY', this.noiseSeed.slice(4, 8)); + setUniform('uSeedZ', this.noiseSeed.slice(8, 12)); + setUniform('uSeedW', this.noiseSeed.slice(12, 16)); + setUniform('uCells', this.noiseCells); + setUniform('uVariation', this.noiseVariation); + setUniform('uWrap', this.noiseWrap); + setUniform('uSmoothing', this.noiseSmoothing); + setUniform('uNormalScale', this.noiseNormalScale); + setUniform('uColorStart', this.noiseColorStart.gl); + setUniform('uColorEnd', this.noiseColorEnd.gl); + }, + + /** + * The function which updates shader configuration. + * This is provided to the Shader base class as `updateShaderConfig`. + * You should not override `updateShaderConfig` on this object. + * + * @method Phaser.GameObjects.NoiseCell4D#_updateShaderConfig + * @private + * @since 4.0.0 + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + * @param {Phaser.GameObjects.Gradient} gameObject - The game object which is rendering. + * @param {Phaser.Renderer.WebGL.RenderNodes.ShaderQuad} renderNode - The render node currently rendering. + */ + _updateShaderConfig: function (drawingContext, gameObject, renderNode) + { + var iterations = Math.max(1, Math.floor(gameObject.noiseIterations)); + var iterationAdd = renderNode.programManager.getAdditionsByTag('ITERATION_COUNT')[0]; + iterationAdd.name = 'ITERATION_COUNT_' + iterations; + iterationAdd.additions.fragmentIterations = '#define ITERATION_COUNT ' + iterations + '.0'; + + var mode = 'MODE_DISTANCE'; + switch (gameObject.noiseMode) + { + case 1: + { + mode = 'MODE_INDEX'; + break; + } + case 2: + { + mode = 'MODE_DISTANCE_SMOOTH'; + break; + } + } + var modeAdd = renderNode.programManager.getAdditionsByTag('MODE')[0]; + modeAdd.name = mode; + modeAdd.additions.fragmentMode = '#define ' + mode; + + var normalAdd = renderNode.programManager.getAdditionsByTag('NORMALMAP')[0]; + normalAdd.disable = !gameObject.noiseNormalMap; + } +}); + +module.exports = NoiseCell4D; + + +/***/ }, + +/***/ 20136 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var NoiseCell4D = __webpack_require__(41946); + +/** + * Creates a new NoiseCell4D Game Object and returns it. + * + * Note: This method will only be available if the NoiseCell4D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#noisecell4d + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.NoiseCell4D.NoiseCell4DConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.NoiseCell4D} The Game Object that was created. + */ +GameObjectCreator.register('noisecell4d', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var noisecell4d = new NoiseCell4D(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, noisecell4d, config); + + return noisecell4d; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 65874 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var NoiseCell4D = __webpack_require__(41946); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new NoiseCell4D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the NoiseCell4D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#noisecell4d + * @webglOnly + * @since 4.0.0 + * + * @param {(string|Phaser.Types.GameObjects.NoiseCell4D.NoiseCell4DQuadConfig)} [config] - The configuration object this NoiseCell4D will use. This defines the shape and appearance of the NoiseCell4D texture. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * + * @return {Phaser.GameObjects.NoiseCell4D} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('noisecell4d', function (config, x, y, width, height) + { + return this.displayList.add(new NoiseCell4D(this.scene, config, x, y, width, height)); + }); +} + + +/***/ }, + +/***/ 1792 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Class = __webpack_require__(83419); +var Shader = __webpack_require__(20071); +var Color = __webpack_require__(40987); +var NoiseSimplex2DFrag = __webpack_require__(83587); + +/** + * @classdesc + * A NoiseSimplex2D object. + * + * This game object is a quad which displays simplex noise. + * You can manipulate this object like any other, make it interactive, + * and use it in filters and masks to create visually stunning effects. + * + * Behind the scenes, a NoiseSimplex2D is a {@see Phaser.GameObjects.Shader} + * using a specific shader program. + * + * Simplex noise is a smooth pattern ideal for soft, natural phenomena. + * It is useful for clouds, flame, water, and many other effects. + * Ken Perlin, the creator of Perlin Noise, created Simplex Noise + * to improve performance and quality over the original. + * + * By default, the noise pattern is periodic: it repeats. + * You can scroll in X and Y. + * You can also change the `noiseFlow` value to evolve the pattern + * along a periodic course. + * + * You can set the cell count, color and transparency of the pattern. + * You can add fine detail with `noiseIterations`. + * You can add turbulence with `noiseWarpAmount`. + * + * You can change the basic pattern with `noiseSeed`. + * Different seeds create completely different patterns. + * + * You can set `noiseNormalMap` to output a normal map. + * This is a quick way to add texture for lighting. + * + * For advanced users, you can configure the characteristics of octave iteration. + * Use `noiseDetailPower`, `noiseFlowPower`, and `noiseContributionPower` + * to adjust the exponential scaling rate of these values. + * Use `noiseWarpDetailPower`, `noiseWarpFlowPower`, and + * `noiseWarpContributionPower` to do the same for the warp effect. + * + * @class NoiseSimplex2D + * @extends Phaser.GameObjects.Shader + * @memberof Phaser.GameObjects + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Types.GameObjects.NoiseSimplex2D.NoiseSimplex2DQuadConfig} [config] - The configuration for this Game Object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + */ +var NoiseSimplex2D = new Class({ + Extends: Shader, + + initialize: function NoiseSimplex2D (scene, config, x, y, width, height) + { + if (!config) { config = {}; } + + var shaderConfig = { + name: 'noiseSimplex2D', + fragmentSource: NoiseSimplex2DFrag, + shaderAdditions: [ + { + name: 'ITERATION_COUNT_1_WARP_ITERATION_COUNT_1', + tags: [ 'ITERATION_COUNT' ], + additions: { + fragmentIterations: '#define ITERATION_COUNT 1.0\n#define WARP_ITERATION_COUNT 1.0' + } + }, + { + name: 'NORMALMAP', + tags: [ 'NORMALMAP' ], + additions: { + fragmentNormalMap: '#define NORMAL_MAP\n#extension GL_OES_standard_derivatives : enable' + }, + disable: !config.noiseNormalMap + } + ], + setupUniforms: this._setupUniforms, + updateShaderConfig: this._updateShaderConfig + }; + + Shader.call(this, scene, shaderConfig, x, y, width, height); + + this.type = 'NoiseSimplex2D'; + + /** + * The number of cells in each dimension. + * + * This must be an array of 2 numbers. + * + * Try to keep the cell count between 2 + * and about an eighth of the resolution of the texture. + * A cell count greater than the resolution of the texture + * will essentially be expensive white noise. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseCells + * @type {number[]} + * @default [ 32, 32 ] + * @since 4.0.0 + */ + this.noiseCells = config.noiseCells || [ 32, 32 ]; + + /** + * The number of cells before the pattern wraps. + * + * This must be an array of 2 numbers. + * + * By default, this is the same as `noiseCells`. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noisePeriod + * @type {number[]} + * @default [ 32, 32 ] + * @since 4.0.0 + */ + this.noisePeriod = [ + this.noiseCells[0], + this.noiseCells[1] + ]; + if (config.noisePeriod) + { + this.noisePeriod = config.noisePeriod; + } + + /** + * The offset of the noise in each dimension: [ x, y ]. + * Animate x and y to scroll the noise pattern. + * + * This must be an array of 2 numbers. + * + * @example + * // Scroll the noise pattern without changing the pattern. + * noise.noiseOffset[0] = Math.sin(scene.time.now / 10000); + * noise.noiseOffset[1] = Math.cos(scene.time.now / 10000); + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseOffset + * @type {number[]} + * @default [ 0, 0 ] + * @since 4.0.0 + */ + this.noiseOffset = [ 0, 0 ]; + if (config.noiseOffset) + { + this.noiseOffset = config.noiseOffset; + } + + /** + * The current flow of the noise field. + * The pattern changes in place with flow. + * This is a rotation, so the pattern returns to its original state + * after flow increases by PI * 2. + * + * Use flow to evolve the pattern over time with periodic repeats. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseFlow + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.noiseFlow = config.noiseFlow || 0; + + /** + * How much to warp the noise texture. + * Warp can add a sense of turbulence to the output. + * + * This runs several octaves of noise to generate a random warp offset. + * It adds to the expense of the shader. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseWarpAmount + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.noiseWarpAmount = config.noiseWarpAmount || 0; + + /** + * How many octaves of noise to apply. + * This adds fine detail to the noise, at the cost of performance. + * + * This value should be an integer of 1 or higher. + * Values above 5 or so have increasingly little effect. + * Each iteration has a cost, so only use as much as you need! + * + * Use `noiseDetailPower`, `noiseFlowPower` and `noiseContributionPower` + * to configure differences between octaves. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseIterations + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseIterations = config.noiseIterations || 1; + + /** + * How many octaves of noise to apply when warping the noise. + * + * This behaves much like `noiseIterations`, + * but is used in the warp calculations instead. + * It is only used when `noiseWarpAmount` is not 0. + * You may need fewer warp iterations than regular iterations. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseWarpIterations + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseWarpIterations = config.noiseWarpIterations || 1; + + /** + * How much to increase detail frequency between noise octaves. + * + * This is used as the base of an exponent. + * The default 2 doubles the frequency every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseDetailPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseDetailPower = config.noiseDetailPower || 2; + + /** + * How much to increase flow progression between noise octaves. + * + * This is used as the base of an exponent. + * The default 2 doubles the flow progression every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseFlowPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseFlowPower = config.noiseFlowPower || 2; + + /** + * How much value to take from subsequent noise octaves. + * + * This is used as the base of an exponent. + * The default 2 halves the contribution every octave. + * Lower values decay slower, prioritize high frequency detail. + * Higher values decay faster, prioritize low frequency detail. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseContributionPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseContributionPower = config.noiseContributionPower || 2; + + /** + * How much to increase detail frequency between noise octaves + * in the warp. + * + * This is used as the base of an exponent. + * The default 2 doubles the frequency every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseWarpDetailPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseWarpDetailPower = config.noiseWarpDetailPower || 2; + + /** + * How much to increase flow progression between noise octaves + * in the warp. + * + * This is used as the base of an exponent. + * The default 2 doubles the flow progression every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseWarpFlowPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseWarpFlowPower = config.noiseWarpFlowPower || 2; + + /** + * How much value to take from subsequent noise octaves + * in the warp. + * + * This is used as the base of an exponent. + * The default 2 halves the contribution every octave. + * Lower values decay slower, prioritize high frequency detail. + * Higher values decay faster, prioritize low frequency detail. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseWarpContributionPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseWarpContributionPower = config.noiseWarpContributionPower || 2; + + /** + * Whether to convert the noise output to a normal map. + * + * Control the curvature strength with `noiseNormalScale`. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseNormalMap + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.noiseNormalMap = !!config.noiseNormalMap; + + /** + * Curvature strength of normal map output. + * This is used when `noiseNormalMap` is enabled. + * + * The default is 1. Higher values produce more curvature; + * lower values are flatter. + * + * Surface angle is determined by the rate of change of the noise. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseNormalScale + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseNormalScale = 1; + if (config.noiseNormalScale !== undefined) + { + this.noiseNormalScale = config.noiseNormalScale; + } + + /** + * Factor applied to the raw noise output. + * + * Raw noise is emitted in the range -1 to 1. + * It is adjusted by (rawNoise * noiseValueFactor + noiseValueAdd) ^ noiseValuePower. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseValueFactor + * @type {number} + * @default 0.5 + * @since 4.0.0 + */ + this.noiseValueFactor = config.noiseValueFactor === undefined ? 0.5 : config.noiseValueFactor; + + /** + * Value added to the raw noise output. + * + * Raw noise is emitted in the range -1 to 1. + * It is adjusted by (rawNoise * noiseValueFactor + noiseValueAdd) ^ noiseValuePower. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseValueAdd + * @type {number} + * @default 0.5 + * @since 4.0.0 + */ + this.noiseValueAdd = config.noiseValueAdd === undefined ? 0.5 : config.noiseValueAdd; + + /** + * Exponent applied to the raw noise output. + * + * Raw noise is emitted in the range -1 to 1. + * It is adjusted by (rawNoise * noiseValueFactor + noiseValueAdd) ^ noiseValuePower. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseValuePower + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseValuePower = config.noiseValuePower === undefined ? 1 : config.noiseValuePower; + + /** + * The color when the adjusted noise value is 0. + * This blends with noiseColorEnd. + * + * The default is black. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseColorStart + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorStart = new Color(0, 0, 0); + + /** + * The color when the adjusted noise value is 1. + * This blends with noiseColorStart. + * + * The default is white. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseColorEnd + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorEnd = new Color(255, 255, 255); + + if (config.noiseColorStart !== undefined || config.noiseColorEnd !== undefined) + { + this.setNoiseColor(config.noiseColorStart, config.noiseColorEnd); + } + + /** + * The seed for the noise. + * + * This offsets the simplex grid, causing its hashes to evaluate + * differently. Any change to the seed results in a new pattern. + * It must be an array of 2 numbers. + * + * Use a custom seed to create different, but reproducible, + * randomness. + * + * @name Phaser.GameObjects.NoiseSimplex2D#noiseSeed + * @type {number[]} + * @default [ 1, 2 ] + * @since 4.0.0 + */ + this.noiseSeed = config.noiseSeed || [ 1, 2 ]; + }, + + /** + * Set the colors of the noise, from a variety of color formats. + * + * - A number is expected to be a 24 or 32 bit RGB or ARGB value. + * - A string is expected to be a hex code. + * - An array of numbers is expected to be RGB or RGBA in the range 0-1. + * - A Color object can be used. + * + * @method Phaser.GameObjects.NoiseSimplex2D#setNoiseColor + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} [start=0x000000] - The color when the noise value is 0, corresponding to `noiseColorStart`. + * @param {number | string | number[] | Phaser.Display.Color} [end=0xffffff] - The color when the noise value is 1, corresponding to `noiseColorEnd`. + * @return {this} This game object. + */ + setNoiseColor: function (start, end) + { + var alpha; + + if (start === undefined) + { + start = 0x000000; + } + if (end === undefined) + { + end = 0xffffff; + } + + if (typeof start === 'number') + { + Color.IntegerToColor(start, this.noiseColorStart); + } + else if (typeof start === 'string') + { + Color.HexStringToColor(start, this.noiseColorStart); + } + else if (Array.isArray(start)) + { + alpha = (start[3] === undefined) ? 1 : start[3]; + this.noiseColorStart.setGLTo(start[0], start[1], start[2], alpha); + } + else if (start instanceof Color) + { + this.noiseColorStart.setTo(start.red, start.green, start.blue, start.alpha); + } + + if (typeof end === 'number') + { + Color.IntegerToColor(end, this.noiseColorEnd); + } + else if (typeof end === 'string') + { + Color.HexStringToColor(end, this.noiseColorEnd); + } + else if (Array.isArray(end)) + { + alpha = (end[3] === undefined) ? 1 : end[3]; + this.noiseColorEnd.setGLTo(end[0], end[1], end[2], alpha); + } + else if (end instanceof Color) + { + this.noiseColorEnd.setTo(end.red, end.green, end.blue, end.alpha); + } + + return this; + }, + + /** + * Randomize the noise seed, creating a unique pattern. + * + * @method Phaser.GameObjects.NoiseSimplex2D#randomizeNoiseSeed + * @since 4.0.0 + * @return {this} This game object. + */ + randomizeNoiseSeed: function () + { + var len = this.noiseSeed.length; + for (var i = 0; i < len; i++) + { + this.noiseSeed[i] = Math.random(); + } + return this; + }, + + /** + * Set the noise texture to wrap seamlessly. + * + * This sets `noisePeriod` to equal `noiseCells` in all dimensions. + * + * @method Phaser.GameObjects.NoiseSimplex2D#wrapNoise + * @since 4.0.0 + * @return {this} This game object. + */ + wrapNoise: function () + { + var len = this.noisePeriod.length; + for (var i = 0; i < len; i++) + { + this.noisePeriod[i] = this.noiseCells[i]; + } + return this; + }, + + /** + * The function which sets uniforms for the shader. + * This is provided to the Shader base class as `setupUniforms`. + * You should not override `setupUniforms` on this object. + * + * @method Phaser.GameObjects.NoiseSimplex2D#_setupUniforms + * @private + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + _setupUniforms: function (setUniform) + { + setUniform('uCells', this.noiseCells); + setUniform('uPeriod', this.noisePeriod); + setUniform('uOffset', this.noiseOffset); + setUniform('uFlow', this.noiseFlow); + setUniform('uDetailPower', this.noiseDetailPower); + setUniform('uFlowPower', this.noiseFlowPower); + setUniform('uContributionPower', this.noiseContributionPower); + setUniform('uWarpDetailPower', this.noiseWarpDetailPower); + setUniform('uWarpFlowPower', this.noiseWarpFlowPower); + setUniform('uWarpContributionPower', this.noiseWarpContributionPower); + setUniform('uWarpAmount', this.noiseWarpAmount); + setUniform('uNormalScale', this.noiseNormalScale); + setUniform('uValueFactor', this.noiseValueFactor); + setUniform('uValueAdd', this.noiseValueAdd); + setUniform('uValuePower', this.noiseValuePower); + setUniform('uColorStart', this.noiseColorStart.gl); + setUniform('uColorEnd', this.noiseColorEnd.gl); + setUniform('uSeed', this.noiseSeed); + }, + + /** + * The function which updates shader configuration. + * This is provided to the Shader base class as `updateShaderConfig`. + * You should not override `updateShaderConfig` on this object. + * + * @method Phaser.GameObjects.NoiseSimplex2D#_updateShaderConfig + * @private + * @since 4.0.0 + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + * @param {Phaser.GameObjects.NoiseSimplex2D} gameObject - The game object which is rendering. + * @param {Phaser.Renderer.WebGL.RenderNodes.ShaderQuad} renderNode - The render node currently rendering. + */ + _updateShaderConfig: function (drawingContext, gameObject, renderNode) + { + var iterations = Math.max(1, Math.floor(gameObject.noiseIterations)); + var warpIterations = Math.max(1, Math.floor(gameObject.noiseWarpIterations)); + var iterationAdd = renderNode.programManager.getAdditionsByTag('ITERATION_COUNT')[0]; + iterationAdd.name = 'ITERATION_COUNT_' + iterations + '_WARP_ITERATION_COUNT_' + warpIterations; + iterationAdd.additions.fragmentIterations = '#define ITERATION_COUNT ' + iterations + '.0' + '\n' + '#define WARP_ITERATION_COUNT ' + warpIterations + '.0'; + + var normalAdd = renderNode.programManager.getAdditionsByTag('NORMALMAP')[0]; + normalAdd.disable = !gameObject.noiseNormalMap; + } +}); + +module.exports = NoiseSimplex2D; + + +/***/ }, + +/***/ 51754 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var NoiseSimplex2D = __webpack_require__(1792); + +/** + * Creates a new NoiseSimplex2D Game Object and returns it. + * + * Note: This method will only be available if the NoiseSimplex2D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#noisesimplex2d + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.NoiseSimplex2D.NoiseSimplex2DConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.NoiseSimplex2D} The Game Object that was created. + */ +GameObjectCreator.register('noisesimplex2d', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var noisesimplex2d = new NoiseSimplex2D(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, noisesimplex2d, config); + + return noisesimplex2d; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 80308 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var NoiseSimplex2D = __webpack_require__(1792); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new NoiseSimplex2D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the NoiseSimplex2D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#noisesimplex2d + * @webglOnly + * @since 4.0.0 + * + * @param {(string|Phaser.Types.GameObjects.NoiseSimplex2D.NoiseSimplex2DQuadConfig)} [config] - The configuration object this NoiseSimplex2D will use. This defines the shape and appearance of the NoiseSimplex2D texture. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * + * @return {Phaser.GameObjects.NoiseSimplex2D} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('noisesimplex2d', function (config, x, y, width, height) + { + return this.displayList.add(new NoiseSimplex2D(this.scene, config, x, y, width, height)); + }); +} + + +/***/ }, + +/***/ 51098 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var Class = __webpack_require__(83419); +var Shader = __webpack_require__(20071); +var Color = __webpack_require__(40987); +var NoiseSimplex3DFrag = __webpack_require__(13460); + +/** + * @classdesc + * A NoiseSimplex3D object. + * + * This game object is a quad which displays simplex noise. + * You can manipulate this object like any other, make it interactive, + * and use it in filters and masks to create visually stunning effects. + * + * Behind the scenes, a NoiseSimplex3D is a {@see Phaser.GameObjects.Shader} + * using a specific shader program. + * + * Simplex noise is a smooth pattern ideal for soft, natural phenomena. + * It is useful for clouds, flame, water, and many other effects. + * Ken Perlin, the creator of Perlin Noise, created Simplex Noise + * to improve performance and quality over the original. + * + * By default, the noise pattern is periodic: it repeats. + * You can scroll in X, Y, and Z. + * You can also change the `noiseFlow` value to evolve the pattern + * along a periodic course. This is useful to avoid scrolling into + * regions of reduced floating-point precision with very large numbers. + * + * You can set the cell count, color and transparency of the pattern. + * You can add fine detail with `noiseIterations`. + * You can add turbulence with `noiseWarpAmount`. + * + * You can change the basic pattern with `noiseSeed`. + * Different seeds create completely different patterns. + * You must use integers for the seed, or bad things will happen. + * + * You can set `noiseNormalMap` to output a normal map. + * This is a quick way to add texture for lighting. + * + * For advanced users, you can configure the characteristics of octave iteration. + * Use `noiseDetailPower`, `noiseFlowPower`, and `noiseContributionPower` + * to adjust the exponential scaling rate of these values. + * Use `noiseWarpDetailPower`, `noiseWarpFlowPower`, and + * `noiseWarpContributionPower` to do the same for the warp effect. + * + * @class NoiseSimplex3D + * @extends Phaser.GameObjects.Shader + * @memberof Phaser.GameObjects + * @since 4.0.0 + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Types.GameObjects.NoiseSimplex3D.NoiseSimplex3DQuadConfig} [config] - The configuration for this Game Object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + */ +var NoiseSimplex3D = new Class({ + Extends: Shader, + + initialize: function NoiseSimplex3D (scene, config, x, y, width, height) + { + if (!config) { config = {}; } + + var shaderConfig = { + name: 'noiseSimplex3D', + fragmentSource: NoiseSimplex3DFrag, + shaderAdditions: [ + { + name: 'ITERATION_COUNT_1_WARP_ITERATION_COUNT_1', + tags: [ 'ITERATION_COUNT' ], + additions: { + fragmentIterations: '#define ITERATION_COUNT 1.0\n#define WARP_ITERATION_COUNT 1.0' + } + }, + { + name: 'NORMALMAP', + tags: [ 'NORMALMAP' ], + additions: { + fragmentNormalMap: '#define NORMAL_MAP\n#extension GL_OES_standard_derivatives : enable' + }, + disable: !config.noiseNormalMap + } + ], + setupUniforms: this._setupUniforms, + updateShaderConfig: this._updateShaderConfig + }; + + Shader.call(this, scene, shaderConfig, x, y, width, height); + + this.type = 'NoiseSimplex3D'; + + /** + * The number of cells in each dimension. + * + * This must be an array of 3 numbers. + * + * Try to keep the cell count between 2 + * and about an eighth of the resolution of the texture. + * A cell count greater than the resolution of the texture + * will essentially be expensive white noise. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseCells + * @type {number[]} + * @default [ 32, 32, 32 ] + * @since 4.0.0 + */ + this.noiseCells = config.noiseCells || [ 32, 32, 32 ]; + + /** + * The number of cells before the pattern wraps. + * + * This must be an array of 3 numbers. + * + * By default, this is the same as `noiseCells`. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noisePeriod + * @type {number[]} + * @default [ 32, 32, 32 ] + * @since 4.0.0 + */ + this.noisePeriod = [ + this.noiseCells[0], + this.noiseCells[1], + this.noiseCells[2] + ]; + if (config.noisePeriod) + { + this.noisePeriod = config.noisePeriod; + } + + /** + * The offset of the noise in each dimension: [ x, y, z ]. + * Animate x and y to scroll the noise pattern. + * Animate z to change the noise pattern by shifting the volume slice. + * + * This must be an array of 3 numbers. + * + * @example + * // Scroll the noise pattern without changing the pattern. + * noise.noiseOffset[0] = Math.sin(scene.time.now / 10000); + * noise.noiseOffset[1] = Math.cos(scene.time.now / 10000); + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseOffset + * @type {number[]} + * @default [ 0, 0, 0 ] + * @since 4.0.0 + */ + this.noiseOffset = [ 0, 0, 0 ]; + if (config.noiseOffset) + { + this.noiseOffset = config.noiseOffset; + } + + /** + * The current flow of the noise field. + * The pattern changes in place with flow. + * This is a rotation, so the pattern returns to its original state + * after flow increases by PI * 2. + * + * Use flow to evolve the pattern over time with periodic repeats. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseFlow + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.noiseFlow = config.noiseFlow || 0; + + /** + * How much to warp the noise texture. + * Warp can add a sense of turbulence to the output. + * + * This runs several octaves of noise to generate a random warp offset. + * It adds to the expense of the shader. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseWarpAmount + * @type {number} + * @default 0 + * @since 4.0.0 + */ + this.noiseWarpAmount = config.noiseWarpAmount || 0; + + /** + * How many octaves of noise to apply. + * This adds fine detail to the noise, at the cost of performance. + * + * This value should be an integer of 1 or higher. + * Values above 5 or so have increasingly little effect. + * Each iteration has a cost, so only use as much as you need! + * + * Use `noiseDetailPower`, `noiseFlowPower` and `noiseContributionPower` + * to configure differences between octaves. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseIterations + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseIterations = config.noiseIterations || 1; + + /** + * How many octaves of noise to apply when warping the noise. + * + * This behaves much like `noiseIterations`, + * but is used in the warp calculations instead. + * It is only used when `noiseWarpAmount` is not 0. + * You may need fewer warp iterations than regular iterations. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseWarpIterations + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseWarpIterations = config.noiseWarpIterations || 1; + + /** + * How much to increase detail frequency between noise octaves. + * + * This is used as the base of an exponent. + * The default 2 doubles the frequency every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseDetailPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseDetailPower = config.noiseDetailPower || 2; + + /** + * How much to increase flow progression between noise octaves. + * + * This is used as the base of an exponent. + * The default 2 doubles the frequency every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseFlowPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseFlowPower = config.noiseFlowPower || 2; + + /** + * How much value to take from subsequent noise octaves. + * + * This is used as the base of an exponent. + * The default 2 halves the contribution every octave. + * Lower values decay slower, prioritize high frequency detail. + * Higher values decay faster, prioritize low frequency detail. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseContributionPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseContributionPower = config.noiseContributionPower || 2; + + /** + * How much to increase detail frequency between noise octaves + * in the warp. + * + * This is used as the base of an exponent. + * The default 2 doubles the frequency every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseWarpDetailPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseWarpDetailPower = config.noiseWarpDetailPower || 2; + + /** + * How much to increase flow progression between noise octaves + * in the warp. + * + * This is used as the base of an exponent. + * The default 2 doubles the frequency every octave. + * Lower values scale slower. + * Higher values scale higher. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseWarpFlowPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseWarpFlowPower = config.noiseWarpFlowPower || 2; + + /** + * How much value to take from subsequent noise octaves + * in the warp. + * + * This is used as the base of an exponent. + * The default 2 halves the contribution every octave. + * Lower values decay slower, prioritize high frequency detail. + * Higher values decay faster, prioritize low frequency detail. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseWarpContributionPower + * @type {number} + * @default 2 + * @since 4.0.0 + */ + this.noiseWarpContributionPower = config.noiseWarpContributionPower || 2; + + /** + * Whether to convert the noise output to a normal map. + * + * Control the curvature strength with `noiseNormalScale`. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseNormalMap + * @type {boolean} + * @default false + * @since 4.0.0 + */ + this.noiseNormalMap = !!config.noiseNormalMap; + + /** + * Curvature strength of normal map output. + * This is used when `noiseNormalMap` is enabled. + * + * The default is 1. Higher values produce more curvature; + * lower values are flatter. + * + * Surface angle is determined by the rate of change of the noise. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseNormalScale + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseNormalScale = 1; + if (config.noiseNormalScale !== undefined) + { + this.noiseNormalScale = config.noiseNormalScale; + } + + /** + * Factor applied to the raw noise output. + * + * Raw noise is emitted in the range -1 to 1. + * It is adjusted by (rawNoise * noiseValueFactor + noiseValueAdd) ^ noiseValuePower. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseValueFactor + * @type {number} + * @default 0.5 + * @since 4.0.0 + */ + this.noiseValueFactor = config.noiseValueFactor === undefined ? 0.5 : config.noiseValueFactor; + + /** + * Value added to the raw noise output. + * + * Raw noise is emitted in the range -1 to 1. + * It is adjusted by (rawNoise * noiseValueFactor + noiseValueAdd) ^ noiseValuePower. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseValueAdd + * @type {number} + * @default 0.5 + * @since 4.0.0 + */ + this.noiseValueAdd = config.noiseValueAdd === undefined ? 0.5 : config.noiseValueAdd; + + /** + * Exponent applied to the raw noise output. + * + * Raw noise is emitted in the range -1 to 1. + * It is adjusted by (rawNoise * noiseValueFactor + noiseValueAdd) ^ noiseValuePower. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseValuePower + * @type {number} + * @default 1 + * @since 4.0.0 + */ + this.noiseValuePower = config.noiseValuePower === undefined ? 1 : config.noiseValuePower; + + /** + * The color when the adjusted noise value is 0. + * This blends with noiseColorEnd. + * + * The default is black. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseColorStart + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorStart = new Color(0, 0, 0); + + /** + * The color when the adjusted noise value is 1. + * This blends with noiseColorStart. + * + * The default is white. You can set any color, and change the alpha. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseColorEnd + * @type {Phaser.Display.Color} + * @since 4.0.0 + */ + this.noiseColorEnd = new Color(255, 255, 255); + + if (config.noiseColorStart !== undefined || config.noiseColorEnd !== undefined) + { + this.setNoiseColor(config.noiseColorStart, config.noiseColorEnd); + } + + /** + * The seed for the noise. + * + * This offsets the simplex grid, causing its hashes to evaluate + * differently. Any change to the seed results in a new pattern. + * It must be an array of 3 integers. + * + * Use a custom seed to create different, but reproducible, + * randomness. + * + * @name Phaser.GameObjects.NoiseSimplex3D#noiseSeed + * @type {number[]} + * @default [ 1, 2, 3 ] + * @since 4.0.0 + */ + this.noiseSeed = config.noiseSeed || [ 1, 2, 3 ]; + }, + + /** + * Set the colors of the noise, from a variety of color formats. + * + * - A number is expected to be a 24 or 32 bit RGB or ARGB value. + * - A string is expected to be a hex code. + * - An array of numbers is expected to be RGB or RGBA in the range 0-1. + * - A Color object can be used. + * + * @method Phaser.GameObjects.NoiseSimplex3D#setNoiseColor + * @since 4.0.0 + * @param {number | string | number[] | Phaser.Display.Color} [start=0x000000] - The color when the adjusted noise value is 0 (minimum). Defaults to black. + * @param {number | string | number[] | Phaser.Display.Color} [end=0xffffff] - The color when the adjusted noise value is 1 (maximum). Defaults to white. + * @return {this} This game object. + */ + setNoiseColor: function (start, end) + { + var alpha; + + if (start === undefined) + { + start = 0x000000; + } + if (end === undefined) + { + end = 0xffffff; + } + + if (typeof start === 'number') + { + Color.IntegerToColor(start, this.noiseColorStart); + } + else if (typeof start === 'string') + { + Color.HexStringToColor(start, this.noiseColorStart); + } + else if (Array.isArray(start)) + { + alpha = (start[3] === undefined) ? 1 : start[3]; + this.noiseColorStart.setGLTo(start[0], start[1], start[2], alpha); + } + else if (start instanceof Color) + { + this.noiseColorStart.setTo(start.red, start.green, start.blue, start.alpha); + } + + if (typeof end === 'number') + { + Color.IntegerToColor(end, this.noiseColorEnd); + } + else if (typeof end === 'string') + { + Color.HexStringToColor(end, this.noiseColorEnd); + } + else if (Array.isArray(end)) + { + alpha = (end[3] === undefined) ? 1 : end[3]; + this.noiseColorEnd.setGLTo(end[0], end[1], end[2], alpha); + } + else if (end instanceof Color) + { + this.noiseColorEnd.setTo(end.red, end.green, end.blue, end.alpha); + } + + return this; + }, + + /** + * Randomize the noise seed, creating a unique pattern. + * + * @method Phaser.GameObjects.NoiseSimplex3D#randomizeNoiseSeed + * @since 4.0.0 + * @return {this} This game object. + */ + randomizeNoiseSeed: function () + { + var len = this.noiseSeed.length; + for (var i = 0; i < len; i++) + { + this.noiseSeed[i] = Math.random(); + } + return this; + }, + + /** + * Set the noise texture to wrap seamlessly. + * + * This sets `noisePeriod` to equal `noiseCells` in all dimensions. + * + * @method Phaser.GameObjects.NoiseSimplex3D#wrapNoise + * @since 4.0.0 + * @return {this} This game object. + */ + wrapNoise: function () + { + var len = this.noisePeriod.length; + for (var i = 0; i < len; i++) + { + this.noisePeriod[i] = this.noiseCells[i]; + } + return this; + }, + + /** + * The function which sets uniforms for the shader. + * This is provided to the Shader base class as `setupUniforms`. + * You should not override `setupUniforms` on this object. + * + * @method Phaser.GameObjects.NoiseSimplex3D#_setupUniforms + * @private + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + _setupUniforms: function (setUniform) + { + setUniform('uCells', this.noiseCells); + setUniform('uPeriod', this.noisePeriod); + setUniform('uOffset', this.noiseOffset); + setUniform('uFlow', this.noiseFlow); + setUniform('uDetailPower', this.noiseDetailPower); + setUniform('uFlowPower', this.noiseFlowPower); + setUniform('uContributionPower', this.noiseContributionPower); + setUniform('uWarpDetailPower', this.noiseWarpDetailPower); + setUniform('uWarpFlowPower', this.noiseWarpFlowPower); + setUniform('uWarpContributionPower', this.noiseWarpContributionPower); + setUniform('uWarpAmount', this.noiseWarpAmount); + setUniform('uNormalScale', this.noiseNormalScale); + setUniform('uValueFactor', this.noiseValueFactor); + setUniform('uValueAdd', this.noiseValueAdd); + setUniform('uValuePower', this.noiseValuePower); + setUniform('uColorStart', this.noiseColorStart.gl); + setUniform('uColorEnd', this.noiseColorEnd.gl); + setUniform('uSeed', this.noiseSeed); + }, + + /** + * The function which updates shader configuration. + * This is provided to the Shader base class as `updateShaderConfig`. + * You should not override `updateShaderConfig` on this object. + * + * @method Phaser.GameObjects.NoiseSimplex3D#_updateShaderConfig + * @private + * @since 4.0.0 + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + * @param {Phaser.GameObjects.Gradient} gameObject - The game object which is rendering. + * @param {Phaser.Renderer.WebGL.RenderNodes.ShaderQuad} renderNode - The render node currently rendering. + */ + _updateShaderConfig: function (drawingContext, gameObject, renderNode) + { + var iterations = Math.max(1, Math.floor(gameObject.noiseIterations)); + var warpIterations = Math.max(1, Math.floor(gameObject.noiseWarpIterations)); + var iterationAdd = renderNode.programManager.getAdditionsByTag('ITERATION_COUNT')[0]; + iterationAdd.name = 'ITERATION_COUNT_' + iterations + '_WARP_ITERATION_COUNT_' + warpIterations; + iterationAdd.additions.fragmentIterations = '#define ITERATION_COUNT ' + iterations + '.0' + '\n' + '#define WARP_ITERATION_COUNT ' + warpIterations + '.0'; + + var normalAdd = renderNode.programManager.getAdditionsByTag('NORMALMAP')[0]; + normalAdd.disable = !gameObject.noiseNormalMap; + } +}); + +module.exports = NoiseSimplex3D; + + +/***/ }, + +/***/ 71112 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var NoiseSimplex3D = __webpack_require__(51098); + +/** + * Creates a new NoiseSimplex3D Game Object and returns it. + * + * Note: This method will only be available if the NoiseSimplex3D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#noisesimplex3d + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.NoiseSimplex3D.NoiseSimplex3DConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.NoiseSimplex3D} The Game Object that was created. + */ +GameObjectCreator.register('noisesimplex3d', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var noisesimplex3d = new NoiseSimplex3D(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, noisesimplex3d, config); + + return noisesimplex3d; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 73810 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} +*/ + +var NoiseSimplex3D = __webpack_require__(51098); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new NoiseSimplex3D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the NoiseSimplex3D Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#noisesimplex3d + * @webglOnly + * @since 4.0.0 + * + * @param {(string|Phaser.Types.GameObjects.NoiseSimplex3D.NoiseSimplex3DQuadConfig)} [config] - The configuration object this NoiseSimplex3D will use. This defines the shape and appearance of the NoiseSimplex3D texture. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * + * @return {Phaser.GameObjects.NoiseSimplex3D} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('noisesimplex3d', function (config, x, y, width, height) + { + return this.displayList.add(new NoiseSimplex3D(this.scene, config, x, y, width, height)); + }); +} + + +/***/ }, + +/***/ 76472 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var EmitterOp = __webpack_require__(44777); +var GetColor = __webpack_require__(37589); +var GetEaseFunction = __webpack_require__(6113); +var GetInterpolationFunction = __webpack_require__(91389); +var IntegerToRGB = __webpack_require__(90664); + +/** + * @classdesc + * A specialized emitter op that manages the `color` property of a Particle over + * its lifetime. Unlike scalar emitter ops, `EmitterColorOp` accepts an array of + * hexadecimal color values (e.g. `[0xff0000, 0x00ff00, 0x0000ff]`) and smoothly + * interpolates between them as the particle ages, producing gradient color + * transitions from birth to death. + * + * The color array is decomposed into separate red, green, and blue component + * arrays on configuration, and a linear interpolation function is used each + * update step to recombine them into the current packed RGB color value. + * + * This class is created and managed automatically by the `ParticleEmitter` when + * a `color` property is present in the emitter configuration; you do not normally + * need to instantiate it directly. + * + * See the `ParticleEmitter` class for more details on emitter op configuration. + * + * @class EmitterColorOp + * @extends Phaser.GameObjects.Particles.EmitterOp + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.60.0 + * + * @param {string} key - The name of the property. + */ +var EmitterColorOp = new Class({ + + Extends: EmitterOp, + + initialize: + + function EmitterColorOp (key) + { + EmitterOp.call(this, key, null, false); + + this.active = false; + + this.easeName = 'Linear'; + + /** + * An array containing the red color values. + * + * Populated during the `setMethods` method. + * + * @name Phaser.GameObjects.Particles.EmitterColorOp#r + * @type {number[]} + * @since 3.60.0 + */ + this.r = []; + + /** + * An array containing the green color values. + * + * Populated during the `setMethods` method. + * + * @name Phaser.GameObjects.Particles.EmitterColorOp#g + * @type {number[]} + * @since 3.60.0 + */ + this.g = []; + + /** + * An array containing the blue color values. + * + * Populated during the `setMethods` method. + * + * @name Phaser.GameObjects.Particles.EmitterColorOp#b + * @type {number[]} + * @since 3.60.0 + */ + this.b = []; + }, + + /** + * Checks the type of `EmitterOp.propertyValue` to determine which + * method is required in order to return values from this op function. + * + * @method Phaser.GameObjects.Particles.EmitterColorOp#getMethod + * @since 3.60.0 + * + * @return {number} Either `0` if no color property value is set, or `9` if a color array is configured. The result should be passed to `setMethods`. + */ + getMethod: function () + { + return (this.propertyValue === null) ? 0 : 9; + }, + + /** + * Configures the emit and update callbacks for this color op based on the + * current `method` value. When a color array is present (method 9), it + * decomposes each packed hex color in `propertyValue` into separate red, + * green, and blue component arrays, sets up the linear easing and + * interpolation functions, and assigns the eased emit and update handlers. + * If no color value is set (method 0), the default no-op handlers are used. + * + * @method Phaser.GameObjects.Particles.EmitterColorOp#setMethods + * @since 3.60.0 + * + * @return {this} This Emitter Op object. + */ + setMethods: function () + { + var value = this.propertyValue; + var current = value; + + var onEmit = this.defaultEmit; + var onUpdate = this.defaultUpdate; + + if (this.method === 9) + { + this.start = value[0]; + this.ease = GetEaseFunction('Linear'); + this.interpolation = GetInterpolationFunction('linear'); + + onEmit = this.easedValueEmit; + onUpdate = this.easeValueUpdate; + current = value[0]; + + this.active = true; + + this.r.length = 0; + this.g.length = 0; + this.b.length = 0; + + // Populate the r,g,b arrays + for (var i = 0; i < value.length; i++) + { + // in hex format 0xff0000 + var color = IntegerToRGB(value[i]); + + this.r.push(color.r); + this.g.push(color.g); + this.b.push(color.b); + } + } + + this.onEmit = onEmit; + this.onUpdate = onUpdate; + this.current = current; + + return this; + }, + + /** + * Sets the Ease function to use for Color interpolation. + * + * @method Phaser.GameObjects.Particles.EmitterColorOp#setEase + * @since 3.60.0 + * + * @param {string} ease - The string-based name of the Ease function to use. + */ + setEase: function (value) + { + this.easeName = value; + + this.ease = GetEaseFunction(value); + }, + + /** + * An `onEmit` callback for an eased property. + * + * It prepares the particle for easing by {@link Phaser.GameObjects.Particles.EmitterColorOp#easeValueUpdate}. + * + * @method Phaser.GameObjects.Particles.EmitterColorOp#easedValueEmit + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * + * @return {number} {@link Phaser.GameObjects.Particles.EmitterColorOp#start}, as the new value of the property. + */ + easedValueEmit: function () + { + this.current = this.start; + + return this.start; + }, + + /** + * An `onUpdate` callback that returns an interpolated packed RGB color value + * across the configured color array, based on the particle's current + * normalized lifetime. + * + * @method Phaser.GameObjects.Particles.EmitterColorOp#easeValueUpdate + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * + * @return {number} The new value of the property. + */ + easeValueUpdate: function (particle, key, t) + { + var v = this.ease(t); + + var r = this.interpolation(this.r, v); + var g = this.interpolation(this.g, v); + var b = this.interpolation(this.b, v); + + var current = GetColor(r, g, b); + + this.current = current; + + return current; + } + +}); + +module.exports = EmitterColorOp; + + +/***/ }, + +/***/ 44777 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Between = __webpack_require__(30976); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var FloatBetween = __webpack_require__(99472); +var GetEaseFunction = __webpack_require__(6113); +var GetFastValue = __webpack_require__(95540); +var GetInterpolationFunction = __webpack_require__(91389); +var SnapTo = __webpack_require__(77720); +var Wrap = __webpack_require__(15994); + +/** + * @classdesc + * This class is responsible for taking control over a single property + * in the Particle class and managing its emission and updating functions. + * + * Particles properties such as `x`, `y`, `scaleX`, `lifespan` and others all use + * EmitterOp instances to manage them, as they can be given in a variety of + * formats: from simple values, to functions, to dynamic callbacks. + * + * See the `ParticleEmitter` class for more details on emitter op configuration. + * + * @class EmitterOp + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {string} key - The name of the property. + * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} defaultValue - The default value of the property. + * @param {boolean} [emitOnly=false] - Whether the property can only be modified when a Particle is emitted. + */ +var EmitterOp = new Class({ + + initialize: + + function EmitterOp (key, defaultValue, emitOnly) + { + if (emitOnly === undefined) { emitOnly = false; } + + /** + * The name of this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey + * @type {string} + * @since 3.0.0 + */ + this.propertyKey = key; + + /** + * The current value of this property. + * + * This can be a simple value, an array, a function or an onEmit + * configuration object. + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} + * @since 3.0.0 + */ + this.propertyValue = defaultValue; + + /** + * The default value of this property. + * + * This can be a simple value, an array, a function or an onEmit + * configuration object. + * + * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} + * @since 3.0.0 + */ + this.defaultValue = defaultValue; + + /** + * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. + * + * @name Phaser.GameObjects.Particles.EmitterOp#steps + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.steps = 0; + + /** + * The step counter for stepped easing, per emit. + * + * @name Phaser.GameObjects.Particles.EmitterOp#counter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.counter = 0; + + /** + * When the step counter reaches its maximum, should it then + * yoyo back to the start again, or flip over to it? + * + * @name Phaser.GameObjects.Particles.EmitterOp#yoyo + * @type {boolean} + * @default false + * @since 3.60.0 + */ + this.yoyo = false; + + /** + * The counter direction. 0 for up and 1 for down. + * + * @name Phaser.GameObjects.Particles.EmitterOp#direction + * @type {number} + * @default 0 + * @since 3.60.0 + */ + this.direction = 0; + + /** + * The start value for this property to ease between. + * + * If an interpolation this holds a reference to the number data array. + * + * @name Phaser.GameObjects.Particles.EmitterOp#start + * @type {number|number[]} + * @default 0 + * @since 3.0.0 + */ + this.start = 0; + + /** + * The most recently calculated value. Updated every time an + * emission or update method is called. Treat as read-only. + * + * @name Phaser.GameObjects.Particles.EmitterOp#current + * @type {number} + * @since 3.60.0 + */ + this.current = 0; + + /** + * The end value for this property to ease between. + * + * @name Phaser.GameObjects.Particles.EmitterOp#end + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.end = 0; + + /** + * The easing function to use for updating this property, if any. + * + * @name Phaser.GameObjects.Particles.EmitterOp#ease + * @type {?function} + * @since 3.0.0 + */ + this.ease = null; + + /** + * The interpolation function to use for updating this property, if any. + * + * @name Phaser.GameObjects.Particles.EmitterOp#interpolation + * @type {?function} + * @since 3.60.0 + */ + this.interpolation = null; + + /** + * Whether this property can only be modified when a Particle is emitted. + * + * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and + * affect this property. + * + * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly + * @type {boolean} + * @since 3.0.0 + */ + this.emitOnly = emitOnly; + + /** + * The callback to run for Particles when they are emitted from the Particle Emitter. + * + * @name Phaser.GameObjects.Particles.EmitterOp#onEmit + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitCallback} + * @since 3.0.0 + */ + this.onEmit = this.defaultEmit; + + /** + * The callback to run for Particles when they are updated. + * + * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateCallback} + * @since 3.0.0 + */ + this.onUpdate = this.defaultUpdate; + + /** + * Set to `false` to disable this EmitterOp. + * + * @name Phaser.GameObjects.Particles.EmitterOp#active + * @type {boolean} + * @since 3.60.0 + */ + this.active = true; + + /** + * The onEmit method type of this EmitterOp. + * + * Set as part of `setMethod` and cached here to avoid + * re-setting when only the value changes. + * + * @name Phaser.GameObjects.Particles.EmitterOp#method + * @type {number} + * @since 3.60.0 + */ + this.method = 0; + + /** + * The callback to run for Particles when they are emitted from the Particle Emitter. + * This is set during `setMethods` and used by `proxyEmit`. + * + * @name Phaser.GameObjects.Particles.EmitterOp#_onEmit + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitCallback} + * @private + * @since 3.60.0 + */ + this._onEmit; + + /** + * The callback to run for Particles when they are updated. + * This is set during `setMethods` and used by `proxyUpdate`. + * + * @name Phaser.GameObjects.Particles.EmitterOp#_onUpdate + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateCallback} + * @private + * @since 3.60.0 + */ + this._onUpdate; + }, + + /** + * Load the property from a Particle Emitter configuration object. + * + * Optionally accepts a new property key to use, replacing the current one. + * + * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} [config] - Settings for the Particle Emitter that owns this property. + * @param {string} [newKey] - The new key to use for this property, if any. + */ + loadConfig: function (config, newKey) + { + if (config === undefined) + { + config = {}; + } + + if (newKey) + { + this.propertyKey = newKey; + } + + this.propertyValue = GetFastValue( + config, + this.propertyKey, + this.defaultValue + ); + + this.method = this.getMethod(); + + this.setMethods(); + + if (this.emitOnly) + { + // Reset it back again + this.onUpdate = this.defaultUpdate; + } + }, + + /** + * Build a JSON representation of this Particle Emitter property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#toJSON + * @since 3.0.0 + * + * @return {object} A JSON representation of this Particle Emitter property. + */ + toJSON: function () + { + return JSON.stringify(this.propertyValue); + }, + + /** + * Change the current value of the property and update its callback methods. + * + * @method Phaser.GameObjects.Particles.EmitterOp#onChange + * @since 3.0.0 + * + * @param {number} value - The new numeric value of this property. + * + * @return {this} This Emitter Op object. + */ + onChange: function (value) + { + var current; + + switch (this.method) + { + // Number + // Custom Callback (onEmit only) + // Custom onEmit and/or onUpdate callbacks + case 1: + case 3: + case 8: + current = value; + break; + + // Random Array + case 2: + if (this.propertyValue.indexOf(value) >= 0) + { + current = value; + } + break; + + // Stepped start/end + case 4: + var step = (this.end - this.start) / this.steps; + current = SnapTo(value, step); + this.counter = current; + break; + + // Eased start/end + // min/max (random float or int) + // Random object (random integer) + case 5: + case 6: + case 7: + current = Clamp(value, this.start, this.end); + break; + + // Interpolation + case 9: + current = this.start[0]; + break; + } + + this.current = current; + + return this; + }, + + /** + * Checks the type of `EmitterOp.propertyValue` to determine which + * method is required in order to return values from this op function. + * + * @method Phaser.GameObjects.Particles.EmitterOp#getMethod + * @since 3.60.0 + * + * @return {number} A number between 0 and 9 which should be passed to `setMethods`. + */ + getMethod: function () + { + var value = this.propertyValue; + + // `moveToX` and `moveToY` are null by default + if (value === null) + { + return 0; + } + + var t = typeof value; + + if (t === 'number') + { + // Number + return 1; + } + else if (Array.isArray(value)) + { + // Random Array + return 2; + } + else if (t === 'function') + { + // Custom Callback + return 3; + } + else if (t === 'object') + { + if (this.hasBoth(value, 'start', 'end')) + { + if (this.has(value, 'steps')) + { + // Stepped start/end + return 4; + } + else + { + // Eased start/end + return 5; + } + } + else if (this.hasBoth(value, 'min', 'max')) + { + // min/max + return 6; + } + else if (this.has(value, 'random')) + { + // Random object + return 7; + } + else if (this.hasEither(value, 'onEmit', 'onUpdate')) + { + // Custom onEmit onUpdate + return 8; + } + else if (this.hasEither(value, 'values', 'interpolation')) + { + // Interpolation + return 9; + } + } + + return 0; + }, + + /** + * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the method returned + * from `getMethod`. The method is stored in the `EmitterOp.method` property + * and is a number between 0 and 9 inclusively. + * + * @method Phaser.GameObjects.Particles.EmitterOp#setMethods + * @since 3.0.0 + * + * @return {this} This Emitter Op object. + */ + setMethods: function () + { + var value = this.propertyValue; + var current = value; + + var onEmit = this.defaultEmit; + var onUpdate = this.defaultUpdate; + + switch (this.method) + { + // Number + case 1: + onEmit = this.staticValueEmit; + break; + + // Random Array + case 2: + onEmit = this.randomStaticValueEmit; + current = value[0]; + break; + + // Custom Callback (onEmit only) + case 3: + this._onEmit = value; + onEmit = this.proxyEmit; + current = this.defaultValue; + break; + + // Stepped start/end + case 4: + this.start = value.start; + this.end = value.end; + this.steps = value.steps; + this.counter = this.start; + this.yoyo = this.has(value, 'yoyo') ? value.yoyo : false; + this.direction = 0; + onEmit = this.steppedEmit; + current = this.start; + break; + + // Eased start/end + case 5: + this.start = value.start; + this.end = value.end; + var easeType = this.has(value, 'ease') ? value.ease : 'Linear'; + this.ease = GetEaseFunction(easeType, value.easeParams); + onEmit = (this.has(value, 'random') && value.random) ? this.randomRangedValueEmit : this.easedValueEmit; + onUpdate = this.easeValueUpdate; + current = this.start; + break; + + // min/max (random float or int) + case 6: + this.start = value.min; + this.end = value.max; + onEmit = (this.has(value, 'int') && value.int) ? this.randomRangedIntEmit : this.randomRangedValueEmit; + current = this.start; + break; + + // Random object (random integer) + case 7: + var rnd = value.random; + + if (Array.isArray(rnd)) + { + this.start = rnd[0]; + this.end = rnd[1]; + } + + onEmit = this.randomRangedIntEmit; + current = this.start; + break; + + // Custom onEmit and/or onUpdate callbacks + case 8: + this._onEmit = (this.has(value, 'onEmit')) ? value.onEmit : this.defaultEmit; + this._onUpdate = (this.has(value, 'onUpdate')) ? value.onUpdate : this.defaultUpdate; + onEmit = this.proxyEmit; + onUpdate = this.proxyUpdate; + current = this.defaultValue; + break; + + // Interpolation + case 9: + this.start = value.values; + var easeTypeI = this.has(value, 'ease') ? value.ease : 'Linear'; + this.ease = GetEaseFunction(easeTypeI, value.easeParams); + this.interpolation = GetInterpolationFunction(value.interpolation); + onEmit = this.easedValueEmit; + onUpdate = this.easeValueUpdate; + current = this.start[0]; + break; + } + + this.onEmit = onEmit; + this.onUpdate = onUpdate; + this.current = current; + + return this; + }, + + /** + * Check whether an object has the given property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#has + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key - The key of the property to look for in the object. + * + * @return {boolean} `true` if the property exists in the object, `false` otherwise. + */ + has: function (object, key) + { + return object.hasOwnProperty(key); + }, + + /** + * Check whether an object has both of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if both properties exist in the object, `false` otherwise. + */ + hasBoth: function (object, key1, key2) + { + return object.hasOwnProperty(key1) && object.hasOwnProperty(key2); + }, + + /** + * Check whether an object has at least one of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasEither + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if at least one of the properties exists in the object, `false` if neither exist. + */ + hasEither: function (object, key1, key2) + { + return object.hasOwnProperty(key1) || object.hasOwnProperty(key2); + }, + + /** + * The returned value sets what the property will be at the START of the particle's life, on emit. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + defaultEmit: function () + { + return this.defaultValue; + }, + + /** + * The returned value updates the property for the duration of the particle's life. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + defaultUpdate: function (particle, key, t, value) + { + return value; + }, + + /** + * The returned value sets what the property will be at the START of the particle's life, on emit. + * + * This method is only used when you have provided a custom emit callback. + * + * @method Phaser.GameObjects.Particles.EmitterOp#proxyEmit + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} [value] - The current value of the property. + * + * @return {number} The new value of the property. + */ + proxyEmit: function (particle, key, value) + { + var result = this._onEmit(particle, key, value); + + this.current = result; + + return result; + }, + + /** + * The returned value updates the property for the duration of the particle's life. + * + * This method is only used when you have provided a custom update callback. + * + * @method Phaser.GameObjects.Particles.EmitterOp#proxyUpdate + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + proxyUpdate: function (particle, key, t, value) + { + var result = this._onUpdate(particle, key, t, value); + + this.current = result; + + return result; + }, + + /** + * An `onEmit` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueEmit: function () + { + return this.current; + }, + + /** + * An `onUpdate` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueUpdate: function () + { + return this.current; + }, + + /** + * An `onEmit` callback that returns a random value from the current value array. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + randomStaticValueEmit: function () + { + var randomIndex = Math.floor(Math.random() * this.propertyValue.length); + + this.current = this.propertyValue[randomIndex]; + + return this.current; + }, + + /** + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The key of the property. + * + * @return {number} The new value of the property. + */ + randomRangedValueEmit: function (particle, key) + { + var value = FloatBetween(this.start, this.end); + + if (particle && particle.data[key]) + { + particle.data[key].min = value; + particle.data[key].max = this.end; + } + + this.current = value; + + return value; + }, + + /** + * An `onEmit` callback that returns a random integer value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedIntEmit + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The key of the property. + * + * @return {number} The new value of the property. + */ + randomRangedIntEmit: function (particle, key) + { + var value = Between(this.start, this.end); + + if (particle && particle.data[key]) + { + particle.data[key].min = value; + particle.data[key].max = this.end; + } + + this.current = value; + + return value; + }, + + /** + * An `onEmit` callback that returns a stepped value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + steppedEmit: function () + { + var current = this.counter; + + var next = current; + + var step = (this.end - this.start) / this.steps; + + if (this.yoyo) + { + var over; + + if (this.direction === 0) + { + // Add step to the current value + next += step; + + if (next >= this.end) + { + over = next - this.end; + + next = this.end - over; + + this.direction = 1; + } + } + else + { + // Down + next -= step; + + if (next <= this.start) + { + over = this.start - next; + + next = this.start + over; + + this.direction = 0; + } + } + + this.counter = next; + } + else + { + this.counter = Wrap(next + step, this.start, this.end); + } + + this.current = current; + + return current; + }, + + /** + * An `onEmit` callback for an eased property. + * + * It prepares the particle for easing by {@link Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate}. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * + * @return {number} {@link Phaser.GameObjects.Particles.EmitterOp#start}, as the new value of the property. + */ + easedValueEmit: function (particle, key) + { + if (particle && particle.data[key]) + { + var data = particle.data[key]; + + data.min = this.start; + data.max = this.end; + } + + this.current = this.start; + + return this.start; + }, + + /** + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * + * @return {number} The new value of the property. + */ + easeValueUpdate: function (particle, key, t) + { + var data = particle.data[key]; + + var current; + var v = this.ease(t); + + if (this.interpolation) + { + current = this.interpolation(this.start, v); + } + else + { + current = (data.max - data.min) * v + data.min; + } + + this.current = current; + + return current; + }, + + /** + * Destroys this EmitterOp instance and all of its references. + * + * Called automatically when the ParticleEmitter that owns this + * EmitterOp is destroyed. + * + * @method Phaser.GameObjects.Particles.EmitterOp#destroy + * @since 3.60.0 + */ + destroy: function () + { + this.propertyValue = null; + this.defaultValue = null; + this.ease = null; + this.interpolation = null; + this._onEmit = null; + this._onUpdate = null; + } +}); + +module.exports = EmitterOp; + + +/***/ }, + +/***/ 24502 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var ParticleProcessor = __webpack_require__(20286); + +/** + * @classdesc + * The Gravity Well Particle Processor applies a force on the particles to draw + * them towards, or repel them from, a single point. + * + * The force applied is inversely proportional to the square of the distance + * from the particle to the point, in accordance with Newton's law of gravity. + * + * This simulates the effect of gravity over large distances (as between planets, for example). + * + * @class GravityWell + * @extends Phaser.GameObjects.Particles.ParticleProcessor + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {(number|Phaser.Types.GameObjects.Particles.GravityWellConfig)} [x=0] - The x coordinate of the Gravity Well, in world space. + * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @param {number} [power=0] - The strength of the gravity force - larger numbers produce a stronger force. + * @param {number} [epsilon=100] - The minimum distance for which the gravity force is calculated. + * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + */ +var GravityWell = new Class({ + + Extends: ParticleProcessor, + + initialize: + + function GravityWell (x, y, power, epsilon, gravity) + { + if (typeof x === 'object') + { + var config = x; + + x = GetFastValue(config, 'x', 0); + y = GetFastValue(config, 'y', 0); + power = GetFastValue(config, 'power', 0); + epsilon = GetFastValue(config, 'epsilon', 100); + gravity = GetFastValue(config, 'gravity', 50); + } + else + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (power === undefined) { power = 0; } + if (epsilon === undefined) { epsilon = 100; } + if (gravity === undefined) { gravity = 50; } + } + + ParticleProcessor.call(this, x, y, true); + + /** + * Internal gravity value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_gravity + * @type {number} + * @private + * @since 3.0.0 + */ + this._gravity = gravity; + + /** + * Internal power value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_power + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._power = power * gravity; + + /** + * Internal epsilon value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_epsilon + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._epsilon = epsilon * epsilon; + }, + + /** + * Takes a Particle and updates its velocity based on the gravitational force exerted + * by this Gravity Well. The force is calculated using the squared distance between the + * particle and the well, clamped by `epsilon` to avoid extreme forces at very close range, + * then applied to the particle's horizontal and vertical velocity components. + * + * @method Phaser.GameObjects.Particles.GravityWell#update + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + */ + update: function (particle, delta) + { + var x = this.x - particle.x; + var y = this.y - particle.y; + var dSq = x * x + y * y; + + if (dSq === 0) + { + return; + } + + var d = Math.sqrt(dSq); + + if (dSq < this._epsilon) + { + dSq = this._epsilon; + } + + var factor = ((this._power * delta) / (dSq * d)) * 100; + + particle.velocityX += x * factor; + particle.velocityY += y * factor; + }, + + /** + * The minimum distance for which the gravity force is calculated, in pixels. + * + * This acts as a lower bound on the distance used in the gravity calculation, + * preventing extreme or infinite forces when a particle passes very close to + * the well's position. Increase this value to soften the effect at close range. + * + * Defaults to 100. + * + * @name Phaser.GameObjects.Particles.GravityWell#epsilon + * @type {number} + * @since 3.0.0 + */ + epsilon: { + + get: function () + { + return Math.sqrt(this._epsilon); + }, + + set: function (value) + { + this._epsilon = value * value; + } + + }, + + /** + * The strength of the gravity force - larger numbers produce a stronger attractive force. + * Negative values reverse the effect, repelling particles away from the well instead. + * + * Internally this value is scaled by `gravity`, so changing `gravity` will also affect + * the effective force even if `power` remains the same. + * + * Defaults to 0. + * + * @name Phaser.GameObjects.Particles.GravityWell#power + * @type {number} + * @since 3.0.0 + */ + power: { + + get: function () + { + return this._power / this._gravity; + }, + + set: function (value) + { + this._power = value * this._gravity; + } + + }, + + /** + * The base gravitational force of this Gravity Well. This value acts as a scalar + * that is multiplied with `power` to determine the total force applied to particles. + * Increasing `gravity` amplifies the effect of `power`; setting it to zero will + * neutralise the well regardless of the `power` value. + * + * Defaults to 50. + * + * @name Phaser.GameObjects.Particles.GravityWell#gravity + * @type {number} + * @since 3.0.0 + */ + gravity: { + + get: function () + { + return this._gravity; + }, + + set: function (value) + { + var pwr = this.power; + this._gravity = value; + this.power = pwr; + } + + } + +}); + +module.exports = GravityWell; + + +/***/ }, + +/***/ 56480 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AnimationState = __webpack_require__(9674); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var DegToRad = __webpack_require__(39506); +var Rectangle = __webpack_require__(87841); +var RotateAround = __webpack_require__(11520); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Particle is a lightweight object owned and controlled by a ParticleEmitter. Each Particle + * holds its own position, velocity, acceleration, rotation, scale, alpha, tint, and lifespan + * values, which are updated each frame by the Emitter's configured EmitterOp instances. + * Particles are pooled and recycled by the Emitter for performance. When a particle's lifespan + * expires, it is deactivated and returned to the pool for reuse rather than being destroyed. + * You do not normally create Particle instances directly; instead, the Emitter manages their + * lifecycle. You can extend this class to add custom properties by providing a custom + * `particleClass` in the emitter configuration. + * + * @class Particle + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to which this Particle belongs. + */ +var Particle = new Class({ + + initialize: + + function Particle (emitter) + { + /** + * The Emitter to which this Particle belongs. + * + * A Particle can only belong to a single Emitter and is created, updated and destroyed by it. + * + * @name Phaser.GameObjects.Particles.Particle#emitter + * @type {Phaser.GameObjects.Particles.ParticleEmitter} + * @since 3.0.0 + */ + this.emitter = emitter; + + /** + * The texture used by this Particle when it renders. + * + * @name Phaser.GameObjects.Particles.Particle#texture + * @type {Phaser.Textures.Texture} + * @default null + * @since 3.60.0 + */ + this.texture = null; + + /** + * The texture frame used by this Particle when it renders. + * + * @name Phaser.GameObjects.Particles.Particle#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * The x coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The coordinates of this Particle in world space. + * + * Updated as part of `computeVelocity`. + * + * @name Phaser.GameObjects.Particles.Particle#worldPosition + * @type {Phaser.Math.Vector2} + * @since 3.60.0 + */ + this.worldPosition = new Vector2(); + + /** + * The x velocity of this Particle, in pixels per second. + * + * @name Phaser.GameObjects.Particles.Particle#velocityX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityX = 0; + + /** + * The y velocity of this Particle, in pixels per second. + * + * @name Phaser.GameObjects.Particles.Particle#velocityY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityY = 0; + + /** + * The x acceleration of this Particle, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = 0; + + /** + * The y acceleration of this Particle, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = 0; + + /** + * The maximum horizontal velocity this Particle can travel at, in pixels per second. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityX + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = 10000; + + /** + * The maximum vertical velocity this Particle can travel at, in pixels per second. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityY + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = 10000; + + /** + * The bounciness, or restitution, of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#bounce + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bounce = 0; + + /** + * The horizontal scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleX = 1; + + /** + * The vertical scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleY = 1; + + /** + * The alpha value of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#alpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.alpha = 1; + + /** + * The angle of this Particle in degrees. + * + * @name Phaser.GameObjects.Particles.Particle#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * The angle of this Particle in radians. + * + * @name Phaser.GameObjects.Particles.Particle#rotation + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotation = 0; + + /** + * The tint applied to this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#tint + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + this.tint = 0xffffff; + + /** + * The lifespan of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#life + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.life = 1000; + + /** + * The current life of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#lifeCurrent + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.lifeCurrent = 1000; + + /** + * The delay applied to this Particle upon emission, in ms. + * + * @name Phaser.GameObjects.Particles.Particle#delayCurrent + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.delayCurrent = 0; + + /** + * The hold applied to this Particle before it expires, in ms. + * + * @name Phaser.GameObjects.Particles.Particle#holdCurrent + * @type {number} + * @default 0 + * @since 3.60.0 + */ + this.holdCurrent = 0; + + /** + * The normalized lifespan T value, where 0 is the start and 1 is the end. + * + * @name Phaser.GameObjects.Particles.Particle#lifeT + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lifeT = 0; + + /** + * An object that stores the min/max interpolation values for each of this Particle's + * properties (such as alpha, tint, scaleX, rotate, etc.) as they are eased over the + * particle's lifetime. These values are populated and used by the EmitterOp instances + * on the parent Emitter. + * + * @name Phaser.GameObjects.Particles.Particle#data + * @type {Phaser.Types.GameObjects.Particles.ParticleData} + * @since 3.0.0 + */ + this.data = { + tint: { min: 0xffffff, max: 0xffffff }, + alpha: { min: 1, max: 1 }, + rotate: { min: 0, max: 0 }, + scaleX: { min: 1, max: 1 }, + scaleY: { min: 1, max: 1 }, + x: { min: 0, max: 0 }, + y: { min: 0, max: 0 }, + accelerationX: { min: 0, max: 0 }, + accelerationY: { min: 0, max: 0 }, + maxVelocityX: { min: 0, max: 0 }, + maxVelocityY: { min: 0, max: 0 }, + moveToX: { min: 0, max: 0 }, + moveToY: { min: 0, max: 0 }, + bounce: { min: 0, max: 0 } + }; + + /** + * Internal private value. + * + * @name Phaser.GameObjects.Particles.Particle#isCropped + * @type {boolean} + * @private + * @readonly + * @since 3.60.0 + */ + this.isCropped = false; + + /** + * A reference to the Scene to which this Game Object belongs. + * + * Game Objects can only belong to one Scene. + * + * You should consider this property as being read-only. You cannot move a + * Game Object to another Scene by simply changing it. + * + * @name Phaser.GameObjects.Particles.Particle#scene + * @type {Phaser.Scene} + * @since 3.60.0 + */ + this.scene = emitter.scene; + + /** + * The Animation State component of this Particle. + * + * This component provides features to apply animations to this Particle. + * It is responsible for playing, loading, queuing animations for later playback, + * mixing between animations and setting the current animation frame to this Particle. + * + * It is created only if the Particle's Emitter has at least one Animation. + * + * @name Phaser.GameObjects.Particles.Particle#anims + * @type {?Phaser.Animations.AnimationState} + * @since 3.60.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAnim + */ + this.anims = null; + + if (this.emitter.anims.length > 0) + { + this.anims = new AnimationState(this); + } + + /** + * A rectangle that holds the bounds of this Particle after a call to + * the `Particle.getBounds` method has been made. + * + * @name Phaser.GameObjects.Particles.Particle#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.60.0 + */ + this.bounds = new Rectangle(); + }, + + /** + * The Event Emitter proxy. + * + * Passes on all parameters to the `ParticleEmitter` to emit directly. + * + * @method Phaser.GameObjects.Particles.Particle#emit + * @since 3.60.0 + * + * @param {(string|Symbol)} event - The event name. + * @param {any} [a1] - Optional argument 1. + * @param {any} [a2] - Optional argument 2. + * @param {any} [a3] - Optional argument 3. + * @param {any} [a4] - Optional argument 4. + * @param {any} [a5] - Optional argument 5. + * + * @return {boolean} `true` if the event had listeners, else `false`. + */ + emit: function (event, a1, a2, a3, a4, a5) + { + return this.emitter.emit(event, a1, a2, a3, a4, a5); + }, + + /** + * Checks to see if this Particle is alive and updating. + * + * @method Phaser.GameObjects.Particles.Particle#isAlive + * @since 3.0.0 + * + * @return {boolean} `true` if this Particle is alive and updating, otherwise `false`. + */ + isAlive: function () + { + return (this.lifeCurrent > 0); + }, + + /** + * Kills this particle. This sets the `lifeCurrent` value to 0, which forces + * the Particle to be removed the next time its parent Emitter runs an update. + * + * @method Phaser.GameObjects.Particles.Particle#kill + * @since 3.60.0 + */ + kill: function () + { + this.lifeCurrent = 0; + }, + + /** + * Sets the position of this particle to the given x/y coordinates. + * + * If the parameters are left undefined, it resets the particle back to (0, 0). + * + * @method Phaser.GameObjects.Particles.Particle#setPosition + * @since 3.60.0 + * + * @param {number} [x=0] - The x coordinate to set this Particle to. + * @param {number} [y=0] - The y coordinate to set this Particle to. + */ + setPosition: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.x = x; + this.y = y; + }, + + /** + * Starts this Particle from the given coordinates. + * + * @method Phaser.GameObjects.Particles.Particle#fire + * @since 3.0.0 + * + * @param {number} [x] - The x coordinate to launch this Particle from. + * @param {number} [y] - The y coordinate to launch this Particle from. + * + * @return {boolean} `true` if the Particle is alive, or `false` if it was spawned inside a DeathZone. + */ + fire: function (x, y) + { + var emitter = this.emitter; + var ops = emitter.ops; + + var anim = emitter.getAnim(); + + if (anim) + { + this.anims.play(anim); + } + else + { + this.frame = emitter.getFrame(); + this.texture = this.frame.texture; + } + + if (!this.frame) + { + throw new Error('Particle has no texture frame'); + } + + // Updates particle.x and particle.y during this call + emitter.getEmitZone(this); + + if (x === undefined) + { + this.x += ops.x.onEmit(this, 'x'); + } + else if (ops.x.steps > 0) + { + // EmitterOp is stepped but x was forced (follower?) so use it + this.x += x + ops.x.onEmit(this, 'x'); + } + else + { + this.x += x; + } + + if (y === undefined) + { + this.y += ops.y.onEmit(this, 'y'); + } + else if (ops.y.steps > 0) + { + // EmitterOp is stepped but y was forced (follower?) so use it + this.y += y + ops.y.onEmit(this, 'y'); + } + else + { + this.y += y; + } + + this.life = ops.lifespan.onEmit(this, 'lifespan'); + this.lifeCurrent = this.life; + this.lifeT = 0; + + this.delayCurrent = ops.delay.onEmit(this, 'delay'); + this.holdCurrent = ops.hold.onEmit(this, 'hold'); + + this.scaleX = ops.scaleX.onEmit(this, 'scaleX'); + this.scaleY = (ops.scaleY.active) ? ops.scaleY.onEmit(this, 'scaleY') : this.scaleX; + + this.angle = ops.rotate.onEmit(this, 'rotate'); + + this.rotation = DegToRad(this.angle); + + emitter.worldMatrix.transformPoint(this.x, this.y, this.worldPosition); + + // Check we didn't spawn in the middle of a DeathZone + if (this.delayCurrent === 0 && emitter.getDeathZone(this)) + { + this.lifeCurrent = 0; + + return false; + } + + var sx = ops.speedX.onEmit(this, 'speedX'); + var sy = (ops.speedY.active) ? ops.speedY.onEmit(this, 'speedY') : sx; + + if (emitter.radial) + { + var rad = DegToRad(ops.angle.onEmit(this, 'angle')); + + this.velocityX = Math.cos(rad) * Math.abs(sx); + this.velocityY = Math.sin(rad) * Math.abs(sy); + } + else if (emitter.moveTo) + { + var mx = ops.moveToX.onEmit(this, 'moveToX'); + var my = ops.moveToY.onEmit(this, 'moveToY'); + var lifeS = this.life / 1000; + + this.velocityX = (mx - this.x) / lifeS; + this.velocityY = (my - this.y) / lifeS; + } + else + { + this.velocityX = sx; + this.velocityY = sy; + } + + if (emitter.acceleration) + { + this.accelerationX = ops.accelerationX.onEmit(this, 'accelerationX'); + this.accelerationY = ops.accelerationY.onEmit(this, 'accelerationY'); + } + + this.maxVelocityX = ops.maxVelocityX.onEmit(this, 'maxVelocityX'); + this.maxVelocityY = ops.maxVelocityY.onEmit(this, 'maxVelocityY'); + + this.bounce = ops.bounce.onEmit(this, 'bounce'); + + this.alpha = ops.alpha.onEmit(this, 'alpha'); + + if (ops.color.active) + { + this.tint = ops.color.onEmit(this, 'tint'); + } + else + { + this.tint = ops.tint.onEmit(this, 'tint'); + } + + return true; + }, + + /** + * The main update method for this Particle. + * + * Updates its life values, computes the velocity and repositions the Particle. + * + * @method Phaser.GameObjects.Particles.Particle#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {Phaser.GameObjects.Particles.ParticleProcessor[]} processors - An array of all active Particle Processors. + * + * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. + */ + update: function (delta, step, processors) + { + if (this.lifeCurrent <= 0) + { + // Particle is dead via `Particle.kill` method, or being held + if (this.holdCurrent > 0) + { + this.holdCurrent -= delta; + + return (this.holdCurrent <= 0); + } + else + { + return true; + } + } + + if (this.delayCurrent > 0) + { + this.delayCurrent -= delta; + + return false; + } + + if (this.anims) + { + this.anims.update(0, delta); + } + + var emitter = this.emitter; + var ops = emitter.ops; + + // How far along in life is this particle? (t = 0 to 1) + var t = 1 - (this.lifeCurrent / this.life); + + this.lifeT = t; + + this.x = ops.x.onUpdate(this, 'x', t, this.x); + this.y = ops.y.onUpdate(this, 'y', t, this.y); + + if (emitter.moveTo) + { + var mx = ops.moveToX.onUpdate(this, 'moveToX', t, emitter.moveToX); + var my = ops.moveToY.onUpdate(this, 'moveToY', t, emitter.moveToY); + var lifeS = this.lifeCurrent / 1000; + + this.velocityX = (mx - this.x) / lifeS; + this.velocityY = (my - this.y) / lifeS; + } + + this.computeVelocity(emitter, delta, step, processors, t); + + this.scaleX = ops.scaleX.onUpdate(this, 'scaleX', t, this.scaleX); + + if (ops.scaleY.active) + { + this.scaleY = ops.scaleY.onUpdate(this, 'scaleY', t, this.scaleY); + } + else + { + this.scaleY = this.scaleX; + } + + this.angle = ops.rotate.onUpdate(this, 'rotate', t, this.angle); + + this.rotation = DegToRad(this.angle); + + if (emitter.getDeathZone(this)) + { + this.lifeCurrent = 0; + + // No need to go any further, particle has been killed + return true; + } + + this.alpha = Clamp(ops.alpha.onUpdate(this, 'alpha', t, this.alpha), 0, 1); + + if (ops.color.active) + { + this.tint = ops.color.onUpdate(this, 'color', t, this.tint); + } + else + { + this.tint = ops.tint.onUpdate(this, 'tint', t, this.tint); + } + + this.lifeCurrent -= delta; + + return (this.lifeCurrent <= 0 && this.holdCurrent <= 0); + }, + + /** + * An internal method that calculates the velocity of the Particle and + * its world position. It also runs it against any active Processors + * that are set on the Emitter. + * + * @method Phaser.GameObjects.Particles.Particle#computeVelocity + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {Phaser.GameObjects.Particles.ParticleProcessor[]} processors - An array of all active Particle Processors. + * @param {number} t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + */ + computeVelocity: function (emitter, delta, step, processors, t) + { + var ops = emitter.ops; + + var vx = this.velocityX; + var vy = this.velocityY; + + var ax = ops.accelerationX.onUpdate(this, 'accelerationX', t, this.accelerationX); + var ay = ops.accelerationY.onUpdate(this, 'accelerationY', t, this.accelerationY); + + var mx = ops.maxVelocityX.onUpdate(this, 'maxVelocityX', t, this.maxVelocityX); + var my = ops.maxVelocityY.onUpdate(this, 'maxVelocityY', t, this.maxVelocityY); + + this.bounce = ops.bounce.onUpdate(this, 'bounce', t, this.bounce); + + vx += (emitter.gravityX * step) + (ax * step); + vy += (emitter.gravityY * step) + (ay * step); + + vx = Clamp(vx, -mx, mx); + vy = Clamp(vy, -my, my); + + this.velocityX = vx; + this.velocityY = vy; + + // Integrate back in to the position + this.x += vx * step; + this.y += vy * step; + + emitter.worldMatrix.transformPoint(this.x, this.y, this.worldPosition); + + // Apply any additional processors (these can update velocity and/or position) + for (var i = 0; i < processors.length; i++) + { + var processor = processors[i]; + + if (processor.active) + { + processor.update(this, delta, step, t); + } + } + }, + + /** + * This is a NOOP method and does nothing when called. + * + * @method Phaser.GameObjects.Particles.Particle#setSizeToFrame + * @since 3.60.0 + */ + setSizeToFrame: function () + { + // NOOP + }, + + /** + * Gets the bounds of this particle as a Geometry Rectangle, factoring in any + * transforms of the parent emitter and anything else above it in the display list. + * + * Once calculated the bounds can be accessed via the `Particle.bounds` property. + * + * @method Phaser.GameObjects.Particles.Particle#getBounds + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [matrix] - Optional transform matrix to apply to this particle. + * + * @return {Phaser.Geom.Rectangle} A Rectangle containing the transformed bounds of this particle. + */ + getBounds: function (matrix) + { + if (matrix === undefined) { matrix = this.emitter.getWorldTransformMatrix(); } + + var sx = Math.abs(matrix.scaleX) * this.scaleX; + var sy = Math.abs(matrix.scaleY) * this.scaleY; + + var x = this.x; + var y = this.y; + var rotation = this.rotation; + var width = (this.frame.width * sx) / 2; + var height = (this.frame.height * sy) / 2; + + var bounds = this.bounds; + + var topLeft = new Vector2(x - width, y - height); + var topRight = new Vector2(x + width, y - height); + var bottomLeft = new Vector2(x - width, y + height); + var bottomRight = new Vector2(x + width, y + height); + + if (rotation !== 0) + { + RotateAround(topLeft, x, y, rotation); + RotateAround(topRight, x, y, rotation); + RotateAround(bottomLeft, x, y, rotation); + RotateAround(bottomRight, x, y, rotation); + } + + matrix.transformPoint(topLeft.x, topLeft.y, topLeft); + matrix.transformPoint(topRight.x, topRight.y, topRight); + matrix.transformPoint(bottomLeft.x, bottomLeft.y, bottomLeft); + matrix.transformPoint(bottomRight.x, bottomRight.y, bottomRight); + + bounds.x = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); + bounds.y = Math.min(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y); + bounds.width = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x) - bounds.x; + bounds.height = Math.max(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y) - bounds.y; + + return bounds; + }, + + /** + * Destroys this Particle by nulling its references to the emitter, texture, frame, + * and scene. If this Particle has an AnimationState, it is also destroyed. After + * calling this method the Particle should not be used again. + * + * @method Phaser.GameObjects.Particles.Particle#destroy + * @since 3.60.0 + */ + destroy: function () + { + if (this.anims) + { + this.anims.destroy(); + } + + this.anims = null; + this.emitter = null; + this.texture = null; + this.frame = null; + this.scene = null; + } + +}); + +module.exports = Particle; + + +/***/ }, + +/***/ 69601 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var ParticleProcessor = __webpack_require__(20286); +var Rectangle = __webpack_require__(87841); + +/** + * @classdesc + * The Particle Bounds Processor. + * + * Defines a rectangular region, in world space, within which particle movement + * is restrained. + * + * Use the properties `collideLeft`, `collideRight`, `collideTop` and + * `collideBottom` to control if a particle will rebound off the sides + * of this boundary, or not. + * + * This happens when the particles worldPosition x/y coordinate hits the boundary. + * + * The strength of the rebound is determined by the `Particle.bounce` property. + * + * @class ParticleBounds + * @extends Phaser.GameObjects.Particles.ParticleProcessor + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.60.0 + * + * @param {number} x - The x position (top-left) of the bounds, in world space. + * @param {number} y - The y position (top-left) of the bounds, in world space. + * @param {number} width - The width of the bounds. + * @param {number} height - The height of the bounds. + * @param {boolean} [collideLeft=true] - Whether particles interact with the left edge of the bounds. + * @param {boolean} [collideRight=true] - Whether particles interact with the right edge of the bounds. + * @param {boolean} [collideTop=true] - Whether particles interact with the top edge of the bounds. + * @param {boolean} [collideBottom=true] - Whether particles interact with the bottom edge of the bounds. + */ +var ParticleBounds = new Class({ + + Extends: ParticleProcessor, + + initialize: + + function ParticleBounds (x, y, width, height, collideLeft, collideRight, collideTop, collideBottom) + { + if (collideLeft === undefined) { collideLeft = true; } + if (collideRight === undefined) { collideRight = true; } + if (collideTop === undefined) { collideTop = true; } + if (collideBottom === undefined) { collideBottom = true; } + + ParticleProcessor.call(this, x, y, true); + + /** + * A rectangular boundary constraining particle movement. Use the ParticleBounds properties `collideLeft`, + * `collideRight`, `collideTop` and `collideBottom` to control if a particle will rebound off + * the sides of this boundary, or not. This happens when the particles x/y coordinate hits + * the boundary. + * + * @name Phaser.GameObjects.Particles.ParticleBounds#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.60.0 + */ + this.bounds = new Rectangle(x, y, width, height); + + /** + * Whether particles interact with the left edge of the {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleBounds#collideLeft + * @type {boolean} + * @default true + * @since 3.60.0 + */ + this.collideLeft = collideLeft; + + /** + * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleBounds#collideRight + * @type {boolean} + * @default true + * @since 3.60.0 + */ + this.collideRight = collideRight; + + /** + * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleBounds#collideTop + * @type {boolean} + * @default true + * @since 3.60.0 + */ + this.collideTop = collideTop; + + /** + * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleBounds#collideBottom + * @type {boolean} + * @default true + * @since 3.60.0 + */ + this.collideBottom = collideBottom; + }, + + /** + * Checks the given Particle against the boundary rectangle. If the particle's world position + * crosses an active edge, its position is clamped back inside the boundary and its velocity + * along that axis is negated and scaled by the particle's `bounce` value, causing it to rebound. + * + * @method Phaser.GameObjects.Particles.ParticleBounds#update + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + */ + update: function (particle) + { + var bounds = this.bounds; + var bounce = -particle.bounce; + var pos = particle.worldPosition; + + if (pos.x < bounds.x && this.collideLeft) + { + particle.x += bounds.x - pos.x; + particle.velocityX *= bounce; + } + else if (pos.x > bounds.right && this.collideRight) + { + particle.x -= pos.x - bounds.right; + particle.velocityX *= bounce; + } + + if (pos.y < bounds.y && this.collideTop) + { + particle.y += bounds.y - pos.y; + particle.velocityY *= bounce; + } + else if (pos.y > bounds.bottom && this.collideBottom) + { + particle.y -= pos.y - bounds.bottom; + particle.velocityY *= bounce; + } + } + +}); + +module.exports = ParticleBounds; + + +/***/ }, + +/***/ 31600 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DefaultParticleEmitterNodes = __webpack_require__(68668); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var ComponentsToJSON = __webpack_require__(53774); +var CopyFrom = __webpack_require__(43459); +var DeathZone = __webpack_require__(26388); +var EdgeZone = __webpack_require__(19909); +var EmitterColorOp = __webpack_require__(76472); +var EmitterOp = __webpack_require__(44777); +var Events = __webpack_require__(20696); +var GameObject = __webpack_require__(95643); +var GetFastValue = __webpack_require__(95540); +var GetRandom = __webpack_require__(26546); +var GravityWell = __webpack_require__(24502); +var HasAll = __webpack_require__(69036); +var HasAny = __webpack_require__(1985); +var HasValue = __webpack_require__(97022); +var Inflate = __webpack_require__(86091); +var List = __webpack_require__(73162); +var MergeRect = __webpack_require__(20074); +var MergeRight = __webpack_require__(269); +var Particle = __webpack_require__(56480); +var ParticleBounds = __webpack_require__(69601); +var RandomZone = __webpack_require__(68875); +var Rectangle = __webpack_require__(87841); +var RectangleToRectangle = __webpack_require__(59996); +var Remove = __webpack_require__(72905); +var Render = __webpack_require__(90668); +var StableSort = __webpack_require__(19186); +var TintModes = __webpack_require__(84322); +var TransformMatrix = __webpack_require__(61340); +var Vector2 = __webpack_require__(26099); +var Wrap = __webpack_require__(15994); + +/** + * Names of simple configuration properties. + * + * @ignore + */ +var configFastMap = [ + 'active', + 'advance', + 'blendMode', + 'colorEase', + 'deathCallback', + 'deathCallbackScope', + 'duration', + 'emitCallback', + 'emitCallbackScope', + 'follow', + 'frequency', + 'gravityX', + 'gravityY', + 'maxAliveParticles', + 'maxParticles', + 'name', + 'emitting', + 'particleBringToTop', + 'particleClass', + 'radial', + 'sortCallback', + 'sortOrderAsc', + 'sortProperty', + 'stopAfter', + 'tintMode', + 'timeScale', + 'trackVisible', + 'visible' +]; + +/** + * Names of complex configuration properties. + * + * @ignore + */ +var configOpMap = [ + 'accelerationX', + 'accelerationY', + 'alpha', + 'angle', + 'bounce', + 'color', + 'delay', + 'hold', + 'lifespan', + 'maxVelocityX', + 'maxVelocityY', + 'moveToX', + 'moveToY', + 'quantity', + 'rotate', + 'scaleX', + 'scaleY', + 'speedX', + 'speedY', + 'tint', + 'x', + 'y' +]; + +/** + * @classdesc + * A Particle Emitter is a special kind of Game Object that controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles}. + * + * Particle Emitters are created via a configuration object. The properties of this object + * can be specified in a variety of formats, giving you plenty of scope over the values they + * return, leading to complex visual effects. Here are the different forms of configuration + * value you can give: + * + * ## An explicit static value: + * + * ```js + * x: 400 + * ``` + * + * The x value will always be 400 when the particle is spawned. + * + * ## A random value: + * + * ```js + * x: [ 100, 200, 300, 400 ] + * ``` + * + * The x value will be one of the 4 elements in the given array, picked at random on emission. + * + * ## A custom callback: + * + * ```js + * x: (particle, key, t, value) => { + * return value + 50; + * } + * ``` + * + * The x value is the result of calling this function. This is only used when the + * particle is emitted, so it provides its initial starting value. It is not used + * when the particle is updated (see the onUpdate callback for that) + * + * ## A start / end object: + * + * This allows you to control the change in value between the given start and + * end parameters over the course of the particles lifetime: + * + * ```js + * scale: { start: 0, end: 1 } + * ``` + * + * The particle scale will start at 0 when emitted and ease to a scale of 1 + * over the course of its lifetime. You can also specify the ease function + * used for this change (the default is Linear): + * + * ```js + * scale: { start: 0, end: 1, ease: 'bounce.out' } + * ``` + * + * ## A start / end random object: + * + * The start and end object can have an optional `random` parameter. + * This forces it to pick a random value between the two values and use + * this as the starting value, then easing to the 'end' parameter over + * its lifetime. + * + * ```js + * scale: { start: 4, end: 0.5, random: true } + * ``` + * + * The particle will start with a random scale between 0.5 and 4 and then + * scale to the end value over its lifetime. You can combine the above + * with the `ease` parameter as well to control the value easing. + * + * ## An interpolation object: + * + * You can provide an array of values which will be used for interpolation + * during the particles lifetime. You can also define the interpolation + * function to be used. There are three provided: `linear` (the default), + * `bezier` and `catmull`, or you can provide your own function. + * + * ```js + * x: { values: [ 50, 500, 200, 800 ], interpolation: 'catmull' } + * ``` + * + * The particle scale will interpolate from 50 when emitted to 800 via the other + * points over the course of its lifetime. You can also specify an ease function + * used to control the rate of change through the values (the default is Linear): + * + * ```js + * x: { values: [ 50, 500, 200, 800 ], interpolation: 'catmull', ease: 'bounce.out } + * ``` + * + * ## A stepped emitter object: + * + * The `steps` parameter allows you to control the placement of sequential + * particles across the start-end range: + * + * ```js + * x: { steps: 32, start: 0, end: 576 } + * ``` + * + * Here we have a range of 576 (start to end). This is divided into 32 steps. + * + * The first particle will emit at the x position of 0. The next will emit + * at the next 'step' along, which would be 18. The following particle will emit + * at the next step, which is 36, and so on. Because the range of 576 has been + * divided by 32, creating 18 pixels steps. When a particle reaches the 'end' + * value the next one will start from the beginning again. + * + * ## A stepped emitter object with yoyo: + * + * You can add the optional `yoyo` property to a stepped object: + * + * ```js + * x: { steps: 32, start: 0, end: 576, yoyo: true } + * ``` + * + * As with the stepped emitter, particles are emitted in sequence, from 'start' + * to 'end' in step sized jumps. Normally, when a stepped emitter reaches the + * end it snaps around to the start value again. However, if you provide the 'yoyo' + * parameter then when it reaches the end it will reverse direction and start + * emitting back down to 'start' again. Depending on the effect you require this + * can often look better. + * + * ## A min / max object: + * + * This allows you to pick a random float value between the min and max properties: + * + * ```js + * x: { min: 100, max: 700 } + * ``` + * + * The x value will be a random float between min and max. + * + * You can force it select an integer by setting the 'int' flag: + * + * ```js + * x: { min: 100, max: 700, int: true } + * ``` + * + * Or, you could use the 'random' array approach (see below) + * + * ## A random object: + * + * This allows you to pick a random integer value between the first and second array elements: + * + * ```js + * x: { random: [ 100, 700 ] } + * ``` + * + * The x value will be a random integer between 100 and 700 as it takes the first + * element in the 'random' array as the 'min' value and the 2nd element as the 'max' value. + * + * ## Custom onEmit and onUpdate callbacks: + * + * If the above won't give you the effect you're after, you can provide your own + * callbacks that will be used when the particle is both emitted and updated: + * + * ```js + * x: { + * onEmit: (particle, key, t, value) => { + * return value; + * }, + * onUpdate: (particle, key, t, value) => { + * return value; + * } + * } + * ``` + * + * You can provide either one or both functions. The `onEmit` is called at the + * start of the particles life and defines the value of the property on birth. + * + * The `onUpdate` function is called every time the Particle Emitter updates + * until the particle dies. Both must return a value. + * + * The properties are: + * + * particle - A reference to the Particle instance. + * key - The string based key of the property, i.e. 'x' or 'lifespan'. + * t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * value - The current property value. At a minimum you should return this. + * + * By using the above configuration options you have an unlimited amount of + * control over how your particles behave. + * + * ## v3.60 Differences + * + * Prior to v3.60 Phaser used a `ParticleEmitterManager`. This was removed in v3.60 + * and now calling `this.add.particles` returns a `ParticleEmitter` instance instead. + * + * In order to streamline memory and the display list we have removed the + * `ParticleEmitterManager` entirely. When you call `this.add.particles` you're now + * creating a `ParticleEmitter` instance, which is being added directly to the + * display list and can be manipulated just like any other Game Object, i.e. + * scaled, rotated, positioned, added to a Container, etc. It now extends the + * `GameObject` base class, meaning it's also an event emitter, which allowed us + * to create some handy new events for particles. + * + * So, to create an emitter, you now give it an xy coordinate, a texture and an + * emitter configuration object (you can also set this later, but most commonly + * you'd do it on creation). I.e.: + * + * ```js + * const emitter = this.add.particles(100, 300, 'flares', { + * frame: 'red', + * angle: { min: -30, max: 30 }, + * speed: 150 + * }); + * ``` + * + * This will create a 'red flare' emitter at 100 x 300. + * + * Please update your code to ensure it adheres to the new function signatures. + * + * @class ParticleEmitter + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.60.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x] - The horizontal position of this Game Object in the world. + * @param {number} [y] - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} [texture] - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} [config] - Settings for this emitter. + */ +var ParticleEmitter = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.Lighting, + Components.Mask, + Components.RenderNodes, + Components.ScrollFactor, + Components.Texture, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function ParticleEmitter (scene, x, y, texture, config) + { + GameObject.call(this, scene, 'ParticleEmitter'); + + /** + * The Particle Class which will be emitted by this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass + * @type {function} + * @default Phaser.GameObjects.Particles.Particle + * @since 3.0.0 + * @see Phaser.Types.GameObjects.Particles.ParticleClassConstructor + */ + this.particleClass = Particle; + + /** + * An internal object holding the configuration for the Emitter. + * + * These are populated as part of the Emitter configuration parsing. + * + * You typically do not access them directly, but instead use the + * `ParticleEmitter.setConfig` or `ParticleEmitter.updateConfig` methods. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#config + * @type {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} + * @since 3.85.0 + */ + this.config = null; + + /** + * An internal object holding all of the EmitterOp instances. + * + * These are populated as part of the Emitter configuration parsing. + * + * You typically do not access them directly, but instead use the + * provided getters and setters on this class, such as `ParticleEmitter.speedX` etc. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#ops + * @type {Phaser.Types.GameObjects.Particles.ParticleEmitterOps} + * @since 3.60.0 + */ + this.ops = { + accelerationX: new EmitterOp('accelerationX', 0), + accelerationY: new EmitterOp('accelerationY', 0), + alpha: new EmitterOp('alpha', 1), + angle: new EmitterOp('angle', { min: 0, max: 360 }, true), + bounce: new EmitterOp('bounce', 0), + color: new EmitterColorOp('color'), + delay: new EmitterOp('delay', 0, true), + hold: new EmitterOp('hold', 0, true), + lifespan: new EmitterOp('lifespan', 1000, true), + maxVelocityX: new EmitterOp('maxVelocityX', 10000), + maxVelocityY: new EmitterOp('maxVelocityY', 10000), + moveToX: new EmitterOp('moveToX', 0), + moveToY: new EmitterOp('moveToY', 0), + quantity: new EmitterOp('quantity', 1, true), + rotate: new EmitterOp('rotate', 0), + scaleX: new EmitterOp('scaleX', 1), + scaleY: new EmitterOp('scaleY', 1), + speedX: new EmitterOp('speedX', 0, true), + speedY: new EmitterOp('speedY', 0, true), + tint: new EmitterOp('tint', 0xffffff), + x: new EmitterOp('x', 0), + y: new EmitterOp('y', 0) + }; + + /** + * A radial emitter will emit particles in all directions between angle min and max, + * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#radial + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setRadial + */ + this.radial = true; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityX = 0; + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityY = 0; + + /** + * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.acceleration = false; + + /** + * Whether moveToX and moveToY are set. Set automatically during configuration. + * + * When true the particles move toward the moveToX and moveToY coordinates and arrive at the end of their life. + * Emitter angle, speedX, and speedY are ignored. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.moveTo = false; + + /** + * A function to call when a particle is emitted. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback + * @type {?Phaser.Types.GameObjects.Particles.ParticleEmitterCallback} + * @default null + * @since 3.0.0 + */ + this.emitCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.emitCallbackScope = null; + + /** + * A function to call when a particle dies. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback + * @type {?Phaser.Types.GameObjects.Particles.ParticleDeathCallback} + * @default null + * @since 3.0.0 + */ + this.deathCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.deathCallbackScope = null; + + /** + * Set to hard limit the amount of particle objects this emitter is allowed to create + * in total. This is the number of `Particle` instances it can create, not the number + * of 'alive' particles. + * + * 0 means unlimited. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxParticles = 0; + + /** + * The maximum number of alive and rendering particles this emitter will update. + * When this limit is reached, a particle needs to die before another can be emitted. + * + * 0 means no limits. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxAliveParticles + * @type {number} + * @default 0 + * @since 3.60.0 + */ + this.maxAliveParticles = 0; + + /** + * If set, either via the Emitter config, or by directly setting this property, + * the Particle Emitter will stop emitting particles once this total has been + * reached. It will then enter a 'stopped' state, firing the `STOP` + * event. Note that entering a stopped state doesn't mean all the particles + * have finished, just that it's not emitting any further ones. + * + * To know when the final particle expires, listen for the COMPLETE event. + * + * Use this if you wish to launch an exact number of particles and then stop + * your emitter afterwards. + * + * The counter is reset each time the `ParticleEmitter.start` method is called. + * + * 0 means the emitter will not stop based on total emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#stopAfter + * @type {number} + * @default 0 + * @since 3.60.0 + */ + this.stopAfter = 0; + + /** + * The number of milliseconds this emitter will emit particles for when in flow mode, + * before it stops emission. A value of 0 (the default) means there is no duration. + * + * When the duration expires the `STOP` event is emitted. Note that entering a + * stopped state doesn't mean all the particles have finished, just that it's + * not emitting any further ones. + * + * To know when the final particle expires, listen for the COMPLETE event. + * + * The counter is reset each time the `ParticleEmitter.start` method is called. + * + * 0 means the emitter will not stop based on duration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#duration + * @type {number} + * @default 0 + * @since 3.60.0 + */ + this.duration = 0; + + /** + * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. + * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. + * For an exploding emitter, this value will be -1. + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + */ + this.frequency = 0; + + /** + * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). + * + * Already alive particles will continue to update until they expire. + * + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitting + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.emitting = true; + + /** + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. + * + * Set to false to send them to the back. + * + * Also see the `sortOrder` property for more complex particle sorting. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.particleBringToTop = true; + + /** + * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * An array containing Particle Emission Zones. These can be either EdgeZones or RandomZones. + * + * Particles are emitted from a randomly selected zone from this array. + * + * Prior to Phaser v3.60 an Emitter could only have one single Emission Zone. + * In 3.60 they can now have an array of Emission Zones. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZones + * @type {Phaser.Types.GameObjects.Particles.EmitZoneObject[]} + * @since 3.60.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + */ + this.emitZones = []; + + /** + * An array containing Particle Death Zone objects. A particle is immediately killed as soon as its x/y coordinates + * intersect with any of the configured Death Zones. + * + * Prior to Phaser v3.60 an Emitter could only have one single Death Zone. + * In 3.60 they can now have an array of Death Zones. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZones + * @type {Phaser.GameObjects.Particles.Zones.DeathZone[]} + * @since 3.60.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + */ + this.deathZones = []; + + /** + * An optional Rectangle object that is used during rendering to cull Particles from + * display. For example, if your particles are limited to only move within a 300x300 + * sized area from their origin, then you can set this Rectangle to those dimensions. + * + * The renderer will check to see if the `viewBounds` Rectangle intersects with the + * Camera bounds during the render step and if not it will skip rendering the Emitter + * entirely. + * + * This allows you to create many emitters in a Scene without the cost of + * rendering if the contents aren't visible. + * + * Note that the Emitter will not perform any checks to see if the Particles themselves + * are outside of these bounds, or not. It will simply check the bounds against the + * camera. Use the `getBounds` method with the `advance` parameter to help define + * the location and placement of the view bounds. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#viewBounds + * @type {?Phaser.Geom.Rectangle} + * @default null + * @since 3.60.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setViewBounds + */ + this.viewBounds = null; + + /** + * A Game Object whose position is used as the particle origin. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#follow + * @type {?Phaser.Types.Math.Vector2Like} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @see Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + */ + this.follow = null; + + /** + * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.followOffset = new Vector2(); + + /** + * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track + * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.trackVisible = false; + + /** + * The texture frames assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frames = []; + + /** + * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitterFrame + */ + this.randomFrame = true; + + /** + * The number of consecutive particles that receive a single texture frame (per frame cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity + * @type {number} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitterFrame + */ + this.frameQuantity = 1; + + /** + * The animations assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#anims + * @type {string[]} + * @since 3.60.0 + */ + this.anims = []; + + /** + * Whether animations {@link Phaser.GameObjects.Particles.ParticleEmitter#anims} are selected at random. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#randomAnim + * @type {boolean} + * @default true + * @since 3.60.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAnim + */ + this.randomAnim = true; + + /** + * The number of consecutive particles that receive a single animation (per frame cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#animQuantity + * @type {number} + * @default 1 + * @since 3.60.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAnim + */ + this.animQuantity = 1; + + /** + * An array containing all currently inactive Particle instances. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#dead + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.dead = []; + + /** + * An array containing all currently live and rendering Particle instances. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alive + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.alive = []; + + /** + * Internal array that holds counter data: + * + * 0 - flowCounter - The time until next flow cycle. + * 1 - frameCounter - Counts up to {@link Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity}. + * 2 - animCounter - Counts up to animQuantity. + * 3 - elapsed - The time remaining until the `duration` limit is reached. + * 4 - stopCounter - The number of particles remaining until `stopAfter` limit is reached. + * 5 - completeFlag - Has the COMPLETE event been emitted? + * 6 - zoneIndex - The emit zone index counter. + * 7 - zoneTotal - The emit zone total counter. + * 8 - currentFrame - The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * 9 - currentAnim - The current animation, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#anims}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#counters + * @type {Float32Array} + * @private + * @since 3.60.0 + */ + this.counters = new Float32Array(10); + + /** + * An internal property used to tell when the emitter is in fast-forward mode. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#skipping + * @type {boolean} + * @default true + * @since 3.60.0 + */ + this.skipping = false; + + /** + * An internal Transform Matrix used to cache this emitters world matrix. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#worldMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.60.0 + */ + this.worldMatrix = new TransformMatrix(); + + /** + * Optionally sort the particles before they render based on this + * property. The property must exist on the `Particle` class, such + * as `y`, `lifeT`, `scaleX`, etc. + * + * When set this overrides the `particleBringToTop` setting. + * + * To reset this and disable sorting, set this property to an empty string. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#sortProperty + * @type {string} + * @since 3.60.0 + */ + this.sortProperty = ''; + + /** + * When `sortProperty` is defined this controls the sorting order, + * either ascending or descending. Toggle to control the visual effect. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#sortOrderAsc + * @type {boolean} + * @since 3.60.0 + */ + this.sortOrderAsc = true; + + /** + * The callback used to sort the particles. Only used if `sortProperty` + * has been set. Set this via the `setSortCallback` method. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#sortCallback + * @type {?Phaser.Types.GameObjects.Particles.ParticleSortCallback} + * @since 3.60.0 + */ + this.sortCallback = this.depthSortCallback; + + /** + * A list of Particle Processors being managed by this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#processors + * @type {Phaser.Structs.List.} + * @since 3.60.0 + */ + this.processors = new List(this); + + /** + * The tint mode used by the Particles in this Emitter. + * + * Available modes are: + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#tintMode + * @type {Phaser.TintModes} + * @default Phaser.TintModes.MULTIPLY + * @since 4.0.0 + */ + this.tintMode = TintModes.MULTIPLY; + + this.initRenderNodes(this._defaultRenderNodesMap); + + this.setPosition(x, y); + this.setTexture(texture); + + if (config) + { + this.setConfig(config); + } + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultParticleEmitterNodes; + } + }, + + /** + * Called when this Game Object is added to a Scene. Registers this emitter + * with the Scene's update list so it receives `preUpdate` calls each frame. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#addedToScene + * @since 3.60.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Called when this Game Object is removed from a Scene. Unregisters this + * emitter from the Scene's update list so it no longer receives `preUpdate` calls. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#removedFromScene + * @since 3.60.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * Takes an Emitter Configuration file and resets this Emitter, using any + * properties defined in the config to then set it up again. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setConfig + * @since 3.60.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} config - Settings for this emitter. + * + * @return {this} This Particle Emitter. + */ + setConfig: function (config) + { + if (!config) + { + return this; + } + + this.config = config; + + var i = 0; + var key = ''; + + var ops = this.ops; + + for (i = 0; i < configOpMap.length; i++) + { + key = configOpMap[i]; + + ops[key].loadConfig(config); + } + + for (i = 0; i < configFastMap.length; i++) + { + key = configFastMap[i]; + + // Only update properties from their current state if they exist in the given config + if (HasValue(config, key)) + { + this[key] = GetFastValue(config, key); + } + } + + this.acceleration = (this.accelerationX !== 0 || this.accelerationY !== 0); + + this.moveTo = HasAll(config, [ 'moveToX', 'moveToY' ]); + + // Special 'speed' override + + if (HasValue(config, 'speed')) + { + ops.speedX.loadConfig(config, 'speed'); + ops.speedY.active = false; + } + + // If you specify speedX, speedY or moveTo then it changes the emitter from radial to a point emitter + if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) + { + this.radial = false; + } + + // Special 'scale' override + + if (HasValue(config, 'scale')) + { + ops.scaleX.loadConfig(config, 'scale'); + ops.scaleY.active = false; + } + + if (HasValue(config, 'callbackScope')) + { + var callbackScope = GetFastValue(config, 'callbackScope', null); + + this.emitCallbackScope = callbackScope; + this.deathCallbackScope = callbackScope; + } + + if (HasValue(config, 'emitZone')) + { + this.addEmitZone(config.emitZone); + } + + if (HasValue(config, 'deathZone')) + { + this.addDeathZone(config.deathZone); + } + + if (HasValue(config, 'bounds')) + { + var bounds = this.addParticleBounds(config.bounds); + + bounds.collideLeft = GetFastValue(config, 'collideLeft', true); + bounds.collideRight = GetFastValue(config, 'collideRight', true); + bounds.collideTop = GetFastValue(config, 'collideTop', true); + bounds.collideBottom = GetFastValue(config, 'collideBottom', true); + } + + if (HasValue(config, 'followOffset')) + { + this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); + } + + if (HasValue(config, 'texture')) + { + this.setTexture(config.texture); + } + + if (HasValue(config, 'frame')) + { + this.setEmitterFrame(config.frame); + } + else if (HasValue(config, 'anim')) + { + this.setAnim(config.anim); + } + + if (HasValue(config, 'reserve')) + { + this.reserve(config.reserve); + } + + if (HasValue(config, 'advance')) + { + this.fastForward(config.advance); + } + + this.resetCounters(this.frequency, this.emitting); + + if (this.emitting) + { + this.emit(Events.START, this); + } + + return this; + }, + + /** + * Takes an existing Emitter Configuration file and updates this Emitter. + * Existing properties are overridden while new properties are added. The + * updated configuration is then passed to the `setConfig` method to reset + * the Emitter with the updated configuration. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#updateConfig + * @since 3.85.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} config - Settings for this emitter. + * + * @return {this} This Particle Emitter. + */ + updateConfig: function (config) + { + if (config) + { + if (!this.config) + { + this.setConfig(config); + } + else + { + this.setConfig(MergeRight(this.config, config)); + } + } + + return this; + }, + + /** + * Creates a description of this emitter suitable for JSON serialization. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + var output = ComponentsToJSON(this); + + var i = 0; + var key = ''; + + for (i = 0; i < configFastMap.length; i++) + { + key = configFastMap[i]; + + output[key] = this[key]; + } + + var ops = this.ops; + + for (i = 0; i < configOpMap.length; i++) + { + key = configOpMap[i]; + + if (ops[key]) + { + output[key] = ops[key].toJSON(); + } + } + + // special handlers + if (!ops.speedY.active) + { + delete output.speedX; + output.speed = ops.speedX.toJSON(); + } + + if (this.scaleX === this.scaleY) + { + delete output.scaleX; + delete output.scaleY; + output.scale = ops.scaleX.toJSON(); + } + + return output; + }, + + /** + * Resets the internal counter trackers. + * + * You shouldn't ever need to call this directly. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#resetCounters + * @since 3.60.0 + * + * @param {number} frequency - The frequency counter. + * @param {boolean} on - Set the complete flag. + */ + resetCounters: function (frequency, on) + { + var counters = this.counters; + + counters.fill(0); + + counters[0] = frequency; + + if (on) + { + counters[5] = 1; + } + }, + + /** + * Continuously moves the particle origin to follow a Game Object's position. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @since 3.0.0 + * + * @param {Phaser.Types.Math.Vector2Like} target - The Object to follow. + * @param {number} [offsetX=0] - Horizontal offset of the particle origin from the Game Object. + * @param {number} [offsetY=0] - Vertical offset of the particle origin from the Game Object. + * @param {boolean} [trackVisible=false] - Whether the emitter's visible state will track the target's visible state. + * + * @return {this} This Particle Emitter. + */ + startFollow: function (target, offsetX, offsetY, trackVisible) + { + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + if (trackVisible === undefined) { trackVisible = false; } + + this.follow = target; + this.followOffset.set(offsetX, offsetY); + this.trackVisible = trackVisible; + + return this; + }, + + /** + * Stops following a Game Object. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + * @since 3.0.0 + * + * @return {this} This Particle Emitter. + */ + stopFollow: function () + { + this.follow = null; + this.followOffset.set(0, 0); + this.trackVisible = false; + + return this; + }, + + /** + * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} The texture frame. + */ + getFrame: function () + { + var frames = this.frames; + var len = frames.length; + var current; + + if (len === 1) + { + current = frames[0]; + } + else if (this.randomFrame) + { + current = GetRandom(frames); + } + else + { + current = frames[this.currentFrame]; + + this.frameCounter++; + + if (this.frameCounter === this.frameQuantity) + { + this.frameCounter = 0; + + this.currentFrame++; + + if (this.currentFrame === len) + { + this.currentFrame = 0; + } + } + } + + return this.texture.get(current); + }, + + /** + * Sets a pattern for assigning texture frames to emitted particles. The `frames` configuration can be any of: + * + * frame: 0 + * frame: 'red' + * frame: [ 0, 1, 2, 3 ] + * frame: [ 'red', 'green', 'blue', 'pink', 'white' ] + * frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterFrame + * @since 3.0.0 + * + * @param {(array|string|number|Phaser.Types.GameObjects.Particles.ParticleEmitterFrameConfig)} frames - One or more texture frames, or a configuration object. + * @param {boolean} [pickRandom=true] - Whether frames should be assigned at random from `frames`. + * @param {number} [quantity=1] - The number of consecutive particles that will receive each frame. + * + * @return {this} This Particle Emitter. + */ + setEmitterFrame: function (frames, pickRandom, quantity) + { + if (pickRandom === undefined) { pickRandom = true; } + if (quantity === undefined) { quantity = 1; } + + this.randomFrame = pickRandom; + this.frameQuantity = quantity; + + this.currentFrame = 0; + + var t = typeof (frames); + + this.frames.length = 0; + + if (Array.isArray(frames)) + { + this.frames = this.frames.concat(frames); + } + else if (t === 'string' || t === 'number') + { + this.frames.push(frames); + } + else if (t === 'object') + { + var frameConfig = frames; + + frames = GetFastValue(frameConfig, 'frames', null); + + if (frames) + { + this.frames = this.frames.concat(frames); + } + + var isCycle = GetFastValue(frameConfig, 'cycle', false); + + this.randomFrame = (isCycle) ? false : true; + + this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); + } + + if (this.frames.length === 1) + { + this.frameQuantity = 1; + this.randomFrame = false; + } + + return this; + }, + + /** + * Chooses an animation from {@link Phaser.GameObjects.Particles.ParticleEmitter#anims}, if populated. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getAnim + * @since 3.60.0 + * + * @return {string} The animation to play, or `null` if there aren't any. + */ + getAnim: function () + { + var anims = this.anims; + var len = anims.length; + + if (len === 0) + { + return null; + } + else if (len === 1) + { + return anims[0]; + } + else if (this.randomAnim) + { + return GetRandom(anims); + } + else + { + var anim = anims[this.currentAnim]; + + this.animCounter++; + + if (this.animCounter >= this.animQuantity) + { + this.animCounter = 0; + this.currentAnim = Wrap(this.currentAnim + 1, 0, len); + } + + return anim; + } + }, + + /** + * Sets a pattern for assigning animations to emitted particles. The `anims` configuration can be any of: + * + * anim: 'red' + * anim: [ 'red', 'green', 'blue', 'pink', 'white' ] + * anim: { anims: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + * + * Call this method at least once before any particles are created, or set `anim` in the Particle Emitter's configuration when creating the Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAnim + * @since 3.60.0 + * + * @param {(string|string[]|Phaser.Types.GameObjects.Particles.ParticleEmitterAnimConfig)} anims - One or more animations, or a configuration object. + * @param {boolean} [pickRandom=true] - Whether animations should be assigned at random from `anims`. If a config object is given, this parameter is ignored. + * @param {number} [quantity=1] - The number of consecutive particles that will receive each animation. If a config object is given, this parameter is ignored. + * + * @return {this} This Particle Emitter. + */ + setAnim: function (anims, pickRandom, quantity) + { + if (pickRandom === undefined) { pickRandom = true; } + if (quantity === undefined) { quantity = 1; } + + this.randomAnim = pickRandom; + this.animQuantity = quantity; + + this.currentAnim = 0; + + var t = typeof (anims); + + this.anims.length = 0; + + if (Array.isArray(anims)) + { + this.anims = this.anims.concat(anims); + } + else if (t === 'string') + { + this.anims.push(anims); + } + else if (t === 'object') + { + var animConfig = anims; + + anims = GetFastValue(animConfig, 'anims', null); + + if (anims) + { + this.anims = this.anims.concat(anims); + } + + var isCycle = GetFastValue(animConfig, 'cycle', false); + + this.randomAnim = (isCycle) ? false : true; + + this.animQuantity = GetFastValue(animConfig, 'quantity', quantity); + } + + if (this.anims.length === 1) + { + this.animQuantity = 1; + this.randomAnim = false; + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial + * @since 3.0.0 + * + * @param {boolean} [value=true] - Radial mode (true) or point mode (false). + * + * @return {this} This Particle Emitter. + */ + setRadial: function (value) + { + if (value === undefined) { value = true; } + + this.radial = value; + + return this; + }, + + /** + * Creates a Particle Bounds processor and adds it to this Emitter. + * + * This processor will check to see if any of the active Particles hit + * the defined boundary, as specified by a Rectangle shape in world-space. + * + * If so, they are 'rebounded' back again by having their velocity adjusted. + * + * The strength of the rebound is controlled by the `Particle.bounce` + * property. + * + * You should be careful to ensure that you emit particles within a bounds, + * if set, otherwise it will lead to unpredictable visual results as the + * particles are hastily repositioned. + * + * The Particle Bounds processor is returned from this method. If you wish + * to modify the area you can directly change its `bounds` property, along + * with the `collideLeft` etc values. + * + * To disable the bounds you can either set its `active` property to `false`, + * or if you no longer require it, call `ParticleEmitter.removeParticleProcessor`. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#addParticleBounds + * @since 3.60.0 + * + * @param {(number|Phaser.Types.GameObjects.Particles.ParticleEmitterBounds|Phaser.Types.GameObjects.Particles.ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. + * @param {number} [y] - The y-coordinate of the top edge of the boundary. + * @param {number} [width] - The width of the boundary. + * @param {number} [height] - The height of the boundary. + * @param {boolean} [collideLeft=true] - Whether particles interact with the left edge of the bounds. + * @param {boolean} [collideRight=true] - Whether particles interact with the right edge of the bounds. + * @param {boolean} [collideTop=true] - Whether particles interact with the top edge of the bounds. + * @param {boolean} [collideBottom=true] - Whether particles interact with the bottom edge of the bounds. + * + * @return {Phaser.GameObjects.Particles.ParticleBounds} The Particle Bounds processor. + */ + addParticleBounds: function (x, y, width, height, collideLeft, collideRight, collideTop, collideBottom) + { + if (typeof x === 'object') + { + var obj = x; + + x = obj.x; + y = obj.y; + width = (HasValue(obj, 'w')) ? obj.w : obj.width; + height = (HasValue(obj, 'h')) ? obj.h : obj.height; + } + + return this.addParticleProcessor(new ParticleBounds(x, y, width, height, collideLeft, collideRight, collideTop, collideBottom)); + }, + + /** + * Sets the initial radial speed of emitted particles. + * + * Changes the emitter to radial mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setParticleSpeed + * @since 3.60.0 + * + * @param {number} x - The horizontal speed of the emitted Particles. + * @param {number} [y=x] - The vertical speed of emitted Particles. If not set it will use the `x` value. + * + * @return {this} This Particle Emitter. + */ + setParticleSpeed: function (x, y) + { + if (y === undefined) { y = x; } + + this.ops.speedX.onChange(x); + + if (x === y) + { + this.ops.speedY.active = false; + } + else + { + this.ops.speedY.onChange(y); + } + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = true; + + return this; + }, + + /** + * Sets the vertical and horizontal scale of the emitted particles. + * + * You can also set the scale of the entire emitter via `setScale`. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setParticleScale + * @since 3.60.0 + * + * @param {number} [x=1] - The horizontal scale of the emitted Particles. + * @param {number} [y=x] - The vertical scale of emitted Particles. If not set it will use the `x` value. + * + * @return {this} This Particle Emitter. + */ + setParticleScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.ops.scaleX.onChange(x); + this.ops.scaleY.onChange(y); + + return this; + }, + + /** + * Sets the gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setParticleGravity + * @since 3.60.0 + * + * @param {number} x - Horizontal acceleration due to gravity, in pixels per second squared. Set to zero for no gravity. + * @param {number} y - Vertical acceleration due to gravity, in pixels per second squared. Set to zero for no gravity. + * + * @return {this} This Particle Emitter. + */ + setParticleGravity: function (x, y) + { + this.gravityX = x; + this.gravityY = y; + + return this; + }, + + /** + * Sets the opacity (alpha) of emitted particles. + * + * You can also set the alpha of the entire emitter via `setAlpha`. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setParticleAlpha + * @since 3.60.0 + * + * @param {(Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType)} value - A value between 0 (transparent) and 1 (opaque). + * + * @return {this} This Particle Emitter. + */ + setParticleAlpha: function (value) + { + this.ops.alpha.onChange(value); + + return this; + }, + + /** + * Sets the color tint of emitted particles. + * + * This is a WebGL only feature. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setParticleTint + * @since 3.60.0 + * @webglOnly + * + * @param {(Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType)} value - A value between 0 and 0xffffff. + * + * @return {this} This Particle Emitter. + */ + setParticleTint: function (value) + { + this.ops.tint.onChange(value); + + return this; + }, + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * + * The value is given in degrees using Phaser's right-handed coordinate system. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} value - The angle of the initial velocity of emitted particles, in degrees. + * + * @return {this} This Particle Emitter. + */ + setEmitterAngle: function (value) + { + this.ops.angle.onChange(value); + + return this; + }, + + /** + * Sets the lifespan of newly emitted particles in milliseconds. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setParticleLifespan + * @since 3.60.0 + * + * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} value - The lifespan of a particle, in ms. + * + * @return {this} This Particle Emitter. + */ + setParticleLifespan: function (value) + { + this.ops.lifespan.onChange(value); + + return this; + }, + + /** + * Sets the number of particles released at each flow cycle or explosion. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} quantity - The number of particles to release at each flow cycle or explosion. + * + * @return {this} This Particle Emitter. + */ + setQuantity: function (quantity) + { + this.quantity = quantity; + + return this; + }, + + /** + * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} [quantity] - The number of particles to release at each flow cycle or explosion. + * + * @return {this} This Particle Emitter. + */ + setFrequency: function (frequency, quantity) + { + this.frequency = frequency; + + this.flowCounter = (frequency > 0) ? frequency : 0; + + if (quantity) + { + this.quantity = quantity; + } + + return this; + }, + + /** + * Adds a new Particle Death Zone to this Emitter. + * + * A particle is immediately killed as soon as its x/y coordinates intersect + * with any of the configured Death Zones. + * + * The `source` can be a Geometry Shape, such as a Circle, Rectangle or Triangle. + * Any valid object from the `Phaser.Geometry` namespace is allowed, as long as + * it supports a `contains` function. You can set the `type` to be either `onEnter` + * or `onLeave`. + * + * A single Death Zone instance can only exist once within this Emitter, but can belong + * to multiple Emitters. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#addDeathZone + * @since 3.60.0 + * + * @param {Phaser.Types.GameObjects.Particles.DeathZoneObject|Phaser.Types.GameObjects.Particles.DeathZoneObject[]} config - A Death Zone configuration object, a Death Zone instance, a valid Geometry object or an array of them. + * + * @return {Phaser.GameObjects.Particles.Zones.DeathZone[]} An array of the Death Zones that were added to this Emitter. + */ + addDeathZone: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var zone; + var output = []; + + for (var i = 0; i < config.length; i++) + { + zone = config[i]; + + if (zone instanceof DeathZone) + { + output.push(zone); + } + else if (typeof zone.contains === 'function') + { + zone = new DeathZone(zone, true); + + output.push(zone); + } + else + { + var type = GetFastValue(zone, 'type', 'onEnter'); + var source = GetFastValue(zone, 'source', null); + + if (source && typeof source.contains === 'function') + { + var killOnEnter = (type === 'onEnter') ? true : false; + + zone = new DeathZone(source, killOnEnter); + + output.push(zone); + } + } + } + + this.deathZones = this.deathZones.concat(output); + + return output; + }, + + /** + * Removes the given Particle Death Zone from this Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#removeDeathZone + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Zones.DeathZone} zone - The Death Zone that should be removed from this Emitter. + * + * @return {this} This Particle Emitter. + */ + removeDeathZone: function (zone) + { + Remove(this.deathZones, zone); + + return this; + }, + + /** + * Clear all Death Zones from this Particle Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#clearDeathZones + * @since 3.70.0 + * + * @return {this} This Particle Emitter. + */ + clearDeathZones: function () + { + this.deathZones.length = 0; + + return this; + }, + + /** + * Adds a new Particle Emission Zone to this Emitter. + * + * An {@link Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. + * Its {@link Phaser.Types.GameObjects.Particles.EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; + * or any object with a suitable {@link Phaser.Types.GameObjects.Particles.EdgeZoneSourceCallback getPoints} method. + * + * A {@link Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig RandomZone} places the particles randomly within its interior. + * Its {@link Phaser.GameObjects.Particles.Zones.RandomZone#source source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method. + * + * An Emission Zone can only exist once within this Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#addEmitZone + * @since 3.60.0 + * + * @param {Phaser.Types.GameObjects.Particles.EmitZoneData|Phaser.Types.GameObjects.Particles.EmitZoneData[]} zone - An Emission Zone configuration object, a RandomZone or EdgeZone instance, or an array of them. + * + * @return {Phaser.Types.GameObjects.Particles.EmitZoneObject[]} An array of the Emission Zones that were added to this Emitter. + */ + addEmitZone: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var zone; + var output = []; + + for (var i = 0; i < config.length; i++) + { + zone = config[i]; + + if (zone instanceof RandomZone || zone instanceof EdgeZone) + { + output.push(zone); + } + else + { + // Where source = Geom like Circle, or a Path or Curve + // emitZone: { type: 'random', source: X } + // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true], [total=1] } + + var source = GetFastValue(zone, 'source', null); + + if (source) + { + var type = GetFastValue(zone, 'type', 'random'); + + if (type === 'random' && typeof source.getRandomPoint === 'function') + { + zone = new RandomZone(source); + + output.push(zone); + } + else if (type === 'edge' && typeof source.getPoints === 'function') + { + var quantity = GetFastValue(zone, 'quantity', 1); + var stepRate = GetFastValue(zone, 'stepRate', 0); + var yoyo = GetFastValue(zone, 'yoyo', false); + var seamless = GetFastValue(zone, 'seamless', true); + var total = GetFastValue(zone, 'total', -1); + + zone = new EdgeZone(source, quantity, stepRate, yoyo, seamless, total); + + output.push(zone); + } + } + } + } + + this.emitZones = this.emitZones.concat(output); + + return output; + }, + + /** + * Removes the given Particle Emission Zone from this Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#removeEmitZone + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone} zone - The Emission Zone that should be removed from this Emitter. + * + * @return {this} This Particle Emitter. + */ + removeEmitZone: function (zone) + { + Remove(this.emitZones, zone); + + this.zoneIndex = 0; + + return this; + }, + + /** + * Clear all Emission Zones from this Particle Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#clearEmitZones + * @since 3.70.0 + * + * @return {this} This Particle Emitter. + */ + clearEmitZones: function () + { + this.emitZones.length = 0; + + this.zoneIndex = 0; + + return this; + }, + + /** + * Takes the given particle and sets its x/y coordinates to match the next available + * emission zone, if any have been configured. This method is called automatically + * as part of the `Particle.fire` process. + * + * The Emit Zones are iterated in sequence. Once a zone has had a particle emitted + * from it, then the next zone is used and so on, in a loop. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getEmitZone + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle to set the emission zone for. + */ + getEmitZone: function (particle) + { + var zones = this.emitZones; + var len = zones.length; + + if (len === 0) + { + return; + } + else + { + var zone = zones[this.zoneIndex]; + + zone.getPoint(particle); + + if (zone.total > -1) + { + this.zoneTotal++; + + if (this.zoneTotal === zone.total) + { + this.zoneTotal = 0; + + this.zoneIndex++; + + if (this.zoneIndex === len) + { + this.zoneIndex = 0; + } + } + } + } + }, + + /** + * Takes the given particle and checks to see if any of the configured Death Zones + * will kill it and returns the result. This method is called automatically as part + * of the `Particle.update` process. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeathZone + * @fires Phaser.GameObjects.Particles.Events#DEATH_ZONE + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle to test against the Death Zones. + * + * @return {boolean} `true` if the particle should be killed, otherwise `false`. + */ + getDeathZone: function (particle) + { + var zones = this.deathZones; + + for (var i = 0; i < zones.length; i++) + { + var zone = zones[i]; + + if (zone.willKill(particle)) + { + this.emit(Events.DEATH_ZONE, this, particle, zone); + + return true; + } + } + + return false; + }, + + /** + * Changes the currently active Emission Zone. The zones should have already + * been added to this Emitter either via the emitter config, or the + * `addEmitZone` method. + * + * Call this method by passing either a numeric zone index value, or + * the zone instance itself. + * + * Prior to v3.60 an Emitter could only have a single Emit Zone and this + * method was how you set it. From 3.60 and up it now performs a different + * function and swaps between all available active zones. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + * @since 3.0.0 + * + * @param {number|Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone} zone - The Emit Zone to set as the active zone. + * + * @return {this} This Particle Emitter. + */ + setEmitZone: function (zone) + { + var index; + + if (isFinite(zone)) + { + index = zone; + } + else + { + index = this.emitZones.indexOf(zone); + } + + if (index >= 0) + { + this.zoneIndex = index; + } + + return this; + }, + + /** + * Adds a Particle Processor, such as a Gravity Well, to this Emitter. + * + * It will start processing particles from the next update as long as its `active` + * property is set. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#addParticleProcessor + * @since 3.60.0 + * + * @generic {Phaser.GameObjects.Particles.ParticleProcessor} T + * @param {T} processor - The Particle Processor to add to this Emitter Manager. + * + * @return {T} The Particle Processor that was added to this Emitter Manager. + */ + addParticleProcessor: function (processor) + { + if (!this.processors.exists(processor)) + { + if (processor.emitter) + { + processor.emitter.removeParticleProcessor(processor); + } + + this.processors.add(processor); + + processor.emitter = this; + } + + return processor; + }, + + /** + * Removes a Particle Processor from this Emitter. + * + * The Processor must belong to this Emitter to be removed. + * + * It is not destroyed when removed, allowing you to move it to another Emitter Manager, + * so if you no longer require it you should call its `destroy` method directly. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#removeParticleProcessor + * @since 3.60.0 + * + * @generic {Phaser.GameObjects.Particles.ParticleProcessor} T + * @param {T} processor - The Particle Processor to remove from this Emitter Manager. + * + * @return {?T} The Particle Processor that was removed, or null if it could not be found. + */ + removeParticleProcessor: function (processor) + { + if (this.processors.exists(processor)) + { + this.processors.remove(processor, true); + + processor.emitter = null; + } + + return processor; + }, + + /** + * Gets all active Particle Processors. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getProcessors + * @since 3.60.0 + * + * @return {Phaser.GameObjects.Particles.ParticleProcessor[]} - An array of active Particle Processors. + */ + getProcessors: function () + { + return this.processors.getAll('active', true); + }, + + /** + * Creates a new Gravity Well, adds it to this Emitter and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#createGravityWell + * @since 3.60.0 + * + * @param {Phaser.Types.GameObjects.Particles.GravityWellConfig} config - Configuration settings for the Gravity Well to create. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. + */ + createGravityWell: function (config) + { + return this.addParticleProcessor(new GravityWell(config)); + }, + + /** + * Creates inactive particles and adds them to this emitter's pool. + * + * If `ParticleEmitter.maxParticles` is set it will limit the + * value passed to this method to make sure it's not exceeded. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve + * @since 3.0.0 + * + * @param {number} count - The number of particles to create. + * + * @return {this} This Particle Emitter. + */ + reserve: function (count) + { + var dead = this.dead; + + if (this.maxParticles > 0) + { + var total = this.getParticleCount(); + + if (total + count > this.maxParticles) + { + count = this.maxParticles - (total + count); + } + } + + for (var i = 0; i < count; i++) + { + dead.push(new this.particleClass(this)); + } + + return this; + }, + + /** + * Gets the number of active (in-use) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount + * @since 3.0.0 + * + * @return {number} The number of particles with `active=true`. + */ + getAliveParticleCount: function () + { + return this.alive.length; + }, + + /** + * Gets the number of inactive (available) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount + * @since 3.0.0 + * + * @return {number} The number of particles with `active=false`. + */ + getDeadParticleCount: function () + { + return this.dead.length; + }, + + /** + * Gets the total number of particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount + * @since 3.0.0 + * + * @return {number} The number of particles, including both alive and dead. + */ + getParticleCount: function () + { + return this.getAliveParticleCount() + this.getDeadParticleCount(); + }, + + /** + * Whether this emitter is at either its hard-cap limit (maxParticles), if set, or + * the max allowed number of 'alive' particles (maxAliveParticles). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. + */ + atLimit: function () + { + if (this.maxParticles > 0 && this.getParticleCount() >= this.maxParticles) + { + return true; + } + + return (this.maxAliveParticles > 0 && this.getAliveParticleCount() >= this.maxAliveParticles); + }, + + /** + * Sets a function to call for each newly emitted particle. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterCallback} callback - The function. + * @param {*} [context] - The calling context. + * + * @return {this} This Particle Emitter. + */ + onParticleEmit: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.emitCallback = null; + this.emitCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.emitCallback = callback; + + if (context) + { + this.emitCallbackScope = context; + } + } + + return this; + }, + + /** + * Sets a function to call for each particle death. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleDeathCallback} callback - The function. + * @param {*} [context] - The function's calling context. + * + * @return {this} This Particle Emitter. + */ + onParticleDeath: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.deathCallback = null; + this.deathCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.deathCallback = callback; + + if (context) + { + this.deathCallbackScope = context; + } + } + + return this; + }, + + /** + * Deactivates every particle in this emitter immediately. + * + * These particles are killed but do not emit an event or callback. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll + * @since 3.0.0 + * + * @return {this} This Particle Emitter. + */ + killAll: function () + { + var dead = this.dead; + var alive = this.alive; + + while (alive.length > 0) + { + dead.push(alive.pop()); + } + + return this; + }, + + /** + * Calls a function for each active particle in this emitter. The function is + * sent two parameters: a reference to the Particle instance and to this Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {this} This Particle Emitter. + */ + forEachAlive: function (callback, context) + { + var alive = this.alive; + var length = alive.length; + + for (var i = 0; i < length; i++) + { + // Sends the Particle and the Emitter + callback.call(context, alive[i], this); + } + + return this; + }, + + /** + * Calls a function for each inactive particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {this} This Particle Emitter. + */ + forEachDead: function (callback, context) + { + var dead = this.dead; + var length = dead.length; + + for (var i = 0; i < length; i++) + { + callback.call(context, dead[i], this); + } + + return this; + }, + + /** + * Enables emitting, sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitting} to `true`, and resets the flow counter. + * + * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). + * + * If this emitter is in explode mode (frequency = -1), nothing will happen. + * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. + * + * Calling this method will emit the `START` event. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#start + * @fires Phaser.GameObjects.Particles.Events#START + * @since 3.0.0 + * + * @param {number} [advance=0] - Advance this number of ms in time through the emitter. + * @param {number} [duration=0] - Limit this emitter to only emit particles for the given number of ms. Setting this parameter will override any duration already set in the Emitter configuration object. + * + * @return {this} This Particle Emitter. + */ + start: function (advance, duration) + { + if (advance === undefined) { advance = 0; } + + if (!this.emitting) + { + if (advance > 0) + { + this.fastForward(advance); + } + + this.emitting = true; + + this.resetCounters(this.frequency, true); + + if (duration !== undefined) + { + this.duration = Math.abs(duration); + } + + this.emit(Events.START, this); + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#emitting off} the emitter and + * stops it from emitting further particles. Currently alive particles will remain + * active until they naturally expire unless you set the `kill` parameter to `true`. + * + * Calling this method will emit the `STOP` event. When the final particle has + * expired the `COMPLETE` event will be emitted. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stop + * @fires Phaser.GameObjects.Particles.Events#STOP + * @since 3.11.0 + * + * @param {boolean} [kill=false] - Kill all particles immediately (true), or leave them to die after their lifespan expires? (false, the default) + * + * @return {this} This Particle Emitter. + */ + stop: function (kill) + { + if (kill === undefined) { kill = false; } + + if (this.emitting) + { + this.emitting = false; + + if (kill) + { + this.killAll(); + } + + this.emit(Events.STOP, this); + } + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#pause + * @since 3.0.0 + * + * @return {this} This Particle Emitter. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#resume + * @since 3.0.0 + * + * @return {this} This Particle Emitter. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * Set the property by which active particles are sorted prior to be rendered. + * + * It allows you to control the rendering order of the particles. + * + * This can be any valid property of the `Particle` class, such as `y`, `alpha` + * or `lifeT`. + * + * The 'alive' particles array is sorted in place each game frame. Setting a + * sort property will override the `particleBringToTop` setting. + * + * If you wish to use your own sorting function, see `setSortCallback` instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSortProperty + * @since 3.60.0 + * + * @param {string} [property] - The property on the `Particle` class to sort by. + * @param {boolean} [ascending=true] - Should the particles be sorted in ascending or descending order? + * + * @return {this} This Particle Emitter. + */ + setSortProperty: function (property, ascending) + { + if (property === undefined) { property = ''; } + if (ascending === undefined) { ascending = this.true; } + + this.sortProperty = property; + this.sortOrderAsc = ascending; + this.sortCallback = this.depthSortCallback; + + return this; + }, + + /** + * Sets a callback to be used to sort the particles before rendering each frame. + * + * This allows you to define your own logic and behavior in the callback. + * + * The callback will be sent two parameters: the two Particles being compared, + * and must adhere to the criteria of the `compareFn` in `Array.sort`: + * + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description + * + * Call this method with no parameters to reset the sort callback. + * + * Setting your own callback will override both the `particleBringToTop` and + * `sortProperty` settings of this Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSortCallback + * @since 3.60.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleSortCallback} [callback] - The callback to invoke when the particles are sorted. Leave undefined to reset to the default. + * + * @return {this} This Particle Emitter. + */ + setSortCallback: function (callback) + { + if (this.sortProperty !== '') + { + callback = this.depthSortCallback; + } + else + { + callback = null; + } + + this.sortCallback = callback; + + return this; + }, + + /** + * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort + * @since 3.0.0 + * + * @return {this} This Particle Emitter. + */ + depthSort: function () + { + StableSort(this.alive, this.sortCallback.bind(this)); + + return this; + }, + + /** + * Calculates the difference of two particles, for sorting them by depth. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback + * @since 3.0.0 + * + * @param {object} a - The first particle. + * @param {object} b - The second particle. + * + * @return {number} The difference of a and b's y coordinates. + */ + depthSortCallback: function (a, b) + { + var key = this.sortProperty; + + if (this.sortOrderAsc) + { + return a[key] - b[key]; + } + else + { + return b[key] - a[key]; + } + }, + + /** + * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. + * + * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#flow + * @fires Phaser.GameObjects.Particles.Events#START + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms. + * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} [count=1] - The number of particles to emit at each flow cycle. + * @param {number} [stopAfter] - Stop this emitter from firing any more particles once this value is reached. Set to zero for unlimited. Setting this parameter will override any `stopAfter` value already set in the Emitter configuration object. + * + * @return {this} This Particle Emitter. + */ + flow: function (frequency, count, stopAfter) + { + if (count === undefined) { count = 1; } + + this.emitting = false; + + this.frequency = frequency; + this.quantity = count; + + if (stopAfter !== undefined) + { + this.stopAfter = stopAfter; + } + + return this.start(); + }, + + /** + * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#explode + * @fires Phaser.GameObjects.Particles.Events#EXPLODE + * @since 3.0.0 + * + * @param {number} [count=this.quantity] - The number of Particles to emit. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.y] - The y coordinate to emit the Particles from. + * + * @return {(Phaser.GameObjects.Particles.Particle|undefined)} The most recently emitted Particle, or `undefined` if the emitter is at its limit. + */ + explode: function (count, x, y) + { + this.frequency = -1; + + this.resetCounters(-1, true); + + var particle = this.emitParticle(count, x, y); + + this.emit(Events.EXPLODE, this, particle); + + return particle; + }, + + /** + * Emits particles at the given position. If no position is given, it will + * emit from this Emitters current location. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt + * @since 3.0.0 + * + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.y] - The y coordinate to emit the Particles from. + * @param {number} [count=this.quantity] - The number of Particles to emit. + * + * @return {(Phaser.GameObjects.Particles.Particle|undefined)} The most recently emitted Particle, or `undefined` if the emitter is at its limit. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Emits particles at a given position (or the emitters current position). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle + * @since 3.0.0 + * + * @param {number} [count=this.quantity] - The number of Particles to emit. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.y] - The y coordinate to emit the Particles from. + * + * @return {(Phaser.GameObjects.Particles.Particle|undefined)} The most recently emitted Particle, or `undefined` if the emitter is at its limit. + * + * @see Phaser.GameObjects.Particles.Particle#fire + */ + emitParticle: function (count, x, y) + { + if (this.atLimit()) + { + return; + } + + if (count === undefined) + { + count = this.ops.quantity.onEmit(); + } + + var dead = this.dead; + var stopAfter = this.stopAfter; + + var followX = (this.follow) ? this.follow.x + this.followOffset.x : x; + var followY = (this.follow) ? this.follow.y + this.followOffset.y : y; + + for (var i = 0; i < count; i++) + { + var particle = dead.pop(); + + if (!particle) + { + particle = new this.particleClass(this); + } + + if (particle.fire(followX, followY)) + { + if (this.particleBringToTop) + { + this.alive.push(particle); + } + else + { + this.alive.unshift(particle); + } + + if (this.emitCallback) + { + this.emitCallback.call(this.emitCallbackScope, particle, this); + } + } + else + { + this.dead.push(particle); + } + + if (stopAfter > 0) + { + this.stopCounter++; + + if (this.stopCounter >= stopAfter) + { + break; + } + } + + if (this.atLimit()) + { + break; + } + } + + return particle; + }, + + /** + * Fast forwards this Particle Emitter and all of its particles. + * + * Works by running the Emitter `preUpdate` handler in a loop until the `time` + * has been reached at `delta` steps per loop. + * + * All callbacks and emitter related events that would normally be fired + * will still be invoked. + * + * You can make an emitter 'fast forward' via the emitter config using the + * `advance` property. Set this value to the number of ms you wish the + * emitter to be fast-forwarded by. Or, call this method post-creation. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#fastForward + * @since 3.60.0 + * + * @param {number} time - The number of ms to advance the Particle Emitter by. + * @param {number} [delta] - The amount of delta to use for each step. Defaults to 1000 / 60. + * + * @return {this} This Particle Emitter. + */ + fastForward: function (time, delta) + { + if (delta === undefined) { delta = 1000 / 60; } + + var total = 0; + + this.skipping = true; + + while (total < Math.abs(time)) + { + this.preUpdate(0, delta); + + total += delta; + } + + this.skipping = false; + + return this; + }, + + /** + * Updates this emitter and its particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate + * @fires Phaser.GameObjects.Particles.Events#COMPLETE + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var step = (delta / 1000); + + if (this.trackVisible) + { + this.visible = this.follow.visible; + } + + this.getWorldTransformMatrix(this.worldMatrix); + + // Any particle processors? + var processors = this.getProcessors(); + + var particles = this.alive; + var dead = this.dead; + + var i = 0; + var rip = []; + var length = particles.length; + + for (i = 0; i < length; i++) + { + var particle = particles[i]; + + // update returns `true` if the particle is now dead (lifeCurrent <= 0) + if (particle.update(delta, step, processors)) + { + rip.push({ index: i, particle: particle }); + } + } + + // Move dead particles to the dead array + length = rip.length; + + if (length > 0) + { + var deathCallback = this.deathCallback; + var deathCallbackScope = this.deathCallbackScope; + + for (i = length - 1; i >= 0; i--) + { + var entry = rip[i]; + + // Remove from particles array + particles.splice(entry.index, 1); + + // Add to dead array + dead.push(entry.particle); + + // Callback + if (deathCallback) + { + deathCallback.call(deathCallbackScope, entry.particle); + } + + entry.particle.setPosition(); + } + } + + if (!this.emitting && !this.skipping) + { + if (this.completeFlag === 1 && particles.length === 0) + { + this.completeFlag = 0; + + this.emit(Events.COMPLETE, this); + } + + return; + } + + if (this.frequency === 0) + { + this.emitParticle(); + } + else if (this.frequency > 0) + { + this.flowCounter -= delta; + + while (this.flowCounter <= 0) + { + // Emits the 'quantity' number of particles + this.emitParticle(); + + // counter = frequency - remainder from previous delta + this.flowCounter += this.frequency; + } + } + + // Duration or stopAfter set? + if (!this.skipping) + { + if (this.duration > 0) + { + // elapsed + this.elapsed += delta; + + if (this.elapsed >= this.duration) + { + this.stop(); + } + } + + if (this.stopAfter > 0 && this.stopCounter >= this.stopAfter) + { + this.stop(); + } + } + }, + + /** + * Takes either a Rectangle Geometry object or an Arcade Physics Body and tests + * to see if it intersects with any currently alive Particle in this Emitter. + * + * Overlapping particles are returned in an array, where you can perform further + * processing on them. If nothing overlaps then the array will be empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#overlap + * @since 3.60.0 + * + * @param {(Phaser.Geom.Rectangle|Phaser.Physics.Arcade.Body)} target - A Rectangle or Arcade Physics Body to check for intersection against all alive particles. + * + * @return {Phaser.GameObjects.Particles.Particle[]} An array of Particles that overlap with the given target. + */ + overlap: function (target) + { + var matrix = this.getWorldTransformMatrix(); + + var alive = this.alive; + var length = alive.length; + + var output = []; + + for (var i = 0; i < length; i++) + { + var particle = alive[i]; + + if (RectangleToRectangle(target, particle.getBounds(matrix))) + { + output.push(particle); + } + } + + return output; + }, + + /** + * Returns a bounds Rectangle calculated from the bounds of all currently + * _active_ Particles in this Emitter. If this Emitter has only just been + * created and not yet rendered, then calling this method will return a Rectangle + * with a max safe integer for dimensions. Use the `advance` parameter to + * avoid this. + * + * Typically it takes a few seconds for a flow Emitter to 'warm up'. You can + * use the `advance` and `delta` parameters to force the Emitter to + * 'fast forward' in time to try and allow the bounds to be more accurate, + * as it will calculate the bounds based on the particle bounds across all + * timesteps, giving a better result. + * + * You can also use the `padding` parameter to increase the size of the + * bounds. Emitters with a lot of randomness in terms of direction or lifespan + * can often return a bounds smaller than their possible maximum. By using + * the `padding` (and `advance` if needed) you can help limit this. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getBounds + * @since 3.60.0 + * + * @param {number} [padding] - The amount of padding, in pixels, to add to the bounds Rectangle. + * @param {number} [advance] - The number of ms to advance the Particle Emitter by. Defaults to 0, i.e. not used. + * @param {number} [delta] - The amount of delta to use for each step. Defaults to 1000 / 60. + * @param {Phaser.Geom.Rectangle} [output] - The Rectangle to store the results in. If not given a new one will be created. + * + * @return {Phaser.Geom.Rectangle} A Rectangle containing the calculated bounds of this Emitter. + */ + getBounds: function (padding, advance, delta, output) + { + if (padding === undefined) { padding = 0; } + if (advance === undefined) { advance = 0; } + if (delta === undefined) { delta = 1000 / 60; } + if (output === undefined) { output = new Rectangle(); } + + var matrix = this.getWorldTransformMatrix(); + + var i; + var bounds; + var alive = this.alive; + var setFirst = false; + + output.setTo(0, 0, 0, 0); + + if (advance > 0) + { + var total = 0; + + this.skipping = true; + + while (total < Math.abs(advance)) + { + this.preUpdate(0, delta); + + for (i = 0; i < alive.length; i++) + { + bounds = alive[i].getBounds(matrix); + + if (!setFirst) + { + setFirst = true; + + CopyFrom(bounds, output); + } + else + { + MergeRect(output, bounds); + } + } + + total += delta; + } + + this.skipping = false; + } + else + { + for (i = 0; i < alive.length; i++) + { + bounds = alive[i].getBounds(matrix); + + if (!setFirst) + { + setFirst = true; + + CopyFrom(bounds, output); + } + else + { + MergeRect(output, bounds); + } + } + } + + if (padding > 0) + { + Inflate(output, padding, padding); + } + + return output; + }, + + /** + * Prints a warning to the console if you mistakenly call this function + * thinking it works the same way as Phaser v3.55. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#createEmitter + * @since 3.60.0 + */ + createEmitter: function () + { + throw new Error('createEmitter removed. See ParticleEmitter docs for info'); + }, + + /** + * The x coordinate the particles are emitted from. + * + * This is relative to the Emitters x coordinate and that of any parent. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleX + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} + * @since 3.60.0 + */ + particleX: { + + get: function () + { + return this.ops.x.current; + }, + + set: function (value) + { + this.ops.x.onChange(value); + } + + }, + + /** + * The y coordinate the particles are emitted from. + * + * This is relative to the Emitters y coordinate and that of any parent. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleY + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} + * @since 3.60.0 + */ + particleY: { + + get: function () + { + return this.ops.y.current; + }, + + set: function (value) + { + this.ops.y.onChange(value); + } + + }, + + /** + * The horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + accelerationX: { + + get: function () + { + return this.ops.accelerationX.current; + }, + + set: function (value) + { + this.ops.accelerationX.onChange(value); + } + + }, + + /** + * The vertical acceleration applied to emitted particles, in pixels per second squared. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + accelerationY: { + + get: function () + { + return this.ops.accelerationY.current; + }, + + set: function (value) + { + this.ops.accelerationY.onChange(value); + } + + }, + + /** + * The maximum horizontal velocity emitted particles can reach, in pixels per second. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + * @default 10000 + */ + maxVelocityX: { + + get: function () + { + return this.ops.maxVelocityX.current; + }, + + set: function (value) + { + this.ops.maxVelocityX.onChange(value); + } + + }, + + /** + * The maximum vertical velocity emitted particles can reach, in pixels per second. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + * @default 10000 + */ + maxVelocityY: { + + get: function () + { + return this.ops.maxVelocityY.current; + }, + + set: function (value) + { + this.ops.maxVelocityY.onChange(value); + } + + }, + + /** + * The initial speed of emitted particles, in pixels per second. + * + * If using this as a getter it will return the `speedX` value. + * + * If using it as a setter it will update both `speedX` and `speedY` to the + * given value. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speed + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + speed: { + + get: function () + { + return this.ops.speedX.current; + }, + + set: function (value) + { + this.ops.speedX.onChange(value); + this.ops.speedY.onChange(value); + } + + }, + + /** + * The initial horizontal speed of emitted particles, in pixels per second. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + speedX: { + + get: function () + { + return this.ops.speedX.current; + }, + + set: function (value) + { + this.ops.speedX.onChange(value); + } + + }, + + /** + * The initial vertical speed of emitted particles, in pixels per second. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + speedY: { + + get: function () + { + return this.ops.speedY.current; + }, + + set: function (value) + { + this.ops.speedY.onChange(value); + } + + }, + + /** + * The x coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + moveToX: { + + get: function () + { + return this.ops.moveToX.current; + }, + + set: function (value) + { + this.ops.moveToX.onChange(value); + } + + }, + + /** + * The y coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + moveToY: { + + get: function () + { + return this.ops.moveToY.current; + }, + + set: function (value) + { + this.ops.moveToY.onChange(value); + } + + }, + + /** + * The amount of velocity particles will use when rebounding off the + * emitter bounds, if set. A value of 0 means no bounce. A value of 1 + * means a full rebound. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + bounce: { + + get: function () + { + return this.ops.bounce.current; + }, + + set: function (value) + { + this.ops.bounce.onChange(value); + } + + }, + + /** + * The horizontal scale of emitted particles. + * + * This is relative to the Emitters scale and that of any parent. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleScaleX + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + particleScaleX: { + + get: function () + { + return this.ops.scaleX.current; + }, + + set: function (value) + { + this.ops.scaleX.onChange(value); + } + + }, + + /** + * The vertical scale of emitted particles. + * + * This is relative to the Emitters scale and that of any parent. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleScaleY + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + particleScaleY: { + + get: function () + { + return this.ops.scaleY.current; + }, + + set: function (value) + { + this.ops.scaleY.onChange(value); + } + + }, + + /** + * A color tint value that is applied to the texture of the emitted + * particle. The value should be given in hex format, i.e. 0xff0000 + * for a red tint, and should not include the alpha channel. + * + * Tints are multiplicative by default, meaning a tint value of white + * (0xffffff) will effectively reset the tint to nothing. + * + * Modify the `ParticleEmitter.tintMode` property to change the tint mode. + * + * When you define the color via the Emitter config you should give + * it as an array of color values. The Particle will then interpolate + * through these colors over the course of its lifespan. Setting this + * will override any `tint` value that may also be given. + * + * This is a WebGL only feature. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleColor + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + particleColor: { + + get: function () + { + return this.ops.color.current; + }, + + set: function (value) + { + this.ops.color.onChange(value); + } + + }, + + /** + * Controls the easing function used when you have created an + * Emitter that uses the `color` property to interpolate the + * tint of Particles over their lifetime. + * + * Setting this has no effect if you haven't also applied a + * `particleColor` to this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#colorEase + * @type {string} + * @since 3.60.0 + */ + colorEase: { + + get: function () + { + return this.ops.color.easeName; + }, + + set: function (value) + { + this.ops.color.setEase(value); + } + + }, + + /** + * A color tint value that is applied to the texture of the emitted + * particle. The value should be given in hex format, i.e. 0xff0000 + * for a red tint, and should not include the alpha channel. + * + * Tints are multiplicative by default, meaning a tint value of white + * (0xffffff) will effectively reset the tint to nothing. + * + * Modify the `ParticleEmitter.tintMode` property to change the tint mode. + * + * The `tint` value will be overridden if a `color` array is provided. + * + * This is a WebGL only feature. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleTint + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + particleTint: { + + get: function () + { + return this.ops.tint.current; + }, + + set: function (value) + { + this.ops.tint.onChange(value); + } + + }, + + /** + * The alpha value of the emitted particles. This is a value + * between 0 and 1. Particles with alpha zero are invisible + * and are therefore not rendered, but are still processed + * by the Emitter. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleAlpha + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + particleAlpha: { + + get: function () + { + return this.ops.alpha.current; + }, + + set: function (value) + { + this.ops.alpha.onChange(value); + } + + }, + + /** + * The lifespan of the emitted particles. This value is given + * in milliseconds and defaults to 1000ms (1 second). When a + * particle reaches this amount it is killed. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + lifespan: { + + get: function () + { + return this.ops.lifespan.current; + }, + + set: function (value) + { + this.ops.lifespan.onChange(value); + } + + }, + + /** + * The angle at which the particles are emitted. The values are + * given in degrees. This allows you to control the direction + * of the emitter. If you wish instead to change the rotation + * of the particles themselves, see the `particleRotate` property. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleAngle + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + particleAngle: { + + get: function () + { + return this.ops.angle.current; + }, + + set: function (value) + { + this.ops.angle.onChange(value); + } + + }, + + /** + * The rotation (or angle) of each particle when it is emitted. + * The value is given in degrees and uses a right-handed + * coordinate system, where 0 degrees points to the right, 90 degrees + * points down and -90 degrees points up. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleRotate + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + particleRotate: { + + get: function () + { + return this.ops.rotate.current; + }, + + set: function (value) + { + this.ops.rotate.onChange(value); + } + + }, + + /** + * The number of particles that are emitted each time an emission + * occurs, i.e. from one 'explosion' or each frame in a 'flow' cycle. + * + * The default is 1. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @see Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + * @since 3.60.0 + */ + quantity: { + + get: function () + { + return this.ops.quantity.current; + }, + + set: function (value) + { + this.ops.quantity.onChange(value); + } + + }, + + /** + * The number of milliseconds to wait after emission before + * the particles start updating. This allows you to emit particles + * that appear 'static' or still on-screen and then, after this value, + * begin to move. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#delay + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + delay: { + + get: function () + { + return this.ops.delay.current; + }, + + set: function (value) + { + this.ops.delay.onChange(value); + } + + }, + + /** + * The number of milliseconds to wait after a particle has finished + * its life before it will be removed. This allows you to 'hold' a + * particle on the screen once it has reached its final state + * before it then vanishes. + * + * Note that all particle updates will cease, including changing + * alpha, scale, movement or animation. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#hold + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @since 3.60.0 + */ + hold: { + + get: function () + { + return this.ops.hold.current; + }, + + set: function (value) + { + this.ops.hold.onChange(value); + } + + }, + + /** + * The internal flow counter. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#flowCounter + * @type {number} + * @since 3.60.0 + */ + flowCounter: { + + get: function () + { + return this.counters[0]; + }, + + set: function (value) + { + this.counters[0] = value; + } + + }, + + /** + * The internal frame counter. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frameCounter + * @type {number} + * @since 3.60.0 + */ + frameCounter: { + + get: function () + { + return this.counters[1]; + }, + + set: function (value) + { + this.counters[1] = value; + } + + }, + + /** + * The internal animation counter. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#animCounter + * @type {number} + * @since 3.60.0 + */ + animCounter: { + + get: function () + { + return this.counters[2]; + }, + + set: function (value) + { + this.counters[2] = value; + } + + }, + + /** + * The internal elapsed counter. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#elapsed + * @type {number} + * @since 3.60.0 + */ + elapsed: { + + get: function () + { + return this.counters[3]; + }, + + set: function (value) + { + this.counters[3] = value; + } + + }, + + /** + * The internal stop counter. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#stopCounter + * @type {number} + * @since 3.60.0 + */ + stopCounter: { + + get: function () + { + return this.counters[4]; + }, + + set: function (value) + { + this.counters[4] = value; + } + + }, + + /** + * The internal complete flag. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#completeFlag + * @type {boolean} + * @since 3.60.0 + */ + completeFlag: { + + get: function () + { + return this.counters[5]; + }, + + set: function (value) + { + this.counters[5] = value; + } + + }, + + /** + * The internal zone index. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#zoneIndex + * @type {number} + * @since 3.60.0 + */ + zoneIndex: { + + get: function () + { + return this.counters[6]; + }, + + set: function (value) + { + this.counters[6] = value; + } + + }, + + /** + * The internal zone total. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#zoneTotal + * @type {number} + * @since 3.60.0 + */ + zoneTotal: { + + get: function () + { + return this.counters[7]; + }, + + set: function (value) + { + this.counters[7] = value; + } + + }, + + /** + * The current frame index. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame + * @type {number} + * @since 3.60.0 + */ + currentFrame: { + + get: function () + { + return this.counters[8]; + }, + + set: function (value) + { + this.counters[8] = value; + } + + }, + + /** + * The current animation index. + * + * Treat this property as read-only. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#currentAnim + * @type {number} + * @since 3.60.0 + */ + currentAnim: { + + get: function () + { + return this.counters[9]; + }, + + set: function (value) + { + this.counters[9] = value; + } + + }, + + /** + * Destroys this Particle Emitter and all Particles it owns. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#preDestroy + * @since 3.60.0 + */ + preDestroy: function () + { + this.texture = null; + this.frames = null; + this.anims = null; + this.emitCallback = null; + this.emitCallbackScope = null; + this.deathCallback = null; + this.deathCallbackScope = null; + this.emitZones = null; + this.deathZones = null; + this.bounds = null; + this.follow = null; + this.counters = null; + + var i; + + var ops = this.ops; + + for (i = 0; i < configOpMap.length; i++) + { + var key = configOpMap[i]; + + ops[key].destroy(); + } + + for (i = 0; i < this.alive.length; i++) + { + this.alive[i].destroy(); + } + + for (i = 0; i < this.dead.length; i++) + { + this.dead[i].destroy(); + } + + this.ops = null; + this.alive = []; + this.dead = []; + this.worldMatrix.destroy(); + } + +}); + +module.exports = ParticleEmitter; + + +/***/ }, + +/***/ 9871 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RectangleToRectangle = __webpack_require__(59996); +var TransformMatrix = __webpack_require__(61340); + +var camMatrix = new TransformMatrix(); +var calcMatrix = new TransformMatrix(); +var particleMatrix = new TransformMatrix(); +var managerMatrix = new TransformMatrix(); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#renderCanvas + * @since 3.60.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ParticleEmitterCanvasRenderer = function (renderer, emitter, camera, parentMatrix) +{ + camera.addToRenderList(emitter); + + camMatrix.copyWithScrollFactorFrom( + camera.matrix, + camera.scrollX, camera.scrollY, + emitter.scrollFactorX, emitter.scrollFactorY + ); + + if (parentMatrix) + { + camMatrix.multiply(parentMatrix); + } + + managerMatrix.applyITRS( + emitter.x, emitter.y, + emitter.rotation, + emitter.scaleX, emitter.scaleY + ); + + camMatrix.multiply(managerMatrix); + + var ctx = renderer.currentContext; + var roundPixels = camera.roundPixels; + var camerAlpha = camera.alpha; + var emitterAlpha = emitter.alpha; + + var particles = emitter.alive; + var particleCount = particles.length; + var viewBounds = emitter.viewBounds; + + if (!emitter.visible || particleCount === 0 || (viewBounds && !RectangleToRectangle(viewBounds, camera.worldView))) + { + return; + } + + if (emitter.sortCallback) + { + emitter.depthSort(); + } + + ctx.save(); + + ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; + + for (var i = 0; i < particleCount; i++) + { + var particle = particles[i]; + + var alpha = particle.alpha * emitterAlpha * camerAlpha; + + if (alpha <= 0 || particle.scaleX === 0 || particle.scaleY === 0) + { + continue; + } + + particleMatrix.applyITRS(particle.x, particle.y, particle.rotation, particle.scaleX, particle.scaleY); + + // Multiply by the particle matrix, store result in calcMatrix + camMatrix.multiply(particleMatrix, calcMatrix); + + var frame = particle.frame; + var cd = frame.canvasData; + + if (cd.width > 0 && cd.height > 0) + { + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + + ctx.globalAlpha = alpha; + + ctx.save(); + + calcMatrix.setToContext(ctx); + + if (roundPixels) + { + x = Math.round(x); + y = Math.round(y); + } + + ctx.imageSmoothingEnabled = !frame.source.scaleMode; + + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = ParticleEmitterCanvasRenderer; + + +/***/ }, + +/***/ 92730 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetFastValue = __webpack_require__(95540); +var ParticleEmitter = __webpack_require__(31600); + +/** + * Creates a new Particle Emitter Game Object and returns it. + * + * A Particle Emitter is a Game Object that produces a stream of particles based on a + * configuration object. It can be used to create effects such as explosions, fire, smoke, + * rain, or any other particle-based visual. The emitter is added to the Scene and managed + * as a standard Game Object, supporting transforms, depth, and other common properties. + * + * Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed + * in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the + * updated function parameters and class documentation for more details. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#particles + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterCreatorConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Game Object that was created. + */ +GameObjectCreator.register('particles', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var emitterConfig = GetFastValue(config, 'config', null); + + var emitter = new ParticleEmitter(this.scene, 0, 0, key); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, emitter, config); + + if (emitterConfig) + { + emitter.setConfig(emitterConfig); + } + + return emitter; +}); + + +/***/ }, + +/***/ 676 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var ParticleEmitter = __webpack_require__(31600); + +/** + * Creates a new Particle Emitter Game Object and adds it to the Scene. + * + * If you wish to configure the Emitter after creating it, use the `ParticleEmitter.setConfig` method. + * + * Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed + * in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the + * updated function parameters and class documentation for more details. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#particles + * @since 3.60.0 + * + * @param {number} [x] - The horizontal position of this Game Object in the world. + * @param {number} [y] - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} [texture] - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} [config] - Configuration settings for the Particle Emitter. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Game Object that was created. + */ +GameObjectFactory.register('particles', function (x, y, texture, config) +{ + if (x !== undefined && typeof x === 'string') + { + console.warn('ParticleEmitterManager was removed in Phaser 3.60. See documentation for details'); + } + + return this.displayList.add(new ParticleEmitter(this.scene, x, y, texture, config)); +}); + + +/***/ }, + +/***/ 90668 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(21188); +} + +if (true) +{ + renderCanvas = __webpack_require__(9871); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 21188 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RectangleToRectangle = __webpack_require__(59996); +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); + +var camMatrix = new TransformMatrix(); +var calcMatrix = new TransformMatrix(); +var particleMatrix = new TransformMatrix(); +var managerMatrix = new TransformMatrix(); + +var tempTexturer = {}; +var tempTinter = {}; +var tempTransformer = { quad: new Float32Array(8) }; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#renderWebGL + * @since 3.60.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ParticleEmitterWebGLRenderer = function (renderer, emitter, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + + camera.addToRenderList(emitter); + + camMatrix.copyWithScrollFactorFrom( + camera.getViewMatrix(!drawingContext.useCanvas), + camera.scrollX, camera.scrollY, + emitter.scrollFactorX, emitter.scrollFactorY + ); + + if (parentMatrix) + { + camMatrix.multiply(parentMatrix); + } + + managerMatrix.applyITRS( + emitter.x, emitter.y, + emitter.rotation, + emitter.scaleX, emitter.scaleY + ); + + camMatrix.multiply(managerMatrix); + + var getTint = Utils.getTintAppendFloatAlpha; + var emitterAlpha = emitter.alpha; + + var particles = emitter.alive; + var particleCount = particles.length; + var viewBounds = emitter.viewBounds; + + if (particleCount === 0 || (viewBounds && !RectangleToRectangle(viewBounds, camera.worldView))) + { + return; + } + + if (emitter.sortCallback) + { + emitter.depthSort(); + } + + var tintEffect = emitter.tintMode; + + for (var i = 0; i < particleCount; i++) + { + var particle = particles[i]; + + var alpha = particle.alpha * emitterAlpha; + + if (alpha <= 0 || particle.scaleX === 0 || particle.scaleY === 0) + { + continue; + } + + particleMatrix.applyITRS(particle.x, particle.y, particle.rotation, particle.scaleX, particle.scaleY); + + // Multiply by the particle matrix, store result in calcMatrix + camMatrix.multiply(particleMatrix, calcMatrix); + + var frame = particle.frame; + + var x = -frame.halfWidth; + var y = -frame.halfHeight; + + calcMatrix.setQuad(x, y, x + frame.width, y + frame.height, tempTransformer.quad); + + if (tempTexturer.frame !== frame) + { + tempTexturer.frame = frame; + tempTexturer.uvSource = frame; + } + + var tint = getTint(particle.tint, alpha); + tempTinter.tintTopLeft = tint; + tempTinter.tintBottomLeft = tint; + tempTinter.tintTopRight = tint; + tempTinter.tintBottomRight = tint; + tempTinter.tintEffect = tintEffect; + + var normalMap, normalMapRotation; + + if (emitter.lighting) + { + if (particle.texture) + { + normalMap = frame.texture.dataSource[frame.sourceIndex]; + } + + normalMapRotation = particle.rotation; + if (emitter.parentContainer) + { + var matrix = emitter.getWorldTransformMatrix(camMatrix, calcMatrix).rotate(particle.rotation); + + normalMapRotation = matrix.rotationNormalized; + } + } + + var customRenderNodes = emitter.customRenderNodes; + var defaultRenderNodes = emitter.defaultRenderNodes; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext, + emitter, + parentMatrix, + 0, + tempTexturer, + tempTransformer, + tempTinter, + + // Optional normal map overrides + normalMap, normalMapRotation + ); + } +}; + +module.exports = ParticleEmitterWebGLRenderer; + + +/***/ }, + +/***/ 20286 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * This class provides the structure required for all Particle Processors. + * + * You should extend it and add the functionality required for your processor, + * including tidying up any resources this may create in the `destroy` method. + * + * See the GravityWell for an example of a processor. + * + * @class ParticleProcessor + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.60.0 + * + * @param {number} [x=0] - The x coordinate of the Particle Processor, in world space. + * @param {number} [y=0] - The y coordinate of the Particle Processor, in world space. + * @param {boolean} [active=true] - The active state of this Particle Processor. + */ +var ParticleProcessor = new Class({ + + initialize: + + function ParticleProcessor (x, y, active) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (active === undefined) { active = true; } + + /** + * A reference to the Particle Emitter that owns this Processor. + * This is set automatically when the Processor is added to an Emitter + * and nulled when removed or destroyed. + * + * @name Phaser.GameObjects.Particles.ParticleProcessor#emitter + * @type {Phaser.GameObjects.Particles.ParticleEmitter} + * @since 3.60.0 + */ + this.emitter; + + /** + * The x coordinate of the Particle Processor, in world space. + * + * @name Phaser.GameObjects.Particles.ParticleProcessor#x + * @type {number} + * @since 3.60.0 + */ + this.x = x; + + /** + * The y coordinate of the Particle Processor, in world space. + * + * @name Phaser.GameObjects.Particles.ParticleProcessor#y + * @type {number} + * @since 3.60.0 + */ + this.y = y; + + /** + * The active state of the Particle Processor. + * + * An inactive Particle Processor will be skipped for processing by + * its parent Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleProcessor#active + * @type {boolean} + * @since 3.60.0 + */ + this.active = active; + }, + + /** + * The Particle Processor update method should be overridden by your own + * method and handle the processing of the particles, typically modifying + * their velocityX/Y values based on the criteria of this processor. + * + * @method Phaser.GameObjects.Particles.ParticleProcessor#update + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {number} t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + */ + update: function () + { + }, + + /** + * Destroys this Particle Processor by removing all external references. + * + * This is called automatically when the owning Particle Emitter is destroyed. + * + * @method Phaser.GameObjects.Particles.ParticleProcessor#destroy + * @since 3.60.0 + */ + destroy: function () + { + this.emitter = null; + } + +}); + +module.exports = ParticleProcessor; + + +/***/ }, + +/***/ 9774 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Particle Emitter Complete Event. + * + * This event is dispatched when the final particle, emitted from a Particle Emitter that + * has been stopped, dies. Upon receipt of this event you know that no particles are + * still rendering at this point in time. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('complete', listener)`. + * + * @event Phaser.GameObjects.Particles.Events#COMPLETE + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - A reference to the Particle Emitter that just completed. + */ +module.exports = 'complete'; + + +/***/ }, + +/***/ 812 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Particle Emitter Death Zone Event. + * + * This event is dispatched when a Death Zone kills a Particle instance. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('deathzone', listener)`. + * + * If you wish to know when the final particle is killed, see the `COMPLETE` event. + * + * @event Phaser.GameObjects.Particles.Events#DEATH_ZONE + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - A reference to the Particle Emitter that owns the Particle and Death Zone. + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle that has been killed. + * @param {Phaser.GameObjects.Particles.Zones.DeathZone} zone - The Death Zone that killed the particle. + */ +module.exports = 'deathzone'; + + +/***/ }, + +/***/ 30522 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Particle Emitter Explode Event. + * + * This event is dispatched when a Particle Emitter explodes a set of particles. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('explode', listener)`. + * + * @event Phaser.GameObjects.Particles.Events#EXPLODE + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - A reference to the Particle Emitter that just completed. + * @param {Phaser.GameObjects.Particles.Particle} particle - The most recently emitted Particle. + */ +module.exports = 'explode'; + + +/***/ }, + +/***/ 96695 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Particle Emitter Start Event. + * + * This event is dispatched when a Particle Emitter starts emission of particles. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('start', listener)`. + * + * @event Phaser.GameObjects.Particles.Events#START + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - A reference to the Particle Emitter that just completed. + */ +module.exports = 'start'; + + +/***/ }, + +/***/ 18677 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Particle Emitter Stop Event. + * + * This event is dispatched when a Particle Emitter is stopped. This can happen either + * when you directly call the `ParticleEmitter.stop` method, or if the emitter has + * been configured to stop after a set time via the `duration` property, or after a + * set number of particles via the `stopAfter` property. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('stop', listener)`. + * + * Note that just because the emitter has stopped, that doesn't mean there aren't still + * particles alive and rendering. It just means the emitter has stopped emitting particles. + * + * If you wish to know when the final particle is killed, see the `COMPLETE` event. + * + * @event Phaser.GameObjects.Particles.Events#STOP + * @type {string} + * @since 3.60.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - A reference to the Particle Emitter that just completed. + */ +module.exports = 'stop'; + + +/***/ }, + +/***/ 20696 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Particles.Events + */ + +module.exports = { + + COMPLETE: __webpack_require__(9774), + DEATH_ZONE: __webpack_require__(812), + EXPLODE: __webpack_require__(30522), + START: __webpack_require__(96695), + STOP: __webpack_require__(18677) + +}; + + +/***/ }, + +/***/ 18404 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Particles + */ + +module.exports = { + + EmitterColorOp: __webpack_require__(76472), + EmitterOp: __webpack_require__(44777), + Events: __webpack_require__(20696), + GravityWell: __webpack_require__(24502), + Particle: __webpack_require__(56480), + ParticleBounds: __webpack_require__(69601), + ParticleEmitter: __webpack_require__(31600), + ParticleProcessor: __webpack_require__(20286), + Zones: __webpack_require__(21024) + +}; + + +/***/ }, + +/***/ 26388 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * A Death Zone. + * + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + * + * @class DeathZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.DeathZoneSource} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + */ +var DeathZone = new Class({ + + initialize: + + function DeathZone (source, killOnEnter) + { + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#source + * @type {Phaser.Types.GameObjects.Particles.DeathZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter + * @type {boolean} + * @since 3.0.0 + */ + this.killOnEnter = killOnEnter; + }, + + /** + * Checks if the given Particle will be killed or not by this zone. + * + * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle to test against this Death Zone. + * + * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. + */ + willKill: function (particle) + { + var pos = particle.worldPosition; + var withinZone = this.source.contains(pos.x, pos.y); + + return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); + } + +}); + +module.exports = DeathZone; + + +/***/ }, + +/***/ 19909 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * An Edge Zone is an emit zone for a Particle Emitter that places emitted particles + * sequentially along the edges of a shape. The shape is defined by a source object + * that provides a `getPoints(quantity, stepRate)` method, such as a Phaser Curve, + * Path, or any compatible geometry object. + * + * As each particle is emitted, it is positioned at the next point along the shape's + * edge, cycling through all points in order. If `yoyo` is enabled, the traversal + * reverses direction when it reaches either end, creating a back-and-forth effect. + * If `seamless` is enabled, duplicate endpoints are removed to avoid stacking + * particles at the join when the shape loops back on itself. + * + * Use this zone when you want particles to trace or outline a shape — for example, + * sparks running along a wire, particles orbiting a path, or effects that follow + * the boundary of a geometric figure. + * + * @class EdgeZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * @param {number} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @param {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. + * @param {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. + * @param {number} [total=-1] - The total number of particles this zone will emit before passing over to the next emission zone in the Emitter. -1 means it will never pass over and you must use `setEmitZone` to change it. + */ +var EdgeZone = new Class({ + + initialize: + + function EdgeZone (source, quantity, stepRate, yoyo, seamless, total) + { + if (yoyo === undefined) { yoyo = false; } + if (seamless === undefined) { seamless = true; } + if (total === undefined) { total = -1; } + + /** + * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source + * @type {Phaser.Types.GameObjects.Particles.EdgeZoneSource|Phaser.Types.GameObjects.Particles.RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * The points placed on the source edge. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points + * @type {Phaser.Math.Vector2[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + /** + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity + * @type {number} + * @since 3.0.0 + */ + this.quantity = quantity; + + /** + * The distance between each particle. When set, `quantity` is implied and should be set to 0. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate + * @type {number} + * @since 3.0.0 + */ + this.stepRate = stepRate; + + /** + * Whether particles are placed from start to end and then end to start. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo + * @type {boolean} + * @since 3.0.0 + */ + this.yoyo = yoyo; + + /** + * The counter used for iterating the EdgeZone's points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.counter = -1; + + /** + * Whether one endpoint will be removed if it's identical to the other. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless + * @type {boolean} + * @since 3.0.0 + */ + this.seamless = seamless; + + /** + * An internal count of the points belonging to this EdgeZone. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._length = 0; + + /** + * An internal value used to keep track of the current iteration direction for the EdgeZone's points. + * + * 0 = forwards, 1 = backwards + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._direction = 0; + + /** + * The total number of particles this zone will emit before the Emitter + * transfers control over to the next zone in its emission zone list. + * + * By default this is -1, meaning it will never pass over from this + * zone to another one. You can call the `ParticleEmitter.setEmitZone` + * method to change it, or set this value to something else via the + * config, or directly at runtime. + * + * A value of 1 would mean the zones rotate in order, but it can + * be set to any integer value. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#total + * @type {number} + * @since 3.60.0 + */ + this.total = total; + + this.updateSource(); + }, + + /** + * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's + * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * + * Also updates internal properties. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource + * @since 3.0.0 + * + * @return {this} This Edge Zone. + */ + updateSource: function () + { + this.points = this.source.getPoints(this.quantity, this.stepRate); + + // Remove ends? + if (this.seamless) + { + var a = this.points[0]; + var b = this.points[this.points.length - 1]; + + if (a.x === b.x && a.y === b.y) + { + this.points.pop(); + } + } + + var oldLength = this._length; + + this._length = this.points.length; + + // Adjust counter if we now have less points than before + if (this._length < oldLength && this.counter > this._length) + { + this.counter = this._length - 1; + } + + return this; + }, + + /** + * Change the source of the EdgeZone, replacing the existing shape with a new one. + * The new source must provide a `getPoints(quantity, stepRate)` method. After + * the source is replaced, `updateSource` is called automatically to regenerate + * the edge points and reset internal state accordingly. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @return {this} This Edge Zone. + */ + changeSource: function (source) + { + this.source = source; + + return this.updateSource(); + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * Points are stepped through sequentially. When the end of the point list is + * reached, the counter wraps back to the start, or reverses direction if `yoyo` + * is enabled. Called automatically by the Particle Emitter each time a new + * particle is emitted. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + if (this._direction === 0) + { + this.counter++; + + if (this.counter >= this._length) + { + if (this.yoyo) + { + this._direction = 1; + this.counter = this._length - 1; + } + else + { + this.counter = 0; + } + } + } + else + { + this.counter--; + + if (this.counter === -1) + { + if (this.yoyo) + { + this._direction = 0; + this.counter = 0; + } + else + { + this.counter = this._length - 1; + } + } + } + + var point = this.points[this.counter]; + + if (point) + { + particle.x = point.x; + particle.y = point.y; + } + } + +}); + +module.exports = EdgeZone; + + +/***/ }, + +/***/ 68875 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Random Zone is an Emit Zone that places particles at random positions within the area of a + * shape. The shape must provide a `getRandomPoint` method, which receives a Vector2 and populates + * it with a random coordinate from anywhere inside the shape. + * + * Phaser geometry objects such as `Phaser.Geom.Rectangle`, `Phaser.Geom.Circle`, + * `Phaser.Geom.Ellipse`, and `Phaser.Geom.Triangle` all implement this method and can be used + * directly as the source for this zone. + * + * Use this zone when you want particles to spawn at random positions distributed across the + * interior of a shape. To spawn particles along the edges of a shape instead, use an EdgeZone. + * + * @class RandomZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Particles.RandomZoneSource} source - An object instance with a `getRandomPoint(point)` method. + */ +var RandomZone = new Class({ + + initialize: + + function RandomZone (source) + { + /** + * An object instance with a `getRandomPoint(point)` method. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#source + * @type {Phaser.Types.GameObjects.Particles.RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Internal calculation vector. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec = new Vector2(); + + /** + * The total number of particles this zone will emit before the Emitter + * transfers control over to the next zone in its emission zone list. + * + * By default this is -1, meaning it will never pass over from this + * zone to another one. You can call the `ParticleEmitter.setEmitZone` + * method to change it, or set this value to something else via the + * config, or directly at runtime. + * + * A value of 1 would mean the zones rotate in order, but it can + * be set to any integer value. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#total + * @type {number} + * @since 3.60.0 + */ + this.total = -1; + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + var vec = this._tempVec; + + this.source.getRandomPoint(vec); + + particle.x = vec.x; + particle.y = vec.y; + } + +}); + +module.exports = RandomZone; + + +/***/ }, + +/***/ 21024 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Particles.Zones + */ + +module.exports = { + + DeathZone: __webpack_require__(26388), + EdgeZone: __webpack_require__(19909), + RandomZone: __webpack_require__(68875) + +}; + + +/***/ }, + +/***/ 1159 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Sprite = __webpack_require__(68287); + +/** + * @classdesc + * A PathFollower is a Sprite that automatically moves along a {@link Phaser.Curves.Path}, making it ideal + * for cutscenes, enemy patrol routes, moving platforms, projectile arcs, or any Game Object that should + * travel a predefined course through the world. + * + * It extends Sprite, so everything available on a standard Sprite — animations, tinting, scaling, + * alpha, blend modes, and so on — works identically here. + * + * A PathFollower is bound to a single Path at any one time and can traverse the full length of that + * Path from start to finish, in either direction, or from any given point along it to the end. + * Playback speed and duration are controlled via a tween-like configuration object passed to + * `startFollow`. The follower can optionally rotate to face the direction of travel, be offset + * from the path coordinates, or rotate independently of the Path. + * + * @class PathFollower + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.PathFollower + * + * @param {Phaser.Scene} scene - The Scene to which this PathFollower belongs. + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var PathFollower = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.PathFollower + ], + + initialize: + + function PathFollower (scene, path, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + this.path = path; + }, + + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + * + * @method Phaser.GameObjects.PathFollower#preUpdate + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + this.pathUpdate(time); + } + +}); + +module.exports = PathFollower; + + +/***/ }, + +/***/ 90145 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var PathFollower = __webpack_require__(1159); + +/** + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * A PathFollower is a Sprite that is bound to a Phaser.Curves.Path and can automatically move along + * that path over time. It is useful for animating characters or objects along predetermined routes, + * such as enemies patrolling a level, vehicles following a road, or any game object that needs to + * travel a curved or multi-segment course. The follower exposes controls to start, stop, pause, and + * resume movement, as well as options for looping and rotation along the path. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#follower + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. + */ +GameObjectFactory.register('follower', function (path, x, y, key, frame) +{ + var sprite = new PathFollower(this.scene, path, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 80321 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DefaultPointLightNodes = __webpack_require__(43246); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var IntegerToColor = __webpack_require__(30100); +var Render = __webpack_require__(67277); + +/** + * @classdesc + * The Point Light Game Object provides a way to add a point light effect into your game, + * without the expensive shader processing requirements of the traditional Light Game Object. + * + * The difference is that the Point Light renders using a custom shader, designed to give the + * impression of a point light source, of variable radius, intensity and color, in your game. + * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their + * normal maps for calculations. This makes them extremely fast to render compared to Lights + * and perfect for special effects, such as flickering torches or muzzle flashes. + * + * For maximum performance you should batch Point Light Game Objects together. This means + * ensuring they follow each other consecutively on the display list. Ideally, use a Layer + * Game Object and then add just Point Lights to it, so that it can batch together the rendering + * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in + * your game then it's perfectly safe to mix them into the display list as normal. However, if + * you're using a large number of them, please consider how they are mixed into the display list. + * + * The renderer will automatically cull Point Lights. Those with a radius that does not intersect + * with the Camera will be skipped in the rendering list. This happens automatically and the + * culled state is refreshed every frame, for every camera. + * + * The origin of a Point Light is always 0.5 and it cannot be changed. + * + * Point Lights are a WebGL only feature and do not have a Canvas counterpart. + * + * @class PointLight + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.50.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Point Light belongs. A Point Light can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Point Light in the world. + * @param {number} y - The vertical position of this Point Light in the world. + * @param {number} [color=0xffffff] - The color of the Point Light, given as a hex value. + * @param {number} [radius=128] - The radius of the Point Light. + * @param {number} [intensity=1] - The intensity, or color blend, of the Point Light. + * @param {number} [attenuation=0.1] - The attenuation of the Point Light. This is the reduction of light from the center point. + */ +var PointLight = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.RenderNodes, + Components.ScrollFactor, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function PointLight (scene, x, y, color, radius, intensity, attenuation) + { + if (color === undefined) { color = 0xffffff; } + if (radius === undefined) { radius = 128; } + if (intensity === undefined) { intensity = 1; } + if (attenuation === undefined) { attenuation = 0.1; } + + GameObject.call(this, scene, 'PointLight'); + + this.initRenderNodes(this._defaultRenderNodesMap); + + this.setPosition(x, y); + + /** + * The color of this Point Light. This property is an instance of a + * Color object, so you can use the methods within it, such as `setTo(r, g, b)` + * to change the color value. + * + * @name Phaser.GameObjects.PointLight#color + * @type {Phaser.Display.Color} + * @since 3.50.0 + */ + this.color = IntegerToColor(color); + + /** + * The intensity of the Point Light. + * + * The colors of the light are multiplied by this value during rendering. + * + * @name Phaser.GameObjects.PointLight#intensity + * @type {number} + * @since 3.50.0 + */ + this.intensity = intensity; + + /** + * The attenuation of the Point Light. + * + * This value controls the force with which the light falls-off from the center of the light. + * + * Use small float-based values, i.e. 0.1. + * + * @name Phaser.GameObjects.PointLight#attenuation + * @type {number} + * @since 3.50.0 + */ + this.attenuation = attenuation; + + // read only: + this.width = radius * 2; + this.height = radius * 2; + + this._radius = radius; + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.PointLight#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultPointLightNodes; + } + }, + + /** + * The radius of the Point Light, in pixels. Changing this value also updates + * the `width` and `height` properties of this Game Object to `radius * 2`. + * + * @name Phaser.GameObjects.PointLight#radius + * @type {number} + * @since 3.50.0 + */ + radius: { + + get: function () + { + return this._radius; + }, + + set: function (value) + { + this._radius = value; + this.width = value * 2; + this.height = value * 2; + } + + }, + + /** + * The horizontal origin of this Point Light. This is always fixed at 0.5 and cannot be changed. + * + * @name Phaser.GameObjects.PointLight#originX + * @type {number} + * @readonly + * @since 3.50.0 + */ + originX: { + + get: function () + { + return 0.5; + } + + }, + + /** + * The vertical origin of this Point Light. This is always fixed at 0.5 and cannot be changed. + * + * @name Phaser.GameObjects.PointLight#originY + * @type {number} + * @readonly + * @since 3.50.0 + */ + originY: { + + get: function () + { + return 0.5; + } + + }, + + /** + * The horizontal display origin of this Point Light, in pixels. This is equal to the radius of the light. + * + * @name Phaser.GameObjects.PointLight#displayOriginX + * @type {number} + * @readonly + * @since 3.50.0 + */ + displayOriginX: { + + get: function () + { + return this._radius; + } + + }, + + /** + * The vertical display origin of this Point Light, in pixels. This is equal to the radius of the light. + * + * @name Phaser.GameObjects.PointLight#displayOriginY + * @type {number} + * @readonly + * @since 3.50.0 + */ + displayOriginY: { + + get: function () + { + return this._radius; + } + + } + +}); + +module.exports = PointLight; + + +/***/ }, + +/***/ 39829 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var PointLight = __webpack_require__(80321); + +/** + * Creates a new Point Light Game Object and returns it. + * + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#pointlight + * @since 3.50.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. Supported properties include `color` (hex color of the light, default `0xffffff`), `radius` (radius of the light in pixels, default `128`), `intensity` (brightness of the light, default `1`), and `attenuation` (rate at which the light falls off toward the edges, default `0.1`). + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.PointLight} The Game Object that was created. + */ +GameObjectCreator.register('pointlight', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var color = GetAdvancedValue(config, 'color', 0xffffff); + var radius = GetAdvancedValue(config, 'radius', 128); + var intensity = GetAdvancedValue(config, 'intensity', 1); + var attenuation = GetAdvancedValue(config, 'attenuation', 0.1); + + var layer = new PointLight(this.scene, 0, 0, color, radius, intensity, attenuation); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, layer, config); + + return layer; +}); + + +/***/ }, + +/***/ 71255 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var PointLight = __webpack_require__(80321); + +/** + * Creates a new Point Light Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * + * The Point Light Game Object provides a way to add a point light effect into your game, + * without the expensive shader processing requirements of the traditional Light Game Object. + * + * The difference is that the Point Light renders using a custom shader, designed to give the + * impression of a point light source, of variable radius, intensity and color, in your game. + * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their + * normal maps for calculations. This makes them extremely fast to render compared to Lights + * and perfect for special effects, such as flickering torches or muzzle flashes. + * + * For maximum performance you should batch Point Light Game Objects together. This means + * ensuring they follow each other consecutively on the display list. Ideally, use a Layer + * Game Object and then add just Point Lights to it, so that it can batch together the rendering + * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in + * your game then it's perfectly safe to mix them into the display list as normal. However, if + * you're using a large number of them, please consider how they are mixed into the display list. + * + * The renderer will automatically cull Point Lights. Those with a radius that does not intersect + * with the Camera will be skipped in the rendering list. This happens automatically and the + * culled state is refreshed every frame, for every camera. + * + * The origin of a Point Light is always 0.5 and it cannot be changed. + * + * Point Lights are a WebGL only feature and do not have a Canvas counterpart. + * + * @method Phaser.GameObjects.GameObjectFactory#pointlight + * @since 3.50.0 + * + * @param {number} x - The horizontal position of this Point Light in the world. + * @param {number} y - The vertical position of this Point Light in the world. + * @param {number} [color=0xffffff] - The color of the Point Light, given as a hex value. + * @param {number} [radius=128] - The radius of the Point Light. + * @param {number} [intensity=1] - The intensity, or color blend, of the Point Light. + * @param {number} [attenuation=0.1] - The attenuation of the Point Light. This is the reduction of light from the center point. + * + * @return {Phaser.GameObjects.PointLight} The Game Object that was created. + */ +GameObjectFactory.register('pointlight', function (x, y, color, radius, intensity, attenuation) +{ + return this.displayList.add(new PointLight(this.scene, x, y, color, radius, intensity, attenuation)); +}); + + +/***/ }, + +/***/ 67277 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(57787); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 57787 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.PointLight#renderWebGL + * @since 3.50.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.PointLight} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PointLightWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var width = src.width; + var height = src.height; + + var x = -src._radius; + var y = -src._radius; + + var xw = x + width; + var yh = y + height; + + var lightX = calcMatrix.getX(0, 0); + var lightY = calcMatrix.getY(0, 0); + + var txTL = calcMatrix.getX(x, y); + var tyTL = calcMatrix.getY(x, y); + + var txBL = calcMatrix.getX(x, yh); + var tyBL = calcMatrix.getY(x, yh); + + var txBR = calcMatrix.getX(xw, yh); + var tyBR = calcMatrix.getY(xw, yh); + + var txTR = calcMatrix.getX(xw, y); + var tyTR = calcMatrix.getY(xw, y); + + (src.customRenderNodes.BatchHandler || src.defaultRenderNodes.BatchHandler).batch( + drawingContext, + src, + txTL, tyTL, + txBL, tyBL, + txTR, tyTR, + txBR, tyBR, + lightX, lightY + ); +}; + +module.exports = PointLightWebGLRenderer; + + +/***/ }, + +/***/ 591 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var UUID = __webpack_require__(45650); +var Image = __webpack_require__(88571); +var RenderTextureRender = __webpack_require__(83999); +var RenderTextureRenderModes = __webpack_require__(58855); + +/** + * @classdesc + * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the + * Dynamic Texture to display itself with. + * + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of + * Game Objects directly to it. + * + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. + * + * In versions of Phaser before 3.60 a Render Texture was the only way you could create a texture + * like this, that had the ability to be drawn on. But in 3.60 we split the core functions out to + * the Dynamic Texture class as it made a lot more sense for them to reside in there. As a result, + * the Render Texture is now a light-weight shim that sits on-top of an Image Game Object and offers + * proxy methods to the features available from a Dynamic Texture. + * + * **When should you use a Render Texture vs. a Dynamic Texture?** + * + * You should use a Dynamic Texture if the texture is going to be used by multiple Game Objects, + * or you want to use it across multiple Scenes, because textures are globally stored. + * + * You should use a Dynamic Texture if the texture isn't going to be displayed in-game, but is + * instead going to be used for something like a mask or shader. + * + * You should use a Render Texture if you need to display the texture in-game on a single Game Object, + * as it provides the convenience of wrapping an Image and Dynamic Texture together for you. + * + * Under WebGL1, a FrameBuffer, which is what this Dynamic Texture uses internally, cannot be anti-aliased. + * This means that when drawing objects such as Shapes or Graphics instances to this texture, they may appear + * to be drawn with no aliasing around the edges. This is a technical limitation of WebGL1. To get around it, + * create your shape as a texture in an art package, then draw that to this texture. + * + * If you activate mipmap support in your game, it will not automatically + * be applied to DynamicTextures. + * This is because regenerating the mipmap for a texture + * costs over 10 microseconds, a big performance loss for a single frame. + * If you want to render your DynamicTextures with mipmaps, + * you must also activate the render config option `mipmapRegeneration`. + * + * In the event that the WebGL context is lost, this DynamicTexture will + * lose its contents. Once context is restored (signalled by the `restorewebgl` + * event), you can choose to redraw the contents of the DynamicTexture. + * You are responsible for the redrawing logic. + * + * @class RenderTexture + * @extends Phaser.GameObjects.Image + * @memberof Phaser.GameObjects + * @constructor + * @since 3.2.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=32] - The width of the Render Texture. + * @param {number} [height=32] - The height of the Render Texture. + * @param {boolean} [forceEven=true] - Force the given width and height to be rounded to even values. This significantly improves the rendering quality. Set to false if you know you need an odd sized texture. + */ +var RenderTexture = new Class({ + + Extends: Image, + + Mixins: [ + RenderTextureRender + ], + + initialize: + + function RenderTexture (scene, x, y, width, height, forceEven) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 32; } + if (height === undefined) { height = 32; } + if (forceEven === undefined) { forceEven = true; } + + var dynamicTexture = scene.sys.textures.addDynamicTexture(UUID(), width, height, forceEven); + + Image.call(this, scene, x, y, dynamicTexture); + + this.type = 'RenderTexture'; + + /** + * An internal Camera that can be used to move around this Render Texture. + * + * Control it just like you would any Scene Camera. The difference is that it only impacts + * the placement of Game Objects that you then draw to this texture. + * + * You can scroll, zoom and rotate this Camera. + * + * This property is a reference to `RenderTexture.texture.camera`. + * + * @name Phaser.GameObjects.RenderTexture#camera + * @type {Phaser.Cameras.Scene2D.BaseCamera} + * @since 3.12.0 + */ + this.camera = this.texture.camera; + + /** + * Internal saved texture flag. + * + * @name Phaser.GameObjects.RenderTexture#_saved + * @type {boolean} + * @private + * @since 3.12.0 + */ + this._saved = false; + + /** + * The render mode of this Render Texture. + * Set this property to change how the Render Texture is rendered. + * + * - 'render' mode draws the contents of the Render Texture to each frame. + * - 'redraw' mode calls `render()` and redraws the texture every frame, + * but does not render itself. This is useful for updating textures + * for reuse by other objects. + * - 'all' mode calls `render()` then draws the texture to the frame. + * + * @name Phaser.GameObjects.RenderTexture#renderMode + * @type {'render'|'redraw'|'all'} + * @default 'render' + * @since 4.0.0 + */ + this.renderMode = RenderTextureRenderModes.RENDER; + + /** + * Whether this RenderTexture is currently executing `renderWebGL`. + * This is used to prevent infinite loops when drawing containers. + * You should not set this property directly. + * + * @name Phaser.GameObjects.RenderTexture#isCurrentlyRendering + * @type {boolean} + * @readonly + * @since 4.0.0 + */ + this.isCurrentlyRendering = false; + }, + + /** + * Sets the internal size of this Render Texture, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. You could also call the `resize` method, as that + * will resize the underlying texture. + * + * If you have enabled this Game Object for input, changing the size will also change the + * size of the hit area, unless you have defined a custom hit area. + * + * @method Phaser.GameObjects.RenderTexture#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + this.updateDisplayOrigin(); + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = width; + input.hitArea.height = height; + } + + return this; + }, + + /** + * Resizes the Render Texture to the new dimensions given. + * + * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. + * In Canvas it will resize the underlying canvas element. + * + * Both approaches will erase everything currently drawn to the Render Texture. + * + * Calling this will then invoke the `setSize` method, setting the internal size of this Game Object + * to the values given to this method. + * + * Calling this will then invoke the `setSize` method, setting the internal size of this Game Object + * to the values given to this method. + * + * If the dimensions given are the same as those already being used, calling this method will do nothing. + * + * @method Phaser.GameObjects.RenderTexture#resize + * @since 3.10.0 + * + * @param {number} width - The new width of the Render Texture. + * @param {number} [height=width] - The new height of the Render Texture. If not specified, will be set the same as the `width`. + * @param {boolean} [forceEven=true] - Force the given width and height to be rounded to even values. This significantly improves the rendering quality. Set to false if you know you need an odd sized texture. + * + * @return {this} This Render Texture. + */ + resize: function (width, height, forceEven) + { + this.texture.setSize(width, height, forceEven); + + this.setSize(this.texture.width, this.texture.height); + + return this; + }, + + /** + * Stores a copy of this Render Texture in the Texture Manager using the given key. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * + * If you destroy this Render Texture, any Game Object using it via the Texture Manager will + * stop rendering. Ensure you remove the texture from the Texture Manager and any Game Objects + * using it first, before destroying this Render Texture. + * + * Note that the texture is assigned a random key on creation. + * This key will be replaced with the new key. + * If the texture was previously removed from the texture manager, + * it will be added back so it can be reused. + * + * @method Phaser.GameObjects.RenderTexture#saveTexture + * @since 3.12.0 + * + * @param {string} key - The unique key to store the texture as within the global Texture Manager. + * + * @return {Phaser.Textures.DynamicTexture} The Texture that was saved. + */ + saveTexture: function (key) + { + var texture = this.texture; + var oldKey = texture.key; + var textureManager = texture.manager; + if (textureManager.exists(oldKey) && textureManager.get(oldKey) === texture) + { + textureManager.renameTexture(oldKey, key); + + this._saved = true; + } + else + { + texture.key = key; + + if (texture.manager.addDynamicTexture(texture)) + { + this._saved = true; + } + } + + return texture; + }, + + /** + * Set the `renderMode` of this Render Texture. + * Set this to change how the Render Texture is rendered. + * + * - 'render' mode draws the contents of the Render Texture to each frame. + * - 'redraw' mode calls `render()` and redraws the texture every frame, + * but does not render itself. This is useful for updating textures + * for reuse by other objects. + * - 'all' mode calls `render()` then draws the texture to the frame. + * + * @method Phaser.GameObjects.RenderTexture#setRenderMode + * @since 4.0.0 + * @param {'render'|'redraw'|'all'} mode - The render mode to set. + * @param {boolean} [preserve=false] - Whether to call `preserve(true)` to preserve the current command buffer. + * @return {this} This Render Texture instance. + */ + setRenderMode: function (mode, preserve) + { + this.renderMode = mode; + + if (preserve) + { + this.texture.preserve(true); + } + + return this; + }, + + /** + * Render the buffered drawing commands to this Dynamic Texture. + * You must do this in order to see anything drawn to it. + * + * @method Phaser.GameObjects.RenderTexture#render + * @since 4.0.0 + */ + render: function () + { + this.texture.render(); + + return this; + }, + + /** + * Fills this Render Texture with the given color. + * + * By default it will fill the entire texture, however you can set it to fill a specific + * rectangular area by using the x, y, width and height arguments. + * + * The color should be given in hex format, i.e. 0xff0000 for red, 0x00ff00 for green, etc. + * + * @method Phaser.GameObjects.RenderTexture#fill + * @since 3.2.0 + * + * @param {number} rgb - The color to fill this Render Texture with, such as 0xff0000 for red. + * @param {number} [alpha=1] - The alpha value used by the fill. + * @param {number} [x=0] - The left coordinate of the fill rectangle. + * @param {number} [y=0] - The top coordinate of the fill rectangle. + * @param {number} [width=this.width] - The width of the fill rectangle. + * @param {number} [height=this.height] - The height of the fill rectangle. + * + * @return {this} This Render Texture instance. + */ + fill: function (rgb, alpha, x, y, width, height) + { + this.texture.fill(rgb, alpha, x, y, width, height); + + return this; + }, + + /** + * Clears a portion or everything from this Render Texture by erasing it and resetting it back to + * a blank, transparent, texture. To clear an area, specify the `x`, `y`, `width` and `height`. + * + * @method Phaser.GameObjects.RenderTexture#clear + * @since 3.2.0 + * + * @param {number} [x=0] - The left coordinate of the clear rectangle. + * @param {number} [y=0] - The top coordinate of the clear rectangle. + * @param {number} [width=this.width] - The width of the clear rectangle. + * @param {number} [height=this.height] - The height of the clear rectangle. + * + * @return {this} This Render Texture instance. + */ + clear: function (x, y, width, height) + { + this.texture.clear(x, y, width, height); + + return this; + }, + + /** + * Takes the given texture key and frame and then stamps it at the given + * x and y coordinates. You can use the optional 'config' argument to provide + * lots more options about how the stamp is applied, including the alpha, + * tint, angle, scale and origin. + * + * By default, the frame will stamp on the x/y coordinates based on its center. + * + * If you wish to stamp from the top-left, set the config `originX` and + * `originY` properties both to zero. + * + * This method ignores the `camera` property of the Dynamic Texture. + * + * @method Phaser.GameObjects.RenderTexture#stamp + * @since 3.60.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|number)} [frame] - The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param {number} [x=0] - The x position to draw the frame at. + * @param {number} [y=0] - The y position to draw the frame at. + * @param {Phaser.Types.Textures.StampConfig} [config] - The stamp configuration object, allowing you to set the alpha, tint, angle, scale and origin of the stamp. + * + * @return {this} This Render Texture instance. + */ + stamp: function (key, frame, x, y, config) + { + this.texture.stamp(key, frame, x, y, config); + + return this; + }, + + /** + * Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE. + * This has the effect of erasing any filled pixels present in the objects from this texture. + * + * This method uses the `draw` method internally, + * and the parameters behave the same way. + * + * @method Phaser.GameObjects.RenderTexture#erase + * @since 3.16.0 + * + * @param {any} entries - Any renderable Game Object, or Group, Container, Display List, Render Texture, Texture Frame, or an array of any of these. + * @param {number} [x=0] - The x position to draw the Frame at, or the offset applied to the object. + * @param {number} [y=0] - The y position to draw the Frame at, or the offset applied to the object. + * + * @return {this} This Render Texture instance. + */ + erase: function (entries, x, y) + { + this.texture.erase(entries, x, y); + + return this; + }, + + /** + * Draws the given object, or an array of objects, to this RenderTexture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene Display List. Pass in `Scene.children` to draw the whole list. + * * Another Dynamic Texture, or a Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up the texture from the Texture Manager. + * + * Note 1: You cannot draw a Render Texture to itself. + * + * Note 2: GameObjects will use the camera, while textures and frames will not. + * Textures and frames are drawn using the `stamp` method. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * For textures and frames, the `x` and `y` values are the middle of the texture. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * @method Phaser.GameObjects.RenderTexture#draw + * @since 3.2.0 + * + * @param {any} entries - Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param {number} [x=0] - The x position to draw the Frame at, or the offset applied to the object. + * @param {number} [y=0] - The y position to draw the Frame at, or the offset applied to the object. + * @param {number} [alpha=1] - The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. + * @param {number} [tint=0xffffff] - The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. + * + * @return {this} This Render Texture instance. + */ + draw: function (entries, x, y, alpha, tint) + { + this.texture.draw(entries, x, y, alpha, tint); + + return this; + }, + + /** + * Draws the given object to this Render Texture. + * This allows you to draw the object as it appears in the game world, + * or with various parameter overrides in the config. + * + * @method Phaser.GameObjects.RenderTexture#capture + * @since 4.0.0 + * + * @param {Phaser.GameObjects.GameObject} entry - Any renderable GameObject. + * @param {Phaser.Types.Textures.CaptureConfig} config - The configuration object for the capture. + * + * @return {this} This Render Texture instance. + */ + capture: function (entry, config) + { + this.texture.capture(entry, config); + + return this; + }, + + /** + * Takes the given Texture Frame and draws it to this Dynamic Texture as a fill pattern, + * i.e. in a grid-layout based on the frame dimensions. + * It uses a `TileSprite` internally to draw the frame repeatedly. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * You can optionally provide a position, width, height, alpha and tint value to apply to + * the frames before they are drawn. The position controls the top-left where the repeating + * fill will start from. The width and height control the size of the filled area. + * + * The position can be negative if required, but the dimensions cannot. + * + * This method respects the camera settings of the Dynamic Texture. + * + * @method Phaser.GameObjects.RenderTexture#repeat + * @since 3.60.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|number)} [frame] - The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param {number} [x=0] - The x position to start drawing the frames from (can be negative to offset). + * @param {number} [y=0] - The y position to start drawing the frames from (can be negative to offset). + * @param {number} [width=this.width] - The width of the area to repeat the frame within. Defaults to the width of this Dynamic Texture. + * @param {number} [height=this.height] - The height of the area to repeat the frame within. Defaults to the height of this Dynamic Texture. + * @param {Phaser.Types.GameObjects.TileSprite.TileSpriteConfig} [config] - The configuration object for the TileSprite which repeats the texture, allowing you to set further properties on it. + * + * @return {this} This Render Texture instance. + */ + repeat: function (key, frame, x, y, width, height, config) + { + this.texture.repeat(key, frame, x, y, width, height, config); + + return this; + }, + + /** + * Sets the preserve flag for this Dynamic Texture. + * Ordinarily, after each render, the command buffer is cleared. + * When this flag is set to `true`, the command buffer is preserved between renders. + * This makes it possible to repeat the same drawing commands on each render. + * + * Make sure to call `clear()` at the start if you don't want to accumulate + * drawing detail over the top of itself. + * + * @method Phaser.GameObjects.RenderTexture#preserve + * @since 4.0.0 + * @param {boolean} preserve - Whether to preserve the command buffer after rendering. + * @return {this} This Render Texture instance. + */ + preserve: function (preserve) + { + this.texture.preserve(preserve); + + return this; + }, + + /** + * Adds a callback to run during the render process. + * This callback runs as a step in the command buffer. + * It can be used to set up conditions for the next draw step. + * + * Note that this will only execute after `render()` is called. + * + * @method Phaser.GameObjects.RenderTexture#callback + * @since 4.0.0 + * @param {Function} callback - A callback function to run during the render process. + * @return {this} This Render Texture instance. + */ + callback: function (callback) + { + this.texture.callback(callback); + + return this; + }, + + /** + * Takes a snapshot of the given area of this Render Texture. + * + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture the whole Render Texture see the `snapshot` method. + * To capture just a specific pixel, see the `snapshotPixel` method. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer + * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally + * creating an Image object from it, which is the image returned to the callback provided. + * + * All in all, this is a computationally expensive and blocking process, which gets more expensive + * the larger the resolution this Render Texture has, so please be careful how you employ this in your game. + * + * @method Phaser.GameObjects.RenderTexture#snapshotArea + * @since 3.19.0 + * + * @param {number} x - The x coordinate to grab from. + * @param {number} y - The y coordinate to grab from. + * @param {number} width - The width of the area to grab. + * @param {number} height - The height of the area to grab. + * @param {Phaser.Types.Renderer.Snapshot.SnapshotCallback} callback - The Function to invoke after the snapshot image is created. + * @param {string} [type='image/png'] - The format of the image to create, usually `image/png` or `image/jpeg`. + * @param {number} [encoderOptions=0.92] - The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. + * + * @return {this} This Render Texture instance. + */ + snapshotArea: function (x, y, width, height, callback, type, encoderOptions) + { + this.texture.snapshotArea(x, y, width, height, callback, type, encoderOptions); + + return this; + }, + + /** + * Takes a snapshot of the whole of this Render Texture. + * + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture a portion of this Render Texture see the `snapshotArea` method. + * To capture just a specific pixel, see the `snapshotPixel` method. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer + * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally + * creating an Image object from it, which is the image returned to the callback provided. + * + * All in all, this is a computationally expensive and blocking process, which gets more expensive + * the larger the resolution this Render Texture has, so please be careful how you employ this in your game. + * + * @method Phaser.GameObjects.RenderTexture#snapshot + * @since 3.19.0 + * + * @param {Phaser.Types.Renderer.Snapshot.SnapshotCallback} callback - The Function to invoke after the snapshot image is created. + * @param {string} [type='image/png'] - The format of the image to create, usually `image/png` or `image/jpeg`. + * @param {number} [encoderOptions=0.92] - The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. + * + * @return {this} This Render Texture instance. + */ + snapshot: function (callback, type, encoderOptions) + { + return this.texture.snapshot(callback, type, encoderOptions); + }, + + /** + * Takes a snapshot of the given pixel from this Render Texture. + * + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture the whole Render Texture see the `snapshot` method. + * To capture a portion of this Render Texture see the `snapshotArea` method. + * + * Unlike the two other snapshot methods, this one will send your callback a `Color` object + * containing the color data for the requested pixel. It doesn't need to create an internal + * Canvas or Image object, so is a lot faster to execute, using less memory than the other snapshot methods. + * + * @method Phaser.GameObjects.RenderTexture#snapshotPixel + * @since 3.19.0 + * + * @param {number} x - The x coordinate of the pixel to get. + * @param {number} y - The y coordinate of the pixel to get. + * @param {Phaser.Types.Renderer.Snapshot.SnapshotCallback} callback - The Function to invoke after the snapshot pixel data is extracted. + * + * @return {this} This Render Texture instance. + */ + snapshotPixel: function (x, y, callback) + { + return this.texture.snapshotPixel(x, y, callback); + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.RenderTexture#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.camera = null; + + if (!this._saved) + { + this.texture.destroy(); + } + } + +}); + +module.exports = RenderTexture; + + +/***/ }, + +/***/ 97272 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ImageCanvasRenderer = __webpack_require__(40652); +var RenderTextureRenderModes = __webpack_require__(58855); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + var redraw = true; + var render = true; + if (src.renderMode === RenderTextureRenderModes.REDRAW) + { + render = false; + } + else if (src.renderMode === RenderTextureRenderModes.RENDER) + { + redraw = false; + } + + if (redraw) + { + src.render(); + } + + if (render) + { + ImageCanvasRenderer(renderer, src, camera, parentMatrix); + } +}; + +module.exports = RenderTextureCanvasRenderer; + + +/***/ }, + +/***/ 34495 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var RenderTexture = __webpack_require__(591); + +/** + * Creates a new Render Texture Game Object and returns it. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the + * Dynamic Texture to display itself with. + * + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of + * Game Objects directly to it. + * + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. + * + * @method Phaser.GameObjects.GameObjectCreator#renderTexture + * @since 3.2.0 + * + * @param {Phaser.Types.GameObjects.RenderTexture.RenderTextureConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectCreator.register('renderTexture', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 32); + var height = GetAdvancedValue(config, 'height', 32); + + var renderTexture = new RenderTexture(this.scene, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, renderTexture, config); + + return renderTexture; +}); + + +/***/ }, + +/***/ 60505 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var RenderTexture = __webpack_require__(591); + +/** + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the + * Dynamic Texture to display itself with. + * + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kinds of + * Game Objects directly to it. + * + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. + * + * @method Phaser.GameObjects.GameObjectFactory#renderTexture + * @since 3.2.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=32] - The width of the Render Texture. + * @param {number} [height=32] - The height of the Render Texture. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectFactory.register('renderTexture', function (x, y, width, height) +{ + return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); +}); + + +/***/ }, + +/***/ 83999 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(53937); +} + +if (true) +{ + renderCanvas = __webpack_require__(97272); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 58855 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +module.exports = { + + RENDER: 'render', + REDRAW: 'redraw', + ALL: 'all' + +}; + + +/***/ }, + +/***/ 53937 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ImageWebGLRenderer = __webpack_require__(99517); +var RenderTextureRenderModes = __webpack_require__(58855); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + if (src.isCurrentlyRendering) + { + return; + } + src.isCurrentlyRendering = true; + + var redraw = true; + var render = true; + if (src.renderMode === RenderTextureRenderModes.REDRAW) + { + render = false; + } + else if (src.renderMode === RenderTextureRenderModes.RENDER) + { + redraw = false; + } + + if (redraw) + { + src.render(); + } + + if (render) + { + ImageWebGLRenderer(renderer, src, drawingContext, parentMatrix); + } + + src.isCurrentlyRendering = false; +}; + +module.exports = RenderTextureWebGLRenderer; + + +/***/ }, + +/***/ 77757 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AnimationState = __webpack_require__(9674); +var DefaultRopeNodes = __webpack_require__(85760); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var RopeRender = __webpack_require__(38745); +var TintModes = __webpack_require__(84322); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * A Rope Game Object. + * + * The Rope object is WebGL only and does not have a Canvas counterpart. + * + * A Rope is a special kind of Game Object that has a texture that is stretched along its entire length, + * mapped across a series of vertices that you define. This makes it ideal for creating effects such as + * flags waving in the wind, banners, cloth, chains, wavy water surfaces, or any shape that needs a + * texture bent or deformed along a path. + * + * Unlike a Sprite, it isn't restricted to using just a quad and can have as many vertices as you define + * when creating it. The vertices can be arranged in a horizontal or vertical strip and have their own + * color and alpha values as well. You can modify the vertex positions each frame to animate the shape + * of the Rope in real-time. + * + * The Rope also supports animations via the `anims` property, allowing you to play frame-based + * animations from a texture atlas across the surface of the Rope. + * + * A Rope's origin is always 0.5 x 0.5 and cannot be changed. + * + * This object does not support trimmed textures from Texture Packer. + * Trimming may interfere with the vertex arrangement. + * + * @class Rope + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.23.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {string} [texture] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. If not given, `__DEFAULT` is used. + * @param {(string|number|null)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {(number|Phaser.Types.Math.Vector2Like[])} [points=2] - An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided a simple quad is created. See `setPoints` to set this post-creation. + * @param {boolean} [horizontal=true] - Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? + * @param {number[]} [colors] - An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. + * @param {number[]} [alphas] - An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. + */ +var Rope = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.Mask, + Components.RenderNodes, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + RopeRender + ], + + initialize: + + function Rope (scene, x, y, texture, frame, points, horizontal, colors, alphas) + { + if (texture === undefined) { texture = '__DEFAULT'; } + if (points === undefined) { points = 2; } + if (horizontal === undefined) { horizontal = true; } + + GameObject.call(this, scene, 'Rope'); + + /** + * The Animation State of this Rope. + * + * @name Phaser.GameObjects.Rope#anims + * @type {Phaser.Animations.AnimationState} + * @since 3.23.0 + */ + this.anims = new AnimationState(this); + + /** + * An array containing the points data for this Rope. + * + * Each point should be given as a Vector2Like object (i.e. a Vector2 or object with public x/y properties). + * + * The point coordinates are given in local space, where 0 x 0 is the start of the Rope strip. + * + * You can modify the contents of this array directly in real-time to create interesting effects. + * If you do so, be sure to call `setDirty` _after_ modifying this array, so that the vertices data is + * updated before the next render. Alternatively, you can use the `setPoints` method instead. + * + * Should you need to change the _size_ of this array, then you should always use the `setPoints` method. + * + * @name Phaser.GameObjects.Rope#points + * @type {Phaser.Types.Math.Vector2Like[]} + * @since 3.23.0 + */ + this.points = points; + + /** + * An array containing the vertices data for this Rope. + * + * This data is calculated automatically in the `updateVertices` method, based on the points provided. + * + * @name Phaser.GameObjects.Rope#vertices + * @type {Float32Array} + * @since 3.23.0 + */ + this.vertices; + + /** + * An array containing the uv data for this Rope. + * + * This data is calculated automatically in the `setPoints` method, based on the points provided. + * + * @name Phaser.GameObjects.Rope#uv + * @type {Float32Array} + * @since 3.23.0 + */ + this.uv; + + /** + * An array containing the color data for this Rope. + * + * Colors should be given as numeric RGB values, such as 0xff0000. + * You should provide _two_ color values for every point in the Rope, one for the top and one for the bottom of each quad. + * + * You can modify the contents of this array directly in real-time, however, should you need to change the _size_ + * of the array, then you should use the `setColors` method instead. + * + * @name Phaser.GameObjects.Rope#colors + * @type {Uint32Array} + * @since 3.23.0 + */ + this.colors; + + /** + * An array containing the alpha data for this Rope. + * + * Alphas should be given as float values, such as 0.5. + * You should provide _two_ alpha values for every point in the Rope, one for the top and one for the bottom of each quad. + * + * You can modify the contents of this array directly in real-time, however, should you need to change the _size_ + * of the array, then you should use the `setAlphas` method instead. + * + * @name Phaser.GameObjects.Rope#alphas + * @type {Float32Array} + * @since 3.23.0 + */ + this.alphas; + + /** + * The tint mode to use when applying the tint to the texture. + * + * Available modes are: + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL (default when the texture is __DEFAULT) + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * + * Rope does not currently support secondary tint colors or modes. + * + * @name Phaser.GameObjects.Rope#tintMode + * @type {Phaser.TintModes} + * @default Phaser.TintModes.MULTIPLY + * @since 4.0.0 + */ + this.tintMode = (texture === '__DEFAULT') ? TintModes.FILL : TintModes.MULTIPLY; + + /** + * If the Rope is marked as `dirty` it will automatically recalculate its vertices + * the next time it renders. You can also force this by calling `updateVertices`. + * + * @name Phaser.GameObjects.Rope#dirty + * @type {boolean} + * @since 3.23.0 + */ + this.dirty = false; + + /** + * Are the Rope vertices aligned horizontally, in a strip, or vertically, in a column? + * + * This property is set during instantiation and cannot be changed directly. + * See the `setVertical` and `setHorizontal` methods. + * + * @name Phaser.GameObjects.Rope#horizontal + * @type {boolean} + * @readonly + * @since 3.23.0 + */ + this.horizontal = horizontal; + + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @name Phaser.GameObjects.Rope#_flipX + * @type {boolean} + * @default false + * @private + * @since 3.23.0 + */ + this._flipX = false; + + /** + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @name Phaser.GameObjects.Rope#_flipY + * @type {boolean} + * @default false + * @private + * @since 3.23.0 + */ + this._flipY = false; + + /** + * Internal Vector2 used for vertices updates. + * + * @name Phaser.GameObjects.Rope#_perp + * @type {Phaser.Math.Vector2} + * @private + * @since 3.23.0 + */ + this._perp = new Vector2(); + + /** + * You can optionally choose to render the vertices of this Rope to a Graphics instance. + * + * Achieve this by setting the `debugCallback` and the `debugGraphic` properties. + * + * You can do this in a single call via the `Rope.setDebug` method, which will use the + * built-in debug function. You can also set it to your own callback. The callback + * will be invoked _once per render_ and sent the following parameters: + * + * `debugCallback(src, meshLength, verts)` + * + * `src` is the Rope instance being debugged. + * `meshLength` is the number of mesh vertices in total. + * `verts` is an array of the translated vertex coordinates. + * + * To disable rendering, set this property back to `null`. + * + * @name Phaser.GameObjects.Rope#debugCallback + * @type {function} + * @since 3.23.0 + */ + this.debugCallback = null; + + /** + * The Graphics instance that the debug vertices will be drawn to, if `setDebug` has + * been called. + * + * @name Phaser.GameObjects.Rope#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.23.0 + */ + this.debugGraphic = null; + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.initRenderNodes(this._defaultRenderNodesMap); + + if (Array.isArray(points)) + { + this.resizeArrays(points.length); + } + + this.setPoints(points, colors, alphas); + + this.updateVertices(); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Rope#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultRopeNodes; + } + }, + + /** + * Called automatically by Phaser when this Game Object is added to a Scene. + * Registers this Rope with the Scene's update list so that `preUpdate` is called each frame. + * + * @method Phaser.GameObjects.Rope#addedToScene + * @since 3.23.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Called automatically by Phaser when this Game Object is removed from a Scene. + * Removes this Rope from the Scene's update list so that `preUpdate` is no longer called each frame. + * + * @method Phaser.GameObjects.Rope#removedFromScene + * @since 3.23.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * The Rope update loop. + * + * @method Phaser.GameObjects.Rope#preUpdate + * @protected + * @since 3.23.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + var prevFrame = this.anims.currentFrame; + + this.anims.update(time, delta); + + if (this.anims.currentFrame !== prevFrame) + { + this.updateUVs(); + this.updateVertices(); + } + }, + + /** + * Start playing the given animation. + * + * @method Phaser.GameObjects.Rope#play + * @since 3.23.0 + * + * @param {string} key - The string-based key of the animation to play. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {number} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {this} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + this.anims.play(key, ignoreIfPlaying, startFrame); + + return this; + }, + + /** + * Flags this Rope as being dirty. A dirty rope will recalculate all of its vertices data + * the _next_ time it renders. You should set this rope as dirty if you update the points + * array directly. + * + * @method Phaser.GameObjects.Rope#setDirty + * @since 3.23.0 + * + * @return {this} This Game Object instance. + */ + setDirty: function () + { + this.dirty = true; + + return this; + }, + + /** + * Sets the alignment of the points in this Rope to be horizontal, in a strip format. + * + * Calling this method will reset this Rope. The current points, vertices, colors and alpha + * values will be reset to those values given as parameters. + * + * @method Phaser.GameObjects.Rope#setHorizontal + * @since 3.23.0 + * + * @param {(number|Phaser.Types.Math.Vector2Like[])} [points] - An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided the current points length is used. + * @param {(number|number[])} [colors] - Either a single color value, or an array of values. + * @param {(number|number[])} [alphas] - Either a single alpha value, or an array of values. + * + * @return {this} This Game Object instance. + */ + setHorizontal: function (points, colors, alphas) + { + if (points === undefined) { points = this.points.length; } + + if (this.horizontal) + { + return this; + } + + this.horizontal = true; + + return this.setPoints(points, colors, alphas); + }, + + /** + * Sets the alignment of the points in this Rope to be vertical, in a column format. + * + * Calling this method will reset this Rope. The current points, vertices, colors and alpha + * values will be reset to those values given as parameters. + * + * @method Phaser.GameObjects.Rope#setVertical + * @since 3.23.0 + * + * @param {(number|Phaser.Types.Math.Vector2Like[])} [points] - An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided the current points length is used. + * @param {(number|number[])} [colors] - Either a single color value, or an array of values. + * @param {(number|number[])} [alphas] - Either a single alpha value, or an array of values. + * + * @return {this} This Game Object instance. + */ + setVertical: function (points, colors, alphas) + { + if (points === undefined) { points = this.points.length; } + + if (!this.horizontal) + { + return this; + } + + this.horizontal = false; + + return this.setPoints(points, colors, alphas); + }, + + /** + * Sets the tint mode to use when applying the tint to the texture. + * + * Available modes are: + * - Phaser.TintModes.MULTIPLY (default) + * - Phaser.TintModes.FILL + * - Phaser.TintModes.ADD + * - Phaser.TintModes.SCREEN + * - Phaser.TintModes.OVERLAY + * - Phaser.TintModes.HARD_LIGHT + * + * See the `setColors` method for details of how to color each of the vertices. + * + * Rope does not currently support secondary tint colors or modes. + * + * @method Phaser.GameObjects.Rope#setTintMode + * @webglOnly + * @since 4.0.0 + * + * @param {Phaser.TintModes} [value=Phaser.TintModes.MULTIPLY] - The tint mode to use. + * + * @return {this} This Game Object instance. + */ + setTintMode: function (value) + { + if (value === undefined) { value = TintModes.MULTIPLY; } + + this.tintMode = value; + + return this; + }, + + /** + * Set the alpha values used by the Rope during rendering. + * + * You can provide the values in a number of ways: + * + * 1) One single numeric value: `setAlphas(0.5)` - This will set a single alpha for the whole Rope. + * 2) Two numeric values: `setAlphas(1, 0.5)` - This will set a 'top' and 'bottom' alpha value across the whole Rope. + * 3) An array of values: `setAlphas([ 1, 0.5, 0.2 ])` + * + * If you provide an array of values and the array has exactly the same number of values as `points` in the Rope, it + * will use each alpha value per rope segment. + * + * If the provided array has a different number of values than `points` then it will use the values in order, from + * the first Rope segment and on, until it runs out of values. This allows you to control the alpha values at all + * vertices in the Rope. + * + * Note this method is called `setAlphas` (plural) and not `setAlpha`. + * + * @method Phaser.GameObjects.Rope#setAlphas + * @since 3.23.0 + * + * @param {(number|number[])} [alphas] - Either a single alpha value, or an array of values. If nothing is provided alpha is reset to 1. + * @param {number} [bottomAlpha] - An optional bottom alpha value. See the method description for details. + * + * @return {this} This Game Object instance. + */ + setAlphas: function (alphas, bottomAlpha) + { + var total = this.points.length; + + if (total < 1) + { + return this; + } + + var currentAlphas = this.alphas; + + if (alphas === undefined) + { + alphas = [ 1 ]; + } + else if (!Array.isArray(alphas) && bottomAlpha === undefined) + { + alphas = [ alphas ]; + } + + var i; + var index = 0; + + if (bottomAlpha !== undefined) + { + // Top / Bottom alpha pair + for (i = 0; i < total; i++) + { + index = i * 2; + + currentAlphas[index] = alphas; + currentAlphas[index + 1] = bottomAlpha; + } + } + else if (alphas.length === total) + { + // If there are exactly the same number of alphas as points, we'll combine the alphas + for (i = 0; i < total; i++) + { + index = i * 2; + + currentAlphas[index] = alphas[i]; + currentAlphas[index + 1] = alphas[i]; + } + } + else + { + var prevAlpha = alphas[0]; + + for (i = 0; i < total; i++) + { + index = i * 2; + + if (alphas.length > index) + { + prevAlpha = alphas[index]; + } + + currentAlphas[index] = prevAlpha; + + if (alphas.length > index + 1) + { + prevAlpha = alphas[index + 1]; + } + + currentAlphas[index + 1] = prevAlpha; + } + } + + return this; + + }, + + /** + * Set the color values used by the Rope during rendering. + * + * Colors are used to control the level of tint applied across the Rope texture. + * + * You can provide the values in a number of ways: + * + * * One single numeric value: `setColors(0xff0000)` - This will set a single color tint for the whole Rope. + * * An array of values: `setColors([ 0xff0000, 0x00ff00, 0x0000ff ])` + * + * If you provide an array of values and the array has exactly the same number of values as `points` in the Rope, it + * will use each color per rope segment. + * + * If the provided array has a different number of values than `points` then it will use the values in order, from + * the first Rope segment and on, until it runs out of values. This allows you to control the color values at all + * vertices in the Rope. + * + * @method Phaser.GameObjects.Rope#setColors + * @since 3.23.0 + * + * @param {(number|number[])} [colors] - Either a single color value, or an array of values. If nothing is provided color is reset to 0xffffff. + * + * @return {this} This Game Object instance. + */ + setColors: function (colors) + { + var total = this.points.length; + + if (total < 1) + { + return this; + } + + var currentColors = this.colors; + + if (colors === undefined) + { + colors = [ 0xffffff ]; + } + else if (!Array.isArray(colors)) + { + colors = [ colors ]; + } + + var i; + var index = 0; + + if (colors.length === total) + { + // If there are exactly the same number of colors as points, we'll combine the colors + for (i = 0; i < total; i++) + { + index = i * 2; + + currentColors[index] = colors[i]; + currentColors[index + 1] = colors[i]; + } + } + else + { + var prevColor = colors[0]; + + for (i = 0; i < total; i++) + { + index = i * 2; + + if (colors.length > index) + { + prevColor = colors[index]; + } + + currentColors[index] = prevColor; + + if (colors.length > index + 1) + { + prevColor = colors[index + 1]; + } + + currentColors[index + 1] = prevColor; + } + } + + return this; + }, + + /** + * Sets the points used by this Rope. + * + * The points should be provided as an array of Vector2, or vector2-like objects (i.e. those with public x/y properties). + * + * Each point corresponds to one segment of the Rope. The more points in the array, the more segments the rope has. + * + * Point coordinates are given in local-space, not world-space, and are directly related to the size of the texture + * this Rope object is using. + * + * For example, a Rope using a 512 px wide texture, split into 4 segments (128px each) would use the following points: + * + * ```javascript + * rope.setPoints([ + * { x: 0, y: 0 }, + * { x: 128, y: 0 }, + * { x: 256, y: 0 }, + * { x: 384, y: 0 } + * ]); + * ``` + * + * Or, you can provide an integer to do the same thing: + * + * ```javascript + * rope.setPoints(4); + * ``` + * + * Which will divide the Rope into 4 equally sized segments based on the frame width. + * + * Note that calling this method with a different number of points than the Rope has currently will + * _reset_ the color and alpha values, unless you provide them as arguments to this method. + * + * @method Phaser.GameObjects.Rope#setPoints + * @since 3.23.0 + * + * @param {(number|Phaser.Types.Math.Vector2Like[])} [points=2] - An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided a simple quad is created. + * @param {(number|number[])} [colors] - Either a single color value, or an array of values. + * @param {(number|number[])} [alphas] - Either a single alpha value, or an array of values. + * + * @return {this} This Game Object instance. + */ + setPoints: function (points, colors, alphas) + { + if (points === undefined) { points = 2; } + + if (typeof points === 'number') + { + // Generate an array based on the points + var segments = points; + + if (segments < 2) + { + segments = 2; + } + + points = []; + + var s; + var frameSegment; + var offset; + + if (this.horizontal) + { + offset = -(this.frame.halfWidth); + frameSegment = this.frame.width / (segments - 1); + + for (s = 0; s < segments; s++) + { + points.push({ x: offset + s * frameSegment, y: 0 }); + } + } + else + { + offset = -(this.frame.halfHeight); + frameSegment = this.frame.height / (segments - 1); + + for (s = 0; s < segments; s++) + { + points.push({ x: 0, y: offset + s * frameSegment }); + } + } + } + + var total = points.length; + var currentTotal = this.points.length; + + if (total < 1) + { + console.warn('Rope: Not enough points given'); + + return this; + } + else if (total === 1) + { + points.unshift({ x: 0, y: 0 }); + total++; + } + + if (currentTotal !== total) + { + this.resizeArrays(total); + } + + this.dirty = true; + + this.points = points; + + this.updateUVs(); + + if (colors !== undefined && colors !== null) + { + this.setColors(colors); + } + + if (alphas !== undefined && alphas !== null) + { + this.setAlphas(alphas); + } + + return this; + }, + + /** + * Updates all of the UVs based on the Rope.points and `flipX` and `flipY` settings. + * + * @method Phaser.GameObjects.Rope#updateUVs + * @since 3.23.0 + * + * @return {this} This Game Object instance. + */ + updateUVs: function () + { + var currentUVs = this.uv; + var total = this.points.length; + + var u0 = this.frame.u0; + var v0 = this.frame.v0; + var u1 = this.frame.u1; + var v1 = this.frame.v1; + + var partH = (u1 - u0) / (total - 1); + var partV = (v1 - v0) / (total - 1); + + for (var i = 0; i < total; i++) + { + var index = i * 4; + + var uv0; + var uv1; + var uv2; + var uv3; + + if (this.horizontal) + { + if (this._flipX) + { + uv0 = u1 - (i * partH); + uv2 = u1 - (i * partH); + } + else + { + uv0 = u0 + (i * partH); + uv2 = u0 + (i * partH); + } + + if (this._flipY) + { + uv1 = v1; + uv3 = v0; + } + else + { + uv1 = v0; + uv3 = v1; + } + } + else + { + if (this._flipX) + { + uv0 = u0; + uv2 = u1; + } + else + { + uv0 = u1; + uv2 = u0; + } + + if (this._flipY) + { + uv1 = v1 - (i * partV); + uv3 = v1 - (i * partV); + } + else + { + uv1 = v0 + (i * partV); + uv3 = v0 + (i * partV); + } + } + + currentUVs[index + 0] = uv0; + currentUVs[index + 1] = uv1; + currentUVs[index + 2] = uv2; + currentUVs[index + 3] = uv3; + } + + return this; + }, + + /** + * Resizes all of the internal arrays: `vertices`, `uv`, `colors` and `alphas` to the new + * given Rope segment total. + * + * @method Phaser.GameObjects.Rope#resizeArrays + * @since 3.23.0 + * + * @param {number} newSize - The amount of segments to split the Rope in to. + * + * @return {this} This Game Object instance. + */ + resizeArrays: function (newSize) + { + var colors = this.colors; + var alphas = this.alphas; + + this.vertices = new Float32Array(newSize * 4); + this.uv = new Float32Array(newSize * 4); + + colors = new Uint32Array(newSize * 2); + alphas = new Float32Array(newSize * 2); + + for (var i = 0; i < newSize * 2; i++) + { + colors[i] = 0xffffff; + alphas[i] = 1; + } + + this.colors = colors; + this.alphas = alphas; + + // updateVertices during next render + this.dirty = true; + + return this; + }, + + /** + * Updates the vertices based on the Rope points. + * + * This method is called automatically during rendering if `Rope.dirty` is `true`, which is set + * by the `setPoints` and `setDirty` methods. You should flag the Rope as being dirty if you modify + * the Rope points directly. + * + * @method Phaser.GameObjects.Rope#updateVertices + * @since 3.23.0 + * + * @return {this} This Game Object instance. + */ + updateVertices: function () + { + var perp = this._perp; + var points = this.points; + var vertices = this.vertices; + + var total = points.length; + + this.dirty = false; + + if (total < 1) + { + return; + } + + var nextPoint; + var lastPoint = points[0]; + + var frameSize = (this.horizontal) ? this.frame.halfHeight : this.frame.halfWidth; + + for (var i = 0; i < total; i++) + { + var point = points[i]; + var index = i * 4; + + if (i < total - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perp.x = nextPoint.y - lastPoint.y; + perp.y = -(nextPoint.x - lastPoint.x); + + var perpLength = perp.length(); + + perp.x /= perpLength; + perp.y /= perpLength; + + perp.x *= frameSize; + perp.y *= frameSize; + + vertices[index] = point.x + perp.x; + vertices[index + 1] = point.y + perp.y; + vertices[index + 2] = point.x - perp.x; + vertices[index + 3] = point.y - perp.y; + + lastPoint = point; + } + + return this; + }, + + /** + * This method enables rendering of the Rope vertices to the given Graphics instance. + * + * If you enable this feature, you **must** call `Graphics.clear()` in your Scene `update`, + * otherwise the Graphics instance you provide to debug will fill-up with draw calls, + * eventually crashing the browser. This is not done automatically to allow you to debug + * draw multiple Rope objects to a single Graphics instance. + * + * The Rope class has a built-in debug rendering callback `Rope.renderDebugVerts`, however + * you can also provide your own callback to be used instead. Do this by setting the `callback` parameter. + * + * The callback is invoked _once per render_ and sent the following parameters: + * + * `callback(src, meshLength, verts)` + * + * `src` is the Rope instance being debugged. + * `meshLength` is the number of mesh vertices in total. + * `verts` is an array of the translated vertex coordinates. + * + * If using your own callback you do not have to provide a Graphics instance to this method. + * + * To disable debug rendering, to either your own callback or the built-in one, call this method + * with no arguments. + * + * @method Phaser.GameObjects.Rope#setDebug + * @since 3.23.0 + * + * @param {Phaser.GameObjects.Graphics} [graphic] - The Graphic instance to render to if using the built-in callback. + * @param {function} [callback] - The callback to invoke during debug render. Leave as undefined to use the built-in callback. + * + * @return {this} This Game Object instance. + */ + setDebug: function (graphic, callback) + { + this.debugGraphic = graphic; + + if (!graphic && !callback) + { + this.debugCallback = null; + } + else if (!callback) + { + this.debugCallback = this.renderDebugVerts; + } + else + { + this.debugCallback = callback; + } + + return this; + }, + + /** + * The built-in Rope vertices debug rendering method. + * + * See `Rope.setDebug` for more details. + * + * @method Phaser.GameObjects.Rope#renderDebugVerts + * @since 3.23.0 + * + * @param {Phaser.GameObjects.Rope} src - The Rope object being rendered. + * @param {number} meshLength - The number of vertices in the mesh. + * @param {number[]} verts - An array of translated vertex coordinates. + */ + renderDebugVerts: function (src, meshLength, verts) + { + var graphic = src.debugGraphic; + + var px0 = verts[0]; + var py0 = verts[1]; + var px1 = verts[2]; + var py1 = verts[3]; + + graphic.lineBetween(px0, py0, px1, py1); + + for (var i = 4; i < meshLength; i += 4) + { + var x0 = verts[i + 0]; + var y0 = verts[i + 1]; + var x1 = verts[i + 2]; + var y1 = verts[i + 3]; + + graphic.lineBetween(px0, py0, x0, y0); + graphic.lineBetween(px1, py1, x1, y1); + graphic.lineBetween(px1, py1, x0, y0); + graphic.lineBetween(x0, y0, x1, y1); + + px0 = x0; + py0 = y0; + px1 = x1; + py1 = y1; + } + }, + + /** + * Handles the pre-destroy step for the Rope, which removes the Animation component and typed arrays. + * + * @method Phaser.GameObjects.Rope#preDestroy + * @private + * @since 3.23.0 + */ + preDestroy: function () + { + this.anims.destroy(); + + this.anims = undefined; + + this.points = null; + this.vertices = null; + this.uv = null; + this.colors = null; + this.alphas = null; + + this.debugCallback = null; + this.debugGraphic = null; + }, + + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @name Phaser.GameObjects.Rope#flipX + * @type {boolean} + * @default false + * @since 3.23.0 + */ + flipX: { + + get: function () + { + return this._flipX; + }, + + set: function (value) + { + this._flipX = value; + + return this.updateUVs(); + } + + }, + + /** + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * + * @name Phaser.GameObjects.Rope#flipY + * @type {boolean} + * @default false + * @since 3.23.0 + */ + flipY: { + + get: function () + { + return this._flipY; + }, + + set: function (value) + { + this._flipY = value; + + return this.updateUVs(); + } + + } + +}); + +module.exports = Rope; + + +/***/ }, + +/***/ 95262 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * This is a stub function for Rope.Render. There is no Canvas renderer for Rope objects. + * + * @method Phaser.GameObjects.Rope#renderCanvas + * @since 3.23.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rope} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var RopeCanvasRenderer = function () +{ +}; + +module.exports = RopeCanvasRenderer; + + +/***/ }, + +/***/ 26209 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var Rope = __webpack_require__(77757); + +/** + * Creates a new Rope Game Object and returns it. + * + * A Rope is a WebGL-only Game Object that renders a strip of textured triangles along a series of points. + * This makes it ideal for creating rope, ribbon, cloth, or other flexible strip-like visual effects. + * The points define the spine of the rope, and the texture is stretched and mapped across the resulting mesh. + * Per-vertex colors and alpha values can be set to create gradient or fade effects along the length of the rope. + * + * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#rope + * @since 3.23.0 + * + * @param {Phaser.Types.GameObjects.Rope.RopeConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Rope} The Game Object that was created. + */ +GameObjectCreator.register('rope', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var horizontal = GetAdvancedValue(config, 'horizontal', true); + var points = GetValue(config, 'points', undefined); + var colors = GetValue(config, 'colors', undefined); + var alphas = GetValue(config, 'alphas', undefined); + + var rope = new Rope(this.scene, 0, 0, key, frame, points, horizontal, colors, alphas); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, rope, config); + + return rope; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 96819 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rope = __webpack_require__(77757); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Rope Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#rope + * @webglOnly + * @since 3.23.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {Phaser.Types.Math.Vector2Like[]} [points] - An array containing the vertices data for this Rope. If none is provided a simple quad is created. See `setPoints` to set this post-creation. + * @param {boolean} [horizontal=true] - Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? + * @param {number[]} [colors] - An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. + * @param {number[]} [alphas] - An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. + * + * @return {Phaser.GameObjects.Rope} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('rope', function (x, y, texture, frame, points, horizontal, colors, alphas) + { + return this.displayList.add(new Rope(this.scene, x, y, texture, frame, points, horizontal, colors, alphas)); + }); +} + + +/***/ }, + +/***/ 38745 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(20439); +} + +if (true) +{ + renderCanvas = __webpack_require__(95262); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 20439 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); + +var renderOptions = { + multiTexturing: false, + smoothPixelArt: false +}; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rope#renderWebGL + * @since 3.23.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Rope} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RopeWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + if (src.dirty) + { + src.updateVertices(); + } + + // Get smooth pixel art option. + var smoothPixelArt; + var srcTexture = src.texture; + if (srcTexture && srcTexture.smoothPixelArt !== null) + { + smoothPixelArt = srcTexture.smoothPixelArt; + } + else + { + smoothPixelArt = src.scene.sys.game.config.smoothPixelArt; + } + renderOptions.smoothPixelArt = smoothPixelArt; + + (src.customRenderNodes.BatchHandler || src.defaultRenderNodes.BatchHandler).batchStrip( + drawingContext, + src, + calcMatrix, + src.texture.source[0].glTexture, + src.vertices, + src.uv, + src.colors, + src.alphas, + src.alpha, + src.tintMode, + renderOptions, + src.debugCallback + ); +}; + +module.exports = RopeWebGLRenderer; + + +/***/ }, + +/***/ 20071 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Camera = __webpack_require__(71911); +var Vector2 = __webpack_require__(26099); +var ShaderQuad = __webpack_require__(55403); +var DrawingContext = __webpack_require__(87774); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var ShaderRender = __webpack_require__(25479); + +/** + * @classdesc + * A Shader Game Object. + * + * This Game Object allows you to easily add a quad with its own shader + * into the display list, and manipulate it as you would any other Game Object, + * including scaling, rotating, positioning and adding to Containers. + * The Shader can be made interactive and used for input events. + * It can also be used in filters to create visually stunning effects. + * + * It works by creating a custom RenderNode which runs a custom shader program + * to draw a quad. The shader program can be loaded from the Shader Cache, + * or provided in-line as strings. + * + * Please see the Phaser Examples GitHub repo for several examples + * of loading and creating shaders dynamically. + * + * Due to the way in which they work, you cannot directly change the alpha + * of a Shader. It should be handled via uniforms in the shader code itself. + * + * By default, a Shader has a uniform called `uProjectionMatrix` + * which is set automatically. + * You can control additional uniforms using the `setupUniforms` method + * in the Shader configuration object, which runs every time the shader renders. + * + * Shaders are stand-alone renders: they finish any current render batch + * and run once by themselves. As this costs a draw call, you should use them sparingly. + * If you need to have a fully batched custom shader, then please look at using + * a custom RenderNode instead. However, for background or special masking effects, + * they are extremely effective. + * + * Note: be careful when using texture coordinates in shader code. + * The built-in variable `gl_FragCoord` and the default uniform `outTexCoord` + * both use WebGL coordinates, which are `0,0` in the bottom-left. + * Additionally, `gl_FragCoord` says it's in "window relative" coordinates. + * But this is actually relative to the framebuffer size. + * + * @example + * // Loading a shader from the cache (good for simple shaders) + * function preload () + * { + * this.load.glsl('fire', 'shaders/fire.glsl.js'); + * } + * + * function create () + * { + * this.add.shader('fire', 400, 300, 512, 512); + * } + * + * @example + * // Using a configuration object (good for more control) + * function create () + * { + * this.add.shader({ + * fragmentKey: 'fire', // This will be overridden by fragmentSource + * fragmentSource: '// your fragment shader source', + * setupUniforms: (setUniform, drawingContext) => { + * setUniform('time', this.game.loop.getDuration()); + * } + * }, 400, 300, 512, 512); + * } + * + * @class Shader + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.17.0 + * + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {string|Phaser.Types.GameObjects.Shader.ShaderQuadConfig} config - The configuration object this Shader will use. It can also be a key that corresponds to a shader in the shader cache, which will be used as `fragmentKey` in a new config object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * @param {string[]|Phaser.Textures.Texture[]} [textures] - The textures that the shader uses, if any. If you intend to define the textures later, use `'__DEFAULT'` as a placeholder, to avoid initialization errors. + */ +var Shader = new Class({ + Extends: GameObject, + + Mixins: [ + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.GetBounds, + Components.Origin, + Components.ScrollFactor, + Components.Transform, + Components.Visible, + ShaderRender + ], + + initialize: function Shader (scene, config, x, y, width, height, textures) + { + if (config === undefined) { config = {}; } + if (typeof config === 'string') + { + config = { fragmentKey: config }; + } + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + GameObject.call(this, scene, 'Shader'); + + var renderer = scene.sys.renderer; + + /** + * The textures that the shader uses. + * These will be assigned to texture units 0 to N when the shader is + * rendered, where N is `textures.length - 1`. + * + * @name Phaser.GameObjects.Shader#textures + * @type {Phaser.Textures.Texture[]} + * @since 4.0.0 + */ + this.textures = []; + + /** + * The underlying RenderNode object that the shader uses to render with. + * + * @name Phaser.GameObjects.Shader#renderNode + * @type {Phaser.Renderer.WebGL.RenderNodes.ShaderQuad} + * @since 4.0.0 + */ + this.renderNode = new ShaderQuad(renderer.renderNodes, config); + + this.setupUniforms = GetFastValue(config, 'setupUniforms', function () {}); + + if (config.updateShaderConfig) + { + this.renderNode.updateShaderConfig = config.updateShaderConfig; + } + + var initialUniforms = GetFastValue(config, 'initialUniforms', {}); + Object.entries(initialUniforms).forEach(function (entry) + { + this.setUniform(entry[0], entry[1]); + }, this); + + /** + * The drawing context containing the framebuffer and texture that the shader is rendered to. + * This is only set if the shader is rendering to a texture. + * + * @name Phaser.GameObjects.Shader#drawingContext + * @type {?Phaser.Renderer.WebGL.DrawingContext} + * @since 4.0.0 + */ + this.drawingContext = null; + + /** + * A reference to the WebGLTextureWrapper this Shader is rendering to. + * This property is only set if you have called `Shader.setRenderToTexture`. + * + * @name Phaser.GameObjects.Shader#glTexture + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 3.19.0 + */ + this.glTexture = null; + + /** + * A flag that indicates if this Shader has been set to render to a texture instead of the display list. + * + * This property is `true` if you have called `Shader.setRenderToTexture`, otherwise it's `false`. + * + * A Shader that is rendering to a texture _does not_ appear on the display list. + * + * @name Phaser.GameObjects.Shader#renderToTexture + * @type {boolean} + * @readonly + * @since 3.19.0 + */ + this.renderToTexture = false; + + /** + * A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader. + * + * This property is only set if you have called `Shader.setRenderToTexture` with a key, otherwise it is `null`. + * + * @name Phaser.GameObjects.Shader#texture + * @type {Phaser.Textures.Texture} + * @since 3.19.0 + */ + this.texture = null; + + /** + * The top-left texture coordinate of the shader. + * This is set to 0,1 by default. It uses WebGL texture coordinates. + * + * @name Phaser.GameObjects.Shader#textureCoordinateTopLeft + * @type {Phaser.Math.Vector2} + * @since 4.0.0 + */ + this.textureCoordinateTopLeft = new Vector2(0, 1); + + /** + * The top-right texture coordinate of the shader. + * This is set to 1,1 by default. It uses WebGL texture coordinates. + * + * @name Phaser.GameObjects.Shader#textureCoordinateTopRight + * @type {Phaser.Math.Vector2} + * @since 4.0.0 + */ + this.textureCoordinateTopRight = new Vector2(1, 1); + + /** + * The bottom-left texture coordinate of the shader. + * This is set to 0,0 by default. It uses WebGL texture coordinates. + * + * @name Phaser.GameObjects.Shader#textureCoordinateBottomLeft + * @type {Phaser.Math.Vector2} + * @since 4.0.0 + */ + this.textureCoordinateBottomLeft = new Vector2(0, 0); + + /** + * The bottom-right texture coordinate of the shader. + * This is set to 1,0 by default. It uses WebGL texture coordinates. + * + * @name Phaser.GameObjects.Shader#textureCoordinateBottomRight + * @type {Phaser.Math.Vector2} + * @since 4.0.0 + */ + this.textureCoordinateBottomRight = new Vector2(1, 0); + + this.setTextures(textures); + this.setPosition(x, y); + this.setSize(width, height); + this.setOrigin(0.5, 0.5); + }, + + /** + * Returns the current value of a uniform from the render node. + * This value is actually copied to all shaders that use it. + * Modifications to non-primitive values such as arrays and objects + * will modify the original. + * + * It's generally better to use the `setupUniforms` function in the + * shader configuration object to set uniform values on changing uniforms. + * This method is provided in the spirit of reading back the values. + * + * @method Phaser.GameObjects.Shader#getUniform + * @since 4.0.0 + * @param {string} name - The name of the uniform to get. + * @return {any} The value of the uniform. + */ + getUniform: function (name) + { + return this.renderNode.programManager.uniforms[name]; + }, + + /** + * Set the value of a uniform in the shader. + * This value is actually copied to all shaders that use it. + * + * It's generally better to use the `setupUniforms` function in the + * shader configuration object to set uniform values on changing uniforms. + * Use this method to set uniforms just once. + * + * @method Phaser.GameObjects.Shader#setUniform + * @since 4.0.0 + * @param {string} name - The name of the uniform to set. + * @param {any} value - The value to set the uniform to. + * @return {this} + */ + setUniform: function (name, value) + { + this.renderNode.programManager.setUniform(name, value); + return this; + }, + + /** + * Set the textures that the shader uses. + * + * Some shaders don't use any textures. Some may use one or more. + * The textures are assigned to texture units 0 to N when the shader is rendered, + * where N is `textures.length - 1`. + * You must set the uniforms in your shader to match these texture units. + * + * Calling this method will replace the existing textures array with the new one. + * + * @example + * // In the shader source, use the `sampler2D` type. + * sampler2D uMainSampler; + * sampler2D uNormalSampler; + * + * // When creating the shader, set the textures. + * var shader = this.add.shader({ + * fragmentKey: 'myShader', + * setupUniforms: (setUniform) => { + * // In the `setupUniforms` function, set the texture to its array position. + * setUniform('uMainSampler', 0); + * setUniform('uNormalSampler', 1); + * } + * }, x, y, width, height, ['metal', 'normal']); + * + * @method Phaser.GameObjects.Shader#setTextures + * @since 4.0.0 + * @param {string[]|Phaser.Textures.Texture[]} [textures] - The textures that the shader uses. + */ + setTextures: function (textures) + { + if (textures === undefined) { textures = []; } + + this.textures.length = 0; + + for (var i = 0; i < textures.length; i++) + { + var texture = textures[i]; + if (typeof texture === 'string') + { + texture = this.scene.textures.get(texture); + } + this.textures.push(texture); + } + + return this; + }, + + /** + * Changes this Shader so instead of rendering to the display list + * it renders to a WebGL Framebuffer and Texture instead. + * This allows you to use the output of this shader as a texture. + * + * After calling this method the following properties are populated: + * - `Shader.drawingContext` + * - `Shader.glTexture` + * + * Additionally, you can provide a key to this method. + * Doing so will create a Phaser Texture from this Shader, + * store it in `Shader.texture`, + * and save it into the Texture Manager, allowing you to then use it for + * any texture-based Game Object, such as a Sprite or Image: + * + * ```javascript + * var shader = this.add.shader('myShader', x, y, width, height); + * + * shader.setRenderToTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Note that it stores an active reference to this Shader. That means as this shader updates, + * so does the texture and any object using it to render with. Also, if you destroy this + * shader, be sure to clear any objects that may have been using it as a texture too. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * + * If you want to update a texture only sporadically, don't use this method. + * Instead, use a DynamicTexture: + * + * ```javascript + * var shader = this.add.shader('myShader', x, y, width, height); + * + * var dynamic = this.textures.addDynamicTexture('myTexture', shader.width, shader.height); + * + * // To update the texture: + * dynamic.clear().draw(shader).render(); + * ``` + * + * @method Phaser.GameObjects.Shader#setRenderToTexture + * @since 3.19.0 + * + * @param {string} [key] - The unique key to store the texture as within the global Texture Manager. + * + * @return {this} This Shader instance. + */ + setRenderToTexture: function (key) + { + if (this.renderToTexture) + { + return this; + } + + var width = this.width; + var height = this.height; + var renderer = this.scene.sys.renderer; + var scene = this.scene; + + var camera = new Camera(0, 0, width, height).setScene(scene.game.scene.systemScene, false); + + this.drawingContext = new DrawingContext(renderer, { + width: width, + height: height, + camera: camera + }); + + this.glTexture = this.drawingContext.texture; + + if (key) + { + this.texture = scene.sys.textures.addGLTexture(key, this.glTexture); + } + + this.renderToTexture = true; + + // Render at least once, so our texture isn't blank on the first update + this.renderWebGLStep(renderer, this, this.drawingContext); + + return this; + }, + + /** + * Render the shader immediately. + * This is useful for a Shader that is not part of the display list, + * but you want to use with `renderToTexture`. + * + * @method Phaser.GameObjects.Shader#renderImmediate + * @since 4.0.0 + * @return {this} This Shader instance. + */ + renderImmediate: function () + { + this.renderWebGLStep(this.scene.renderer, this, this.drawingContext); + + return this; + }, + + /** + * The function which sets uniforms for the shader. + * This is called automatically during rendering. + * It is set from the `config` object passed in the constructor. + * You should use this function to set any uniform values you need for your shader to run. + * + * You can set this function directly after object creation, + * but it's recommended to use the `config` object + * to keep your logic encapsulated. + * + * The function is invoked with two arguments: `setUniform` and `drawingContext`. + * `setUniform` is a function that takes two arguments: a string (the name of the uniform) and a value. + * Ensure that the value matches the expected type in the shader. + * You don't need to be too precise, as the system will convert + * e.g. Array and Float32Array types as needed. + * To set an array in a shader, append `[0]` to the uniform name. + * `drawingContext` is a reference to the current drawing context, + * which may be useful if you need to query the camera or similar. + * + * Note that `uProjectionMatrix` is set for you automatically. + * + * @method Phaser.GameObjects.Shader#setupUniforms + * @since 4.0.0 + * @param {function} setUniform - The function which sets uniforms. `(name: string, value: any) => void`. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - A reference to the current drawing context. + */ + setupUniforms: function (setUniform, drawingContext) + { + // NOOP + }, + + /** + * A NOOP method so you can pass a Shader to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Shader#setAlpha + * @private + * @since 3.17.0 + * @return {this} This Shader instance. + */ + setAlpha: function () + { + return this; + }, + + /** + * Set the texture coordinates of the shader. + * These values are used to provide texture mapping to the shader, + * and are commonly used to drive generative output. + * + * By default, the shader uses the whole texture, the range 0-1. + * The coordinates are in WebGL texture space, which is 0,0 in the bottom-left. + * This method allows you to specify a region of the texture to use, + * or even go outside the 0-1 bounds. + * This can be useful if you want to use a single frame from a texture, + * repeat the shader's texture, use a larger numeric range, + * or distort the shader. + * + * Note that a quad is made of two triangles, divided by the diagonal + * from the top-left to the bottom-right. This means that some permutations + * of coordinates may affect just one or the other triangle. + * This can cause abrupt warping along the diagonal. + * Keep an eye on your output. Rectangles and parallelograms are safe bets. + * So are rotation and scaling transforms. Moving a single point is risky. + * + * Call this method with no arguments to reset the shader to use the whole texture. + * + * @method Phaser.GameObjects.Shader#setTextureCoordinates + * @since 4.0.0 + * @param {number} [topLeftX=0] - The top-left x coordinate of the texture. + * @param {number} [topLeftY=1] - The top-left y coordinate of the texture. + * @param {number} [topRightX=1] - The top-right x coordinate of the texture. + * @param {number} [topRightY=1] - The top-right y coordinate of the texture. + * @param {number} [bottomLeftX=0] - The bottom-left x coordinate of the texture. + * @param {number} [bottomLeftY=0] - The bottom-left y coordinate of the texture. + * @param {number} [bottomRightX=1] - The bottom-right x coordinate of the texture. + * @param {number} [bottomRightY=0] - The bottom-right y coordinate of the texture. + * @return {this} This Shader instance + */ + setTextureCoordinates: function ( + topLeftX, topLeftY, + topRightX, topRightY, + bottomLeftX, bottomLeftY, + bottomRightX, bottomRightY + ) + { + if (topLeftX === undefined) { topLeftX = 0; } + if (topLeftY === undefined) { topLeftY = 1; } + if (topRightX === undefined) { topRightX = 1; } + if (topRightY === undefined) { topRightY = 1; } + if (bottomLeftX === undefined) { bottomLeftX = 0; } + if (bottomLeftY === undefined) { bottomLeftY = 0; } + if (bottomRightX === undefined) { bottomRightX = 1; } + if (bottomRightY === undefined) { bottomRightY = 0; } + + this.textureCoordinateTopLeft.set(topLeftX, topLeftY); + this.textureCoordinateTopRight.set(topRightX, topRightY); + this.textureCoordinateBottomLeft.set(bottomLeftX, bottomLeftY); + this.textureCoordinateBottomRight.set(bottomRightX, bottomRightY); + + return this; + }, + + /** + * Set the texture coordinates of the shader from a frame. + * This is a convenience method that sets the texture coordinates + * to match a frame from a texture. + * + * @method Phaser.GameObjects.Shader#setTextureCoordinatesFromFrame + * @since 4.0.0 + * @param {Phaser.Textures.Frame|string} frame - The frame to set the texture coordinates from. If a string is given, it will be used to look up the frame in the texture. + * @param {Phaser.Textures.Texture|string} [texture] - The texture that the frame is from. This is only used if `frame` is a string. If a string is given, it will be used to look up the texture in the Texture Manager. If not given, the first member of `Shader.textures` is used. If `Shader.textures` is empty, an error will occur. + */ + setTextureCoordinatesFromFrame: function (frame, texture) + { + if (typeof frame === 'string') + { + if (!texture) + { + texture = this.textures[0]; + } + else if (typeof texture === 'string') + { + texture = this.scene.textures.get(texture); + } + frame = texture.get(frame); + } + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.setTextureCoordinates(u0, v0, u1, v0, u0, v1, u1, v1); + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Shader#preDestroy + * @protected + * @since 3.17.0 + */ + preDestroy: function () + { + this.renderNode = null; + + this.textures.length = 0; + + if (this.drawingContext) + { + this.drawingContext.destroy(); + if (this.texture) + { + this.texture.destroy(); + } + + this.drawingContext = null; + this.glTexture = null; + this.texture = null; + } + } +}); + +module.exports = Shader; + + +/***/ }, + +/***/ 80464 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * This is a stub function for Shader.Render. There is no Canvas renderer for Shader objects. + * + * @method Phaser.GameObjects.Shader#renderCanvas + * @since 3.17.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Shader} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var ShaderCanvasRenderer = function () +{ +}; + +module.exports = ShaderCanvasRenderer; + + +/***/ }, + +/***/ 54935 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Shader = __webpack_require__(20071); + +/** + * Creates a new Shader Game Object and returns it. + * + * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#shader + * @since 3.17.0 + * + * @param {Phaser.Types.GameObjects.Shader.ShaderConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Shader} The Game Object that was created. + */ +GameObjectCreator.register('shader', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var quadConfig = GetAdvancedValue(config, 'config', null); + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 128); + var height = GetAdvancedValue(config, 'height', 128); + + var shader = new Shader(this.scene, quadConfig, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, shader, config); + + return shader; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 74177 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Shader = __webpack_require__(20071); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Shader Game Object and adds it to the Scene. + * + * A Shader Game Object renders a custom GLSL fragment shader as a rectangular Game Object, allowing you to + * display procedural visual effects, generative graphics, or post-processing-style visuals directly within + * your game world. The shader runs on the GPU and can receive custom uniforms as well as up to four texture + * channel inputs (iChannel0 to iChannel3), making it compatible with shaders written in the Shadertoy style. + * + * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#shader + * @webglOnly + * @since 3.17.0 + * + * @param {(string|Phaser.Types.GameObjects.Shader.ShaderQuadConfig)} config - The configuration object this Shader will use. It can also be a key that corresponds to a shader in the shader cache, which will be used as `fragmentKey` in a new config object. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the Game Object. + * @param {number} [height=128] - The height of the Game Object. + * @param {string[]} [textures] - Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. + * + * @return {Phaser.GameObjects.Shader} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('shader', function (config, x, y, width, height, textures) + { + return this.displayList.add(new Shader(this.scene, config, x, y, width, height, textures)); + }); +} + + +/***/ }, + +/***/ 25479 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(19257); +} + +if (true) +{ + renderCanvas = __webpack_require__(80464); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 19257 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Shader#renderWebGL + * @since 3.17.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Shader} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ShaderWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + + camera.addToRenderList(src); + + if (src.renderToTexture) + { + drawingContext = src.drawingContext; + + if (drawingContext.width !== src.width || drawingContext.height !== src.height) + { + var width = src.width; + var height = src.height; + drawingContext.resize(width, height); + drawingContext.camera.setSize(width, height); + } + + drawingContext.use(); + } + + src.renderNode.run(drawingContext, src, parentMatrix); + + if (src.renderToTexture) + { + drawingContext.release(); + } +}; + +module.exports = ShaderWebGLRenderer; + + +/***/ }, + +/***/ 10441 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Utils = __webpack_require__(70554); + +/** + * Renders a filled path for the given Shape. + * + * @method Phaser.GameObjects.Shape#FillPathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerTriFlat} submitter - The Submitter node to use. + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix used to get the position values. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var FillPathWebGL = function (drawingContext, submitter, calcMatrix, src, alpha, dx, dy) +{ + // This is very similar to the FillPath RenderNode, but it already + // has access to the Earcut indexes, so it doesn't need to calculate them. + + var fillTintColor = Utils.getTintAppendFloatAlpha(src.fillColor, src.fillAlpha * alpha); + + var path = src.pathData; + var pathIndexes = src.pathIndexes; + + var length = path.length; + var pathIndex, pointX, pointY, x, y; + + var vertices = Array(length * 2); + var colors = Array(length); + + var verticesIndex = 0; + var colorsIndex = 0; + + for (pathIndex = 0; pathIndex < length; pathIndex += 2) + { + pointX = path[pathIndex] - dx; + pointY = path[pathIndex + 1] - dy; + + // Transform the point. + x = calcMatrix.getX(pointX, pointY); + y = calcMatrix.getY(pointX, pointY); + + vertices[verticesIndex++] = x; + vertices[verticesIndex++] = y; + colors[colorsIndex++] = fillTintColor; + } + + submitter.batch( + drawingContext, + pathIndexes, + vertices, + colors, + src.lighting + ); +}; + +module.exports = FillPathWebGL; + + +/***/ }, + +/***/ 65960 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Sets the fillStyle on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#FillStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the fill style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the fill style from. + * @param {number} [altColor] - An alternative color to render with. + * @param {number} [altAlpha] - An alternative alpha to render with. + */ +var FillStyleCanvas = function (ctx, src, altColor, altAlpha) +{ + var fillColor = (altColor) ? altColor : src.fillColor; + var fillAlpha = (altAlpha) ? altAlpha : src.fillAlpha; + + var red = ((fillColor & 0xFF0000) >>> 16); + var green = ((fillColor & 0xFF00) >>> 8); + var blue = (fillColor & 0xFF); + + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; +}; + +module.exports = FillStyleCanvas; + + +/***/ }, + +/***/ 75177 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Sets the strokeStyle and lineWidth on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#LineStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the stroke style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the stroke style from. + * @param {number} [altColor] - An alternative color to render with. + * @param {number} [altAlpha] - An alternative alpha to render with. + */ +var LineStyleCanvas = function (ctx, src, altColor, altAlpha) +{ + var strokeColor = (altColor) ? altColor : src.strokeColor; + var strokeAlpha = (altAlpha) ? altAlpha : src.strokeAlpha; + + var red = ((strokeColor & 0xFF0000) >>> 16); + var green = ((strokeColor & 0xFF00) >>> 8); + var blue = (strokeColor & 0xFF); + + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + strokeAlpha + ')'; + ctx.lineWidth = src.lineWidth; +}; + +module.exports = LineStyleCanvas; + + +/***/ }, + +/***/ 17803 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DefaultGraphicsNodes = __webpack_require__(87891); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var Line = __webpack_require__(23031); + +/** + * @classdesc + * The Shape Game Object is a base class for the various built-in shape types, such as the Arc, Star, Polygon, + * Rectangle, and Triangle. It provides a common interface for managing fill color, stroke color, line width, + * and the precomputed path data used when rendering. + * + * You cannot add a Shape directly to your Scene. Instead, use one of the built-in subclasses, or extend this + * class to create your own custom Shape types with their own geometry logic. + * + * Shape objects share the same render batch as the Graphics Game Object when rendering in WebGL. + * They do not support gradients, path smoothing thresholds, or other advanced Graphics features. + * In return, they store precomputed internal geometry data which allows them to render more efficiently + * than dynamically-constructed Graphics objects. + * + * @class Shape + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @extends Phaser.GameObjects.Components.AlphaSingle + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {string} [type] - The internal type of the Shape. + * @param {any} [data] - The data of the source shape geometry, if any. + */ +var Shape = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.AlphaSingle, + Components.BlendMode, + Components.Depth, + Components.GetBounds, + Components.Lighting, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.Transform, + Components.Visible + ], + + initialize: + + function Shape (scene, type, data) + { + if (type === undefined) { type = 'Shape'; } + + GameObject.call(this, scene, type); + + /** + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. + * + * @name Phaser.GameObjects.Shape#geom + * @type {any} + * @readonly + * @since 3.13.0 + */ + this.geom = data; + + /** + * Holds the polygon path data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathData + * @type {number[]} + * @readonly + * @since 3.13.0 + */ + this.pathData = []; + + /** + * Holds the earcut polygon path index data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathIndexes + * @type {number[]} + * @readonly + * @since 3.13.0 + */ + this.pathIndexes = []; + + /** + * The fill color used by this Shape, as a hex value (e.g., 0xff0000 for red). + * Only used when `isFilled` is `true`. Set via `setFillStyle`. + * + * @name Phaser.GameObjects.Shape#fillColor + * @type {number} + * @since 3.13.0 + */ + this.fillColor = 0xffffff; + + /** + * The alpha applied to the fill of this Shape, in the range 0 (fully transparent) to 1 (fully opaque). + * Only used when `isFilled` is `true`. Set via `setFillStyle`. + * + * @name Phaser.GameObjects.Shape#fillAlpha + * @type {number} + * @since 3.13.0 + */ + this.fillAlpha = 1; + + /** + * The stroke color used by this Shape, as a hex value (e.g., 0x00ff00 for green). + * Only used when `isStroked` is `true`. Set via `setStrokeStyle`. + * + * @name Phaser.GameObjects.Shape#strokeColor + * @type {number} + * @since 3.13.0 + */ + this.strokeColor = 0xffffff; + + /** + * The alpha applied to the stroke of this Shape, in the range 0 (fully transparent) to 1 (fully opaque). + * Only used when `isStroked` is `true`. Set via `setStrokeStyle`. + * + * @name Phaser.GameObjects.Shape#strokeAlpha + * @type {number} + * @since 3.13.0 + */ + this.strokeAlpha = 1; + + /** + * The width of the stroke line for this Shape, in pixels. + * Only used when `isStroked` is `true`. Set via `setStrokeStyle`. + * + * @name Phaser.GameObjects.Shape#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + * + * @name Phaser.GameObjects.Shape#isFilled + * @type {boolean} + * @since 3.13.0 + */ + this.isFilled = false; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + * + * @name Phaser.GameObjects.Shape#isStroked + * @type {boolean} + * @since 3.13.0 + */ + this.isStroked = false; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * @name Phaser.GameObjects.Shape#closePath + * @type {boolean} + * @since 3.13.0 + */ + this.closePath = true; + + /** + * Private internal value. + * A Line used when parsing internal path data to avoid constant object re-creation. + * + * @name Phaser.GameObjects.Shape#_tempLine + * @type {Phaser.Geom.Line} + * @private + * @since 3.13.0 + */ + this._tempLine = new Line(); + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Shape#width + * @type {number} + * @since 3.13.0 + */ + this.width = 0; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Shape#height + * @type {number} + * @since 3.0.0 + */ + this.height = 0; + + if (this.enableFilters) + { + // Prevent Shape stroke from being cut off in filters. + this.filtersFocusContext = true; + } + + this.initRenderNodes(this._defaultRenderNodesMap); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Shape#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultGraphicsNodes; + } + }, + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setFillStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to fill this shape. If not provided the Shape will not be filled. + * @param {number} [alpha=1] - The alpha value used when filling this shape, if a fill color is given. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (color === undefined) + { + this.isFilled = false; + } + else + { + this.fillColor = color; + this.fillAlpha = alpha; + this.isFilled = true; + } + + return this; + }, + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setStrokeStyle + * @since 3.13.0 + * + * @param {number} [lineWidth] - The width of line to stroke with. If not provided or undefined the Shape will not be stroked. + * @param {number} [color] - The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param {number} [alpha=1] - The alpha value used when stroking this shape, if a stroke color is given. + * + * @return {this} This Game Object instance. + */ + setStrokeStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (lineWidth === undefined) + { + this.isStroked = false; + } + else + { + this.lineWidth = lineWidth; + this.strokeColor = color; + this.strokeAlpha = alpha; + this.isStroked = true; + } + + return this; + }, + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setClosePath + * @since 3.13.0 + * + * @param {boolean} value - Set to `true` if the Shape should be closed when stroked, otherwise `false`. + * + * @return {this} This Game Object instance. + */ + setClosePath: function (value) + { + this.closePath = value; + + return this; + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Shape#setSize + * @private + * @since 3.13.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the displayed pixel size of this Shape by adjusting its `scaleX` and `scaleY` properties + * relative to its native width and height. This is equivalent to calling `setScale` but lets you + * specify the desired rendered dimensions in pixels rather than as a scale multiplier. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setDisplaySize + * @since 3.53.0 + * + * @param {number} width - The display width of this Shape, in pixels. + * @param {number} height - The display height of this Shape, in pixels. + * + * @return {this} This Shape instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Shape#preDestroy + * @protected + * @since 3.13.0 + */ + preDestroy: function () + { + this.geom = null; + this._tempLine = null; + this.pathData = []; + this.pathIndexes = []; + }, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Shape#displayWidth + * @type {number} + * @since 3.13.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Shape#displayHeight + * @type {number} + * @since 3.13.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + } + +}); + +module.exports = Shape; + + +/***/ }, + +/***/ 34682 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Utils = __webpack_require__(70554); + +/** + * Renders a stroke outline around the given Shape. + * + * @method Phaser.GameObjects.Shape#StrokePathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerTriFlat} submitter - The Submitter node to use. + * @param {Phaser.GameObjects.Components.TransformMatrix} matrix - The current transform matrix. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var StrokePathWebGL = function (drawingContext, submitter, matrix, src, alpha, dx, dy) +{ + var strokeTintColor = Utils.getTintAppendFloatAlpha(src.strokeColor, src.strokeAlpha * alpha); + + var path = src.pathData; + var pathLength = path.length - 1; + var lineWidth = src.lineWidth; + var openPath = !src.closePath; + + var strokePath = src.customRenderNodes.StrokePath || src.defaultRenderNodes.StrokePath; + + var pointPath = []; + + // Don't add the last point to open paths. + if (openPath) + { + pathLength -= 2; + } + + for (var i = 0; i < pathLength; i += 2) + { + var x = path[i] - dx; + var y = path[i + 1] - dy; + if (i > 0) + { + if (x === path[i - 2] && y === path[i - 1]) + { + // Duplicate point, skip it + continue; + } + } + pointPath.push({ + x: x, + y: y, + width: lineWidth + }); + } + + strokePath.run( + drawingContext, + submitter, + pointPath, + lineWidth, + openPath, + matrix, + strokeTintColor, strokeTintColor, strokeTintColor, strokeTintColor, + undefined, + src.lighting + ); +}; + +module.exports = StrokePathWebGL; + + +/***/ }, + +/***/ 23629 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ArcRender = __webpack_require__(13609); +var Class = __webpack_require__(83419); +var DegToRad = __webpack_require__(39506); +var Earcut = __webpack_require__(94811); +var GeomCircle = __webpack_require__(96503); +var MATH_CONST = __webpack_require__(36383); +var Shape = __webpack_require__(17803); + +/** + * @classdesc + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. + * + * @class Arc + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [radius=128] - The radius of the arc. + * @param {number} [startAngle=0] - The start angle of the arc, in degrees. + * @param {number} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Arc = new Class({ + + Extends: Shape, + + Mixins: [ + ArcRender + ], + + initialize: + + function Arc (scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 128; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (anticlockwise === undefined) { anticlockwise = false; } + + Shape.call(this, scene, 'Arc', new GeomCircle(0, 0, radius)); + + /** + * Private internal value. Holds the start angle in degrees. + * + * @name Phaser.GameObjects.Arc#_startAngle + * @type {number} + * @private + * @since 3.13.0 + */ + this._startAngle = startAngle; + + /** + * Private internal value. Holds the end angle in degrees. + * + * @name Phaser.GameObjects.Arc#_endAngle + * @type {number} + * @private + * @since 3.13.0 + */ + this._endAngle = endAngle; + + /** + * Private internal value. Holds the winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#_anticlockwise + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._anticlockwise = anticlockwise; + + /** + * Private internal value. Holds the number of iterations used when drawing the arc. + * + * @name Phaser.GameObjects.Arc#_iterations + * @type {number} + * @default 0.01 + * @private + * @since 3.13.0 + */ + this._iterations = 0.01; + + this.setPosition(x, y); + + var diameter = this.geom.radius * 2; + this.setSize(diameter, diameter); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * + * @name Phaser.GameObjects.Arc#iterations + * @type {number} + * @default 0.01 + * @since 3.13.0 + */ + iterations: { + + get: function () + { + return this._iterations; + }, + + set: function (value) + { + this._iterations = value; + + this.updateData(); + } + + }, + + /** + * The radius of the arc, in pixels. Changing this value also updates the size of the + * Game Object and triggers a recalculation of its geometry data. + * + * @name Phaser.GameObjects.Arc#radius + * @type {number} + * @since 3.13.0 + */ + radius: { + + get: function () + { + return this.geom.radius; + }, + + set: function (value) + { + this.geom.radius = value; + + var diameter = value * 2; + this.setSize(diameter, diameter); + this.updateDisplayOrigin(); + this.updateData(); + } + + }, + + /** + * The start angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#startAngle + * @type {number} + * @since 3.13.0 + */ + startAngle: { + + get: function () + { + return this._startAngle; + }, + + set: function (value) + { + this._startAngle = value; + + this.updateData(); + } + + }, + + /** + * The end angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#endAngle + * @type {number} + * @since 3.13.0 + */ + endAngle: { + + get: function () + { + return this._endAngle; + }, + + set: function (value) + { + this._endAngle = value; + + this.updateData(); + } + + }, + + /** + * The winding order of the start and end angles. If `true` the arc is drawn anti-clockwise + * (counter-clockwise), otherwise it is drawn clockwise. This affects which direction the + * arc sweeps between the start and end angles. + * + * @name Phaser.GameObjects.Arc#anticlockwise + * @type {boolean} + * @since 3.13.0 + */ + anticlockwise: { + + get: function () + { + return this._anticlockwise; + }, + + set: function (value) + { + this._anticlockwise = value; + + this.updateData(); + } + + }, + + /** + * Sets the radius of the arc. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setRadius + * @since 3.13.0 + * + * @param {number} value - The value to set the radius to. + * + * @return {this} This Game Object instance. + */ + setRadius: function (value) + { + this.radius = value; + + return this; + }, + + /** + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setIterations + * @since 3.13.0 + * + * @param {number} value - The value to set the iterations to. + * + * @return {this} This Game Object instance. + */ + setIterations: function (value) + { + if (value === undefined) { value = 0.01; } + + this.iterations = value; + + return this; + }, + + /** + * Sets the starting angle of the arc, in degrees. Optionally also updates the winding order. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setStartAngle + * @since 3.13.0 + * + * @param {number} value - The value to set the starting angle to. + * @param {boolean} [anticlockwise] - If `true` the arc will be drawn anti-clockwise. If `false` it will be drawn clockwise. If not given, the current `anticlockwise` property value is used. + * + * @return {this} This Game Object instance. + */ + setStartAngle: function (angle, anticlockwise) + { + this._startAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Sets the ending angle of the arc, in degrees. Optionally also updates the winding order. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setEndAngle + * @since 3.13.0 + * + * @param {number} value - The value to set the ending angle to. + * @param {boolean} [anticlockwise] - If `true` the arc will be drawn anti-clockwise. If `false` it will be drawn clockwise. If not given, the current `anticlockwise` property value is used. + * + * @return {this} This Game Object instance. + */ + setEndAngle: function (angle, anticlockwise) + { + this._endAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Arc#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var step = this._iterations; + var iteration = step; + + var radius = this.geom.radius; + var startAngle = DegToRad(this._startAngle); + var endAngle = DegToRad(this._endAngle); + var anticlockwise = this._anticlockwise; + + var x = radius; + var y = radius; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -MATH_CONST.TAU) + { + endAngle = -MATH_CONST.TAU; + } + else if (endAngle > 0) + { + endAngle = -MATH_CONST.TAU + endAngle % MATH_CONST.TAU; + } + } + else if (endAngle > MATH_CONST.TAU) + { + endAngle = MATH_CONST.TAU; + } + else if (endAngle < 0) + { + endAngle = MATH_CONST.TAU + endAngle % MATH_CONST.TAU; + } + + var path = [ x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius ]; + + var ta; + + while (iteration < 1) + { + ta = endAngle * iteration + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + iteration += step; + } + + ta = endAngle + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + path.push(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Arc; + + +/***/ }, + +/***/ 42542 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DegToRad = __webpack_require__(39506); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var radius = src.radius; + + ctx.beginPath(); + + ctx.arc( + (radius) - src.originX * (radius * 2), + (radius) - src.originY * (radius * 2), + radius, + DegToRad(src._startAngle), + DegToRad(src._endAngle), + src.anticlockwise + ); + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = ArcCanvasRenderer; + + +/***/ }, + +/***/ 42563 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Arc = __webpack_require__(23629); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Arc Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * @method Phaser.GameObjects.GameObjectFactory#arc + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [radius=128] - The radius of the arc. + * @param {number} [startAngle=0] - The start angle of the arc, in degrees. + * @param {number} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - Whether the arc is drawn anticlockwise between the start and end angles. When `false` the arc is drawn clockwise. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('arc', function (x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha)); +}); + +/** + * Creates a new Circle Shape Game Object and adds it to the Scene. + * + * A Circle is an Arc with a fixed start angle of 0 and end angle of 360 degrees, so it always renders as a complete circle. Use the `arc` factory method if you need control over the start and end angles. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#circle + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [radius=128] - The radius of the circle. + * @param {number} [fillColor] - The color the circle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('circle', function (x, y, radius, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, 0, 360, false, fillColor, fillAlpha)); +}); + + +/***/ }, + +/***/ 13609 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(41447); +} + +if (true) +{ + renderCanvas = __webpack_require__(42542); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 41447 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var FillPathWebGL = __webpack_require__(10441); +var StrokePathWebGL = __webpack_require__(34682); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = src.alpha; + + var submitter = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + if (src.isFilled) + { + FillPathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } +}; + +module.exports = ArcWebGLRenderer; + + +/***/ }, + +/***/ 89 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CurveRender = __webpack_require__(33141); +var Earcut = __webpack_require__(94811); +var Rectangle = __webpack_require__(87841); +var Shape = __webpack_require__(17803); + +/** + * @classdesc + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Curve + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Curve = new Class({ + + Extends: Shape, + + Mixins: [ + CurveRender + ], + + initialize: + + function Curve (scene, x, y, curve, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Curve', curve); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Curve#_smoothness + * @type {number} + * @private + * @since 3.13.0 + */ + this._smoothness = 32; + + /** + * Private internal value. + * The Curve bounds rectangle. + * + * @name Phaser.GameObjects.Curve#_curveBounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.13.0 + */ + this._curveBounds = new Rectangle(); + + this.closePath = false; + + this.setPosition(x, y); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateData(); + }, + + /** + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Curve#smoothness + * @type {number} + * @default 32 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Curve#setSmoothness + * @since 3.13.0 + * + * @param {number} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Curve#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var bounds = this._curveBounds; + var smoothness = this._smoothness; + + // Update the bounds in case the underlying data has changed + this.geom.getBounds(bounds, smoothness); + + this.setSize(bounds.width, bounds.height); + this.updateDisplayOrigin(); + + var path = []; + var points = this.geom.getPoints(smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Curve; + + +/***/ }, + +/***/ 3170 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = CurveCanvasRenderer; + + +/***/ }, + +/***/ 40511 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var Curve = __webpack_require__(89); + +/** + * Creates a new Curve Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Curve Game Object has been built into Phaser. + * + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#curve + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Curve} The Game Object that was created. + */ +GameObjectFactory.register('curve', function (x, y, curve, fillColor, fillAlpha) +{ + return this.displayList.add(new Curve(this.scene, x, y, curve, fillColor, fillAlpha)); +}); + + +/***/ }, + +/***/ 33141 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(53987); +} + +if (true) +{ + renderCanvas = __webpack_require__(3170); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 53987 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + // Note use of _curveBounds, unlike other path-based Shape objects. + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var alpha = src.alpha; + + var submitter = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + if (src.isFilled) + { + FillPathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } +}; + +module.exports = CurveWebGLRenderer; + + +/***/ }, + +/***/ 19921 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var EllipseRender = __webpack_require__(54205); +var GeomEllipse = __webpack_require__(8497); +var Shape = __webpack_require__(17803); + +/** + * @classdesc + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of points + * used to approximate the curve. Increase the default value for smoother shapes, or decrease it for + * more jagged, lower-polygon results. + * + * @class Ellipse + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Ellipse = new Class({ + + Extends: Shape, + + Mixins: [ + EllipseRender + ], + + initialize: + + function Ellipse (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Ellipse', new GeomEllipse(width / 2, height / 2, width, height)); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Ellipse#_smoothness + * @type {number} + * @private + * @since 3.13.0 + */ + this._smoothness = 64; + + this.setPosition(x, y); + + this.width = width; + this.height = height; + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Ellipse#smoothness + * @type {number} + * @default 64 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSize + * @since 3.13.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + this.geom.setPosition(width / 2, height / 2); + this.geom.setSize(width, height); + + this.updateDisplayOrigin(); + + return this.updateData(); + }, + + /** + * Sets the smoothness of the ellipse, controlling the number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSmoothness + * @since 3.13.0 + * + * @param {number} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Ellipse#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.getPoints(this._smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Ellipse; + + +/***/ }, + +/***/ 7930 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = EllipseCanvasRenderer; + + +/***/ }, + +/***/ 1543 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Ellipse = __webpack_require__(19921); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Ellipse Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. + * + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#ellipse + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Ellipse} The Game Object that was created. + */ +GameObjectFactory.register('ellipse', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Ellipse(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }, + +/***/ 54205 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(19467); +} + +if (true) +{ + renderCanvas = __webpack_require__(7930); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 19467 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = src.alpha; + + var submitter = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + if (src.isFilled) + { + FillPathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } +}; + +module.exports = EllipseWebGLRenderer; + + +/***/ }, + +/***/ 30479 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); +var GridRender = __webpack_require__(26015); + +/** + * @classdesc + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have a stroke fill color. If set, this draws lines between the grid cells + * in the given color. If you specify a stroke color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @class Grid + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [strokeFillColor] - The color of the lines between the grid cells. See the `setStrokeStyle` method. + * @param {number} [strokeFillAlpha] - The alpha of the lines between the grid cells. + */ +var Grid = new Class({ + + Extends: Shape, + + Mixins: [ + GridRender + ], + + initialize: + + function Grid (scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, strokeFillColor, strokeFillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + if (cellWidth === undefined) { cellWidth = 32; } + if (cellHeight === undefined) { cellHeight = 32; } + + Shape.call(this, scene, 'Grid', null); + + /** + * The width of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellWidth + * @type {number} + * @since 3.13.0 + */ + this.cellWidth = cellWidth; + + /** + * The height of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellHeight + * @type {number} + * @since 3.13.0 + */ + this.cellHeight = cellHeight; + + /** + * Controls whether the grid renders alternating cells using the `altFillColor` and `altFillAlpha` values. + * Set this via the `setAltFillStyle` method. + * + * @name Phaser.GameObjects.Grid#showAltCells + * @type {boolean} + * @since 3.13.0 + */ + this.showAltCells = false; + + /** + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * + * @name Phaser.GameObjects.Grid#altFillColor + * @type {number} + * @since 3.13.0 + */ + this.altFillColor; + + /** + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. + * + * @name Phaser.GameObjects.Grid#altFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.altFillAlpha; + + /** + * The padding around each cell. The effective gutter between cells is + * twice this value. + * + * @name Phaser.GameObjects.Grid#cellPadding + * @type {number} + * @since 4.0.0 + * @default 0.5 + */ + this.cellPadding = 0.5; + + /** + * Whether to stroke on the outside edges of the Grid object. + * + * @name Phaser.GameObjects.Grid#strokeOutside + * @type {boolean} + * @since 4.0.0 + * @default false + */ + this.strokeOutside = false; + + /** + * Whether to stroke on the outside edges of the Grid object + * when the cell is incomplete, e.g. the grid size does not + * evenly fit the cell size. + * + * This only has an effect if `strokeOutside` is `true`. + * It will affect the right and bottom edges of the grid. + * + * @name Phaser.GameObjects.Grid#strokeOutsideIncomplete + * @type {boolean} + * @since 4.0.0 + * @default true + */ + this.strokeOutsideIncomplete = true; + + this.setPosition(x, y); + this.setSize(width, height); + + this.setFillStyle(fillColor, fillAlpha); + + if (strokeFillColor !== undefined) + { + this.setStrokeStyle(1, strokeFillColor, strokeFillAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setStrokeStyle` and `setFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setAltFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setAltFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showAltCells = false; + } + else + { + this.altFillColor = fillColor; + this.altFillAlpha = fillAlpha; + this.showAltCells = true; + } + + return this; + }, + + /** + * Sets the cell padding for the grid. + * The cell padding is the space around each cell, between the cells. + * The effective gutter between cells is twice this value. + * + * If this method is called with no value then the cell padding is set to zero. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setCellPadding + * @since 4.0.0 + * @param {number} [value] - The cell padding value. + * @return {this} This Game Object instance. + */ + setCellPadding: function (value) + { + this.cellPadding = value || 0; + + return this; + }, + + /** + * Controls whether a stroke is drawn around the outer perimeter of the entire Grid object, + * in addition to the lines drawn between cells. Optionally, you can also control whether the + * outer edge is stroked on partial cells, i.e. where the grid dimensions do not divide evenly + * by the cell dimensions, leaving an incomplete cell on the right or bottom edge. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setStrokeOutside + * @since 4.0.0 + * @param {boolean} strokeOutside - Whether to stroke the outside edges of the Grid object. + * @param {boolean} [strokeOutsideIncomplete] - Whether to stroke the outside edges of the Grid object when the cell is incomplete. + */ + setStrokeOutside: function (strokeOutside, strokeOutsideIncomplete) + { + this.strokeOutside = strokeOutside; + + if (strokeOutsideIncomplete !== undefined) + { + this.strokeOutsideIncomplete = strokeOutsideIncomplete; + } + + return this; + } + +}); + +module.exports = Grid; + + +/***/ }, + +/***/ 49912 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Grid#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Grid} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GridCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = -src._displayOriginX; + var dy = -src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + // Work out the grid size + + var width = src.width; + var height = src.height; + + var cellWidth = src.cellWidth; + var cellHeight = src.cellHeight; + + var gridWidth = Math.ceil(width / cellWidth); + var gridHeight = Math.ceil(height / cellHeight); + + var cellWidthA = cellWidth; + var cellHeightA = cellHeight; + + var cellWidthB = cellWidth - ((gridWidth * cellWidth) - width); + var cellHeightB = cellHeight - ((gridHeight * cellHeight) - height); + + var showCells = src.isFilled; + var showAltCells = src.showAltCells; + var showOutline = src.isStroked; + + var cellPadding = src.cellPadding; + + var lineWidth = src.lineWidth; + var halfLineWidth = lineWidth / 2; + + var x = 0; + var y = 0; + var r = 0; + var cw = 0; + var ch = 0; + + if (cellPadding) + { + cellWidthA -= cellPadding * 2; + cellHeightA -= cellPadding * 2; + + + cellWidthB -= cellPadding * 2; + cellHeightB -= cellPadding * 2; + } + + if (showCells && src.fillAlpha > 0) + { + FillStyleCanvas(ctx, src); + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && r) + { + r = 0; + continue; + } + + r++; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + if (cw > 0 && ch > 0) + { + ctx.fillRect( + dx + x * cellWidth + cellPadding, + dy + y * cellHeight + cellPadding, + cw, + ch + ); + } + } + } + } + + if (showAltCells && src.altFillAlpha > 0) + { + FillStyleCanvas(ctx, src, src.altFillColor, src.altFillAlpha * alpha); + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && !r) + { + r = 1; + continue; + } + + r = 0; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + if (cw > 0 && ch > 0) + { + ctx.fillRect( + dx + x * cellWidth + cellPadding, + dy + y * cellHeight + cellPadding, + cw, + ch + ); + } + } + } + } + + if (showOutline && src.strokeAlpha > 0) + { + LineStyleCanvas(ctx, src, src.strokeColor, src.strokeAlpha * alpha); + + var start = src.strokeOutside ? 0 : 1; + + for (x = start; x < gridWidth; x++) + { + var x1 = x * cellWidth; + + ctx.beginPath(); + + ctx.moveTo(x1 + dx, dy); + ctx.lineTo(x1 + dx, height + dy); + + ctx.stroke(); + } + + for (y = start; y < gridHeight; y++) + { + var y1 = y * cellHeight; + + ctx.beginPath(); + + ctx.moveTo(dx, y1 + dy); + ctx.lineTo(dx + width, y1 + dy); + + ctx.stroke(); + } + + // Render remaining outer strokes. + if (src.strokeOutside) + { + if (width > halfLineWidth) + { + ctx.beginPath(); + + ctx.moveTo(width + dx, dy); + ctx.lineTo(width + dx, height + dy); + + ctx.stroke(); + } + + if (height > halfLineWidth) + { + ctx.beginPath(); + + ctx.moveTo(dx, height + dy); + ctx.lineTo(width + dx, height + dy); + + ctx.stroke(); + } + } + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = GridCanvasRenderer; + + +/***/ }, + +/***/ 34137 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var Grid = __webpack_require__(30479); + +/** + * Creates a new Grid Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @method Phaser.GameObjects.GameObjectFactory#grid + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + * + * @return {Phaser.GameObjects.Grid} The Game Object that was created. + */ +GameObjectFactory.register('grid', function (x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) +{ + return this.displayList.add(new Grid(this.scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha)); +}); + + +/***/ }, + +/***/ 26015 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(46161); +} + +if (true) +{ + renderCanvas = __webpack_require__(49912); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 46161 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Grid#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Grid} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GridWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var fillRectNode = src.customRenderNodes.FillRect || src.defaultRenderNodes.FillRect; + var submitterNode = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + calcMatrix.translate(-src._displayOriginX, -src._displayOriginY); + + var alpha = src.alpha; + + // Work out the grid size + + var width = src.width; + var height = src.height; + + var cellWidth = src.cellWidth; + var cellHeight = src.cellHeight; + + var gridWidth = Math.ceil(width / cellWidth); + var gridHeight = Math.ceil(height / cellHeight); + + var cellWidthA = cellWidth; + var cellHeightA = cellHeight; + + var cellWidthB = cellWidth - ((gridWidth * cellWidth) - width); + var cellHeightB = cellHeight - ((gridHeight * cellHeight) - height); + + var fillTintColor; + + var showCells = src.isFilled; + var showAltCells = src.showAltCells; + var showOutline = src.isStroked; + + var cellPadding = src.cellPadding; + + var lineWidth = src.lineWidth; + var halfLineWidth = lineWidth / 2; + + var x = 0; + var y = 0; + var r = 0; + var cw = 0; + var ch = 0; + + if (cellPadding) + { + cellWidthA -= cellPadding * 2; + cellHeightA -= cellPadding * 2; + + cellWidthB -= cellPadding * 2; + cellHeightB -= cellPadding * 2; + } + + if (showCells && src.fillAlpha > 0) + { + fillTintColor = Utils.getTintAppendFloatAlpha(src.fillColor, src.fillAlpha * alpha); + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && r) + { + r = 0; + continue; + } + + r++; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + if (cw > 0 && ch > 0) + { + fillRectNode.run( + drawingContext, + calcMatrix, + submitterNode, + x * cellWidth + cellPadding, y * cellHeight + cellPadding, + cw, ch, + fillTintColor, fillTintColor, fillTintColor, fillTintColor, + src.lighting + ); + } + } + } + } + + if (showAltCells && src.altFillAlpha > 0) + { + fillTintColor = Utils.getTintAppendFloatAlpha(src.altFillColor, src.altFillAlpha * alpha); + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && !r) + { + r = 1; + continue; + } + + r = 0; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + if (cw > 0 && ch > 0) + { + fillRectNode.run( + drawingContext, + calcMatrix, + submitterNode, + x * cellWidth + cellPadding, y * cellHeight + cellPadding, + cw, ch, + fillTintColor, fillTintColor, fillTintColor, fillTintColor + ); + } + } + } + } + + if (showOutline && src.strokeAlpha > 0) + { + var color = Utils.getTintAppendFloatAlpha(src.strokeColor, src.strokeAlpha * alpha); + + var start = src.strokeOutside ? 0 : 1; + + for (x = start; x < gridWidth; x++) + { + var x1 = x * cellWidth - halfLineWidth; + + fillRectNode.run( + drawingContext, + calcMatrix, + submitterNode, + x1, 0, + lineWidth, height, + color, color, color, color + ); + } + + for (y = start; y < gridHeight; y++) + { + var y1 = y * cellHeight - halfLineWidth; + + fillRectNode.run( + drawingContext, + calcMatrix, + submitterNode, + 0, y1, + width, lineWidth, + color, color, color, color + ); + } + + // Render remaining outer strokes. + if (src.strokeOutside && src.strokeOutsideIncomplete) + { + if (width > halfLineWidth) + { + fillRectNode.run( + drawingContext, + calcMatrix, + submitterNode, + width - halfLineWidth, 0, + lineWidth, height, + color, color, color, color + ); + } + + if (height > halfLineWidth) + { + fillRectNode.run( + drawingContext, + calcMatrix, + submitterNode, + 0, height - halfLineWidth, + width, lineWidth, + color, color, color, color + ); + } + } + } +}; + +module.exports = GridWebGLRenderer; + + +/***/ }, + +/***/ 61475 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var IsoBoxRender = __webpack_require__(99651); +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); + +/** + * @classdesc + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from underneath, however you can change the 'angle' by setting + * the `projection` property. + * + * @class IsoBox + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + */ +var IsoBox = new Class({ + + Extends: Shape, + + Mixins: [ + IsoBoxRender + ], + + initialize: + + function IsoBox (scene, x, y, size, height, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoBox', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoBox#projection + * @type {number} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls whether the top face of the iso box will be rendered. + * + * @name Phaser.GameObjects.IsoBox#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls whether the left face of the iso box will be rendered. + * + * @name Phaser.GameObjects.IsoBox#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls whether the right face of the iso box will be rendered. + * + * @name Phaser.GameObjects.IsoBox#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setProjection + * @since 3.13.0 + * + * @param {number} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso box. + * @param {boolean} [showLeft=true] - Show the left-face of the iso box. + * @param {boolean} [showRight=true] - Show the right-face of the iso box. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso box. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso box. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso box. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoBox; + + +/***/ }, + +/***/ 11508 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + // Top Face + + if (src.showTop) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, -1); + ctx.lineTo(0, sizeB - 1); + ctx.lineTo(-sizeA, -1); + ctx.lineTo(-sizeA, -height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(-sizeA, -height); + ctx.lineTo(-sizeA, 0); + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, 0); + + ctx.fill(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = IsoBoxCanvasRenderer; + + +/***/ }, + +/***/ 3933 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var IsoBox = __webpack_require__(61475); + +/** + * Creates a new IsoBox Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. + * + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @method Phaser.GameObjects.GameObjectFactory#isobox + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + * + * @return {Phaser.GameObjects.IsoBox} The Game Object that was created. + */ +GameObjectFactory.register('isobox', function (x, y, size, height, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoBox(this.scene, x, y, size, height, fillTop, fillLeft, fillRight)); +}); + + +/***/ }, + +/***/ 99651 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(68149); +} + +if (true) +{ + renderCanvas = __webpack_require__(11508); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 68149 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + if (!src.isFilled) + { + return; + } + + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var fillTriNode = src.customRenderNodes.FillTri || src.defaultRenderNodes.FillTri; + var submitterNode = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var alpha = src.alpha; + + var tint; + + var lighting = src.lighting; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + // Top Face + + if (src.showTop) + { + tint = Utils.getTintAppendFloatAlpha(src.fillTop, alpha); + + x0 = -sizeA; + y0 = -height; + + x1 = 0; + y1 = -sizeB - height; + + x2 = sizeA; + y2 = -height; + + x3 = 0; + y3 = sizeB - height; + + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x0, y0, x1, y1, x2, y2, tint, tint, tint, lighting); + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x2, y2, x3, y3, x0, y0, tint, tint, tint, lighting); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlpha(src.fillLeft, alpha); + + x0 = -sizeA; + y0 = 0; + + x1 = 0; + y1 = sizeB; + + x2 = 0; + y2 = sizeB - height; + + x3 = -sizeA; + y3 = -height; + + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x0, y0, x1, y1, x2, y2, tint, tint, tint, lighting); + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x2, y2, x3, y3, x0, y0, tint, tint, tint, lighting); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlpha(src.fillRight, alpha); + + x0 = sizeA; + y0 = 0; + + x1 = 0; + y1 = sizeB; + + x2 = 0; + y2 = sizeB - height; + + x3 = sizeA; + y3 = -height; + + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x0, y0, x1, y1, x2, y2, tint, tint, tint, lighting); + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x2, y2, x3, y3, x0, y0, tint, tint, tint, lighting); + } +}; + +module.exports = IsoBoxWebGLRenderer; + + +/***/ }, + +/***/ 16933 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var IsoTriangleRender = __webpack_require__(60561); +var Shape = __webpack_require__(17803); + +/** + * @classdesc + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @class IsoTriangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + */ +var IsoTriangle = new Class({ + + Extends: Shape, + + Mixins: [ + IsoTriangleRender + ], + + initialize: + + function IsoTriangle (scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (reversed === undefined) { reversed = false; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoTriangle', null); + + /** + * The projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * + * @name Phaser.GameObjects.IsoTriangle#projection + * @type {number} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + * + * @name Phaser.GameObjects.IsoTriangle#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls whether the top face of the iso triangle will be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls whether the left face of the iso triangle will be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls whether the right face of the iso triangle will be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + /** + * Indicates whether the iso triangle is rendered upside down. + * + * @name Phaser.GameObjects.IsoTriangle#isReversed + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.isReversed = reversed; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setProjection + * @since 3.13.0 + * + * @param {number} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setReversed + * @since 3.13.0 + * + * @param {boolean} reversed - Whether to render the iso triangle upside down. + * + * @return {this} This Game Object instance. + */ + setReversed: function (reversed) + { + this.isReversed = reversed; + + return this; + }, + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso triangle (only if `reversed` is true) + * @param {boolean} [showLeft=true] - Show the left-face of the iso triangle. + * @param {boolean} [showRight=true] - Show the right-face of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso triangle. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso triangle. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoTriangle; + + +/***/ }, + +/***/ 79590 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + // Top Face + + if (src.showTop && reversed) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(0, sizeB - height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = IsoTriangleCanvasRenderer; + + +/***/ }, + +/***/ 49803 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var IsoTriangle = __webpack_require__(16933); + +/** + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. + * + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively. + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from underneath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @method Phaser.GameObjects.GameObjectFactory#isotriangle + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + * + * @return {Phaser.GameObjects.IsoTriangle} The Game Object that was created. + */ +GameObjectFactory.register('isotriangle', function (x, y, size, height, reversed, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoTriangle(this.scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight)); +}); + + +/***/ }, + +/***/ 60561 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(51503); +} + +if (true) +{ + renderCanvas = __webpack_require__(79590); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 51503 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + if (!src.isFilled) + { + return; + } + + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var fillTriNode = src.customRenderNodes.FillTri || src.defaultRenderNodes.FillTri; + var submitterNode = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + var alpha = src.alpha; + + var lighting = src.lighting; + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + // Top Face + + if (src.showTop && reversed) + { + tint = Utils.getTintAppendFloatAlpha(src.fillTop, alpha); + + x0 = -sizeA; + y0 = -height; + + x1 = 0; + y1 = -sizeB - height; + + x2 = sizeA; + y2 = -height; + + var x3 = 0; + var y3 = sizeB - height; + + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x0, y0, x1, y1, x2, y2, tint, tint, tint, lighting); + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x2, y2, x3, y3, x0, y0, tint, tint, tint, lighting); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlpha(src.fillLeft, alpha); + + if (reversed) + { + x0 = -sizeA; + y0 = -height; + + x1 = 0; + y1 = sizeB; + + x2 = 0; + y2 = sizeB - height; + } + else + { + x0 = -sizeA; + y0 = 0; + + x1 = 0; + y1 = sizeB; + + x2 = 0; + y2 = sizeB - height; + } + + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x0, y0, x1, y1, x2, y2, tint, tint, tint, lighting); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlpha(src.fillRight, alpha); + + if (reversed) + { + x0 = sizeA; + y0 = -height; + + x1 = 0; + y1 = sizeB; + + x2 = 0; + y2 = sizeB - height; + } + else + { + x0 = sizeA; + y0 = 0; + + x1 = 0; + y1 = sizeB; + + x2 = 0; + y2 = sizeB - height; + } + + fillTriNode.run(drawingContext, calcMatrix, submitterNode, x0, y0, x1, y1, x2, y2, tint, tint, tint, lighting); + } +}; + +module.exports = IsoTriangleWebGLRenderer; + + +/***/ }, + +/***/ 57847 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); +var GeomLine = __webpack_require__(23031); +var LineRender = __webpack_require__(36823); + +/** + * @classdesc + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only, you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * Be aware that as with all Game Objects the default origin is 0.5. If you need to draw a Line + * between two points and want the x1/y1 values to match the x/y values, then set the origin to 0. + * + * @class Line + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Line = new Class({ + + Extends: Shape, + + Mixins: [ + LineRender + ], + + initialize: + + function Line (scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 128; } + if (y2 === undefined) { y2 = 0; } + + Shape.call(this, scene, 'Line', new GeomLine(x1, y1, x2, y2)); + + /** + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + * + * @name Phaser.GameObjects.Line#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Private internal value. Holds the start width of the line. + * + * @name Phaser.GameObjects.Line#_startWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._startWidth = 1; + + /** + * Private internal value. Holds the end width of the line. + * + * @name Phaser.GameObjects.Line#_endWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._endWidth = 1; + + this.setPosition(x, y); + this.updateSize(); + + if (strokeColor !== undefined) + { + this.setStrokeStyle(1, strokeColor, strokeAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the width of the line. + * + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Line#setLineWidth + * @since 3.13.0 + * + * @param {number} startWidth - The start width of the line. + * @param {number} [endWidth] - The end width of the line. Only used in WebGL. + * + * @return {this} This Game Object instance. + */ + setLineWidth: function (startWidth, endWidth) + { + if (endWidth === undefined) { endWidth = startWidth; } + + this._startWidth = startWidth; + this._endWidth = endWidth; + + this.lineWidth = startWidth; + + return this; + }, + + /** + * Sets the start and end coordinates of this Line. + * + * @method Phaser.GameObjects.Line#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=0] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * + * @return {this} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + this.geom.setTo(x1, y1, x2, y2); + + this.updateSize(); + + return this; + }, + + /** + * Updates the width and height of the Line based on its geometry. + * + * @method Phaser.GameObjects.Line#updateSize + * @private + * @since 4.2.0 + * + * @return {this} This Line instance. + */ + updateSize: function () + { + var width = Math.max(1, this.geom.right - this.geom.left); + var height = Math.max(1, this.geom.bottom - this.geom.top); + + this.setSize(width, height); + + return this; + } +}); + +module.exports = Line; + + +/***/ }, + +/***/ 17440 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.moveTo(src.geom.x1 - dx, src.geom.y1 - dy); + ctx.lineTo(src.geom.x2 - dx, src.geom.y2 - dy); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = LineCanvasRenderer; + + +/***/ }, + +/***/ 2481 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var Line = __webpack_require__(57847); + +/** + * Creates a new Line Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Line Game Object has been built into Phaser. + * + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @method Phaser.GameObjects.GameObjectFactory#line + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Line} The Game Object that was created. + */ +GameObjectFactory.register('line', function (x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) +{ + return this.displayList.add(new Line(this.scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha)); +}); + + +/***/ }, + +/***/ 36823 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(77385); +} + +if (true) +{ + renderCanvas = __webpack_require__(17440); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 77385 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); + +var tempPath = [ + { + x: 0, y: 0, width: 0 + }, + { + x: 0, y: 0, width: 0 + } +]; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = src.alpha; + + if (src.isStroked) + { + var color = Utils.getTintAppendFloatAlpha(src.strokeColor, src.strokeAlpha * alpha); + + tempPath[0].x = src.geom.x1 - dx; + tempPath[0].y = src.geom.y1 - dy; + tempPath[0].width = src._startWidth; + + tempPath[1].x = src.geom.x2 - dx; + tempPath[1].y = src.geom.y2 - dy; + tempPath[1].width = src._endWidth; + + (src.customRenderNodes.StrokePath || src.defaultRenderNodes.StrokePath).run( + drawingContext, + src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter, + tempPath, + 1, + true, + calcMatrix, + color, color, color, color, + undefined, + src.lighting + ); + } +}; + +module.exports = LineWebGLRenderer; + + +/***/ }, + +/***/ 24949 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PolygonRender = __webpack_require__(90273); +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var GetAABB = __webpack_require__(13829); +var GeomPolygon = __webpack_require__(25717); +var Shape = __webpack_require__(17803); +var Smooth = __webpack_require__(5469); + +/** + * @classdesc + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * Note: The method `getBounds` will return incorrect bounds if any of the points in the Polygon are negative. + * If this is the case, please use the function `Phaser.Geom.Polygon.GetAABB(polygon.geom)` instead and then + * adjust the returned Rectangle position accordingly. + * + * @class Polygon + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Polygon = new Class({ + + Extends: Shape, + + Mixins: [ + PolygonRender + ], + + initialize: + + function Polygon (scene, x, y, points, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Polygon', new GeomPolygon(points)); + + var bounds = GetAABB(this.geom); + + this.setPosition(x, y); + this.setSize(bounds.width, bounds.height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. + * This call can be chained. + * + * @method Phaser.GameObjects.Polygon#smooth + * @since 3.13.0 + * + * @param {number} [iterations=1] - The number of times to apply the polygon smoothing. + * + * @return {this} This Game Object instance. + */ + smooth: function (iterations) + { + if (iterations === undefined) { iterations = 1; } + + for (var i = 0; i < iterations; i++) + { + Smooth(this.geom); + } + + return this.updateData(); + }, + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * Calling this method will reset the size (width, height) and display origin of this Shape. + * + * It also runs both GetAABB and EarCut on the given points, so please be careful not to do this + * at a high frequency, or with too many points. + * + * @method Phaser.GameObjects.Polygon#setTo + * @since 3.60.0 + * + * @param {(string|number[]|Phaser.Types.Math.Vector2Like[])} [points] - Points defining the perimeter of this polygon. Please check function description above for the different supported formats. + * + * @return {this} This Game Object instance. + */ + setTo: function (points) + { + this.geom.setTo(points); + + var bounds = GetAABB(this.geom); + + this.setSize(bounds.width, bounds.height); + + this.updateDisplayOrigin(); + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Polygon#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.points; + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Polygon; + + +/***/ }, + +/***/ 38710 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = PolygonCanvasRenderer; + + +/***/ }, + +/***/ 64827 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var Polygon = __webpack_require__(24949); + +/** + * Creates a new Polygon Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. + * + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @method Phaser.GameObjects.GameObjectFactory#polygon + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Polygon} The Game Object that was created. + */ +GameObjectFactory.register('polygon', function (x, y, points, fillColor, fillAlpha) +{ + return this.displayList.add(new Polygon(this.scene, x, y, points, fillColor, fillAlpha)); +}); + + +/***/ }, + +/***/ 90273 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(73695); +} + +if (true) +{ + renderCanvas = __webpack_require__(38710); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 73695 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = src.alpha; + + var submitter = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + if (src.isFilled) + { + FillPathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } +}; + +module.exports = PolygonWebGLRenderer; + + +/***/ }, + +/***/ 74561 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var GeomRectangle = __webpack_require__(87841); +var Shape = __webpack_require__(17803); +var RectangleRender = __webpack_require__(95597); + +/** + * @classdesc + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @class Rectangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Rectangle = new Class({ + + Extends: Shape, + + Mixins: [ + RectangleRender + ], + + initialize: + + function Rectangle (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Rectangle', new GeomRectangle(0, 0, width, height)); + + /** + * The radius of the rectangle if this is set to use rounded corners. + * + * Do not modify this property. Instead, call the method `setRounded` to set the + * radius of the rounded corners. + * + * @name Phaser.GameObjects.Rectangle#radius + * @type {number} + * @readonly + * @since 3.89.0 + */ + this.radius = 20; + + /** + * Does this Rectangle have rounded corners? + * + * Do not modify this property. Instead, call the method `setRounded` to set the + * radius state of this rectangle. + * + * @name Phaser.GameObjects.Rectangle#isRounded + * @type {boolean} + * @readonly + * @since 3.89.0 + */ + this.isRounded = false; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets this rectangle to have rounded corners by specifying the radius of the corners. + * + * The radius of the rounded corners is limited by the smallest dimension of the rectangle. + * + * To disable rounded corners, set the `radius` parameter to 0. + * + * @method Phaser.GameObjects.Rectangle#setRounded + * @since 3.89.0 + * + * @param {number} [radius=16] - The radius of all four rounded corners. + * + * @return {this} This Game Object instance. + */ + setRounded: function (radius) + { + if (radius === undefined) { radius = 16; } + + this.radius = radius; + this.isRounded = radius > 0; + + return this.updateRoundedData(); + }, + + /** + * Sets the size of this Rectangle. This updates the underlying geometry, path data, display origin, and the default input hit area. + * + * If you have assigned a custom input hit area for this Rectangle, changing the Rectangle size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Rectangle#setSize + * @since 3.13.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + this.geom.setSize(width, height); + + this.updateData(); + + this.updateDisplayOrigin(); + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = width; + input.hitArea.height = height; + } + + return this; + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Rectangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + if (this.isRounded) + { + return this.updateRoundedData(); + } + + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + rect.getLineD(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + }, + + /** + * Internal method that updates the data and path values when this rectangle is rounded. + * + * @method Phaser.GameObjects.Rectangle#updateRoundedData + * @private + * @since 3.89.0 + * + * @return {this} This Game Object instance. + */ + updateRoundedData: function () + { + var path = []; + var halfWidth = this.width / 2; + var halfHeight = this.height / 2; + + // Limit max radius to half the smallest dimension + var maxRadius = Math.min(halfWidth, halfHeight); + var radius = Math.min(this.radius, maxRadius); + + var x = halfWidth; + var y = halfHeight; + + // Ensure minimum smoothness for small radii while preventing excessive tessellation + var segments = Math.max(4, Math.min(16, Math.ceil(radius / 2))); + + // Create points going clockwise from top-left + + // Top-left corner + this.arcTo(path, x - halfWidth + radius, y - halfHeight + radius, radius, Math.PI, Math.PI * 1.5, segments); + + // Top edge and top-right corner + path.push(x + halfWidth - radius, y - halfHeight); + + this.arcTo(path, x + halfWidth - radius, y - halfHeight + radius, radius, Math.PI * 1.5, Math.PI * 2, segments); + + // Right edge and bottom-right corner + path.push(x + halfWidth, y + halfHeight - radius); + + this.arcTo(path, x + halfWidth - radius, y + halfHeight - radius, radius, 0, Math.PI * 0.5, segments); + + // Bottom edge and bottom-left corner + path.push(x - halfWidth + radius, y + halfHeight); + + this.arcTo(path, x - halfWidth + radius, y + halfHeight - radius, radius, Math.PI * 0.5, Math.PI, segments); + + // Left edge (connects back to first point) + path.push(x - halfWidth, y - halfHeight + radius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + }, + + /** + * Internal method placing points around the circumference of a circle for the rounded corners. + * + * @method Phaser.GameObjects.Rectangle#arcTo + * @private + * @since 3.89.0 + * + * @param {number[]} path - The array to push the points into. + * @param {number} centerX - The center x coordinate of the circle. + * @param {number} centerY - The center y coordinate of the circle. + * @param {number} radius - The radius of the circle. + * @param {number} startAngle - The starting angle of the arc. + * @param {number} endAngle - The ending angle of the arc. + * @param {number} segments - The number of segments to create. + * + * @return {this} This Game Object instance. + */ + arcTo: function (path, centerX, centerY, radius, startAngle, endAngle, segments) + { + var angleInc = (endAngle - startAngle) / segments; + + for (var i = 0; i <= segments; i++) + { + var angle = startAngle + (angleInc * i); + + path.push( + centerX + Math.cos(angle) * radius, + centerY + Math.sin(angle) * radius + ); + } + } + +}); + +module.exports = Rectangle; + + +/***/ }, + +/***/ 48682 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Constructs a rounded rectangle path on the given Canvas 2D context using `arcTo` for each corner. + * The corner radius is automatically clamped to half the smaller of the width or height to prevent + * rendering artifacts. If the clamped radius is zero, a standard rectangle is drawn via `ctx.rect` instead. + * This function only defines the path; the caller is responsible for calling `ctx.fill` or `ctx.stroke`. + * + * @ignore + * @param {CanvasRenderingContext2D} ctx - The Canvas 2D rendering context on which to draw the path. + * @param {number} x - The x coordinate of the top-left corner of the rectangle, in pixels. + * @param {number} y - The y coordinate of the top-left corner of the rectangle, in pixels. + * @param {number} width - The width of the rectangle, in pixels. + * @param {number} height - The height of the rectangle, in pixels. + * @param {number} radius - The desired corner radius, in pixels. Clamped to half the smaller dimension. + */ +var DrawRoundedRect = function (ctx, x, y, width, height, radius) +{ + // Limit radius to half of the smaller dimension + var maxRadius = Math.min(width / 2, height / 2); + var r = Math.min(radius, maxRadius); + + if (r === 0) + { + // Fall back to normal rectangle if radius is 0 + ctx.rect(x, y, width, height); + return; + } + + // Start at top-left, after the corner + ctx.moveTo(x + r, y); + + // Top edge and top-right corner + ctx.lineTo(x + width - r, y); + ctx.arcTo(x + width, y, x + width, y + r, r); + + // Right edge and bottom-right corner + ctx.lineTo(x + width, y + height - r); + ctx.arcTo(x + width, y + height, x + width - r, y + height, r); + + // Bottom edge and bottom-left corner + ctx.lineTo(x + r, y + height); + ctx.arcTo(x, y + height, x, y + height - r, r); + + // Left edge and top-left corner + ctx.lineTo(x, y + r); + ctx.arcTo(x, y, x + r, y, r); + + ctx.closePath(); +}; + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + if (src.isRounded) + { + ctx.beginPath(); + DrawRoundedRect(ctx, -dx, -dy, src.width, src.height, src.radius); + ctx.fill(); + } + else + { + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + if (src.isRounded) + { + DrawRoundedRect(ctx, -dx, -dy, src.width, src.height, src.radius); + } + else + { + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + } + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + + + +module.exports = RectangleCanvasRenderer; + + +/***/ }, + +/***/ 87959 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var Rectangle = __webpack_require__(74561); + +/** + * Creates a new Rectangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. + * + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @method Phaser.GameObjects.GameObjectFactory#rectangle + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Rectangle} The Game Object that was created. + */ +GameObjectFactory.register('rectangle', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Rectangle(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }, + +/***/ 95597 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(52059); +} + +if (true) +{ + renderCanvas = __webpack_require__(48682); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 52059 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); +var Utils = __webpack_require__(70554); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = src.alpha; + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + var submitter = customRenderNodes.Submitter || defaultRenderNodes.Submitter; + + if (src.isFilled) + { + if (src.isRounded) + { + FillPathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } + else + { + var fillTintColor = Utils.getTintAppendFloatAlpha(src.fillColor, src.fillAlpha * alpha); + + (customRenderNodes.FillRect || defaultRenderNodes.FillRect).run( + drawingContext, + calcMatrix, + submitter, + -dx, -dy, + src.width, src.height, + fillTintColor, + fillTintColor, + fillTintColor, + fillTintColor, + src.lighting + ); + } + } + + if (src.isStroked) + { + StrokePathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } +}; + +module.exports = RectangleWebGLRenderer; + + +/***/ }, + +/***/ 55911 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var StarRender = __webpack_require__(81991); +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var Shape = __webpack_require__(17803); + +/** + * @classdesc + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @class Star + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star, in pixels. + * @param {number} [outerRadius=64] - The outer radius of the star, in pixels. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Star = new Class({ + + Extends: Shape, + + Mixins: [ + StarRender + ], + + initialize: + + function Star (scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (points === undefined) { points = 5; } + if (innerRadius === undefined) { innerRadius = 32; } + if (outerRadius === undefined) { outerRadius = 64; } + + Shape.call(this, scene, 'Star', null); + + /** + * Private internal value. + * The number of points in the star. + * + * @name Phaser.GameObjects.Star#_points + * @type {number} + * @private + * @since 3.13.0 + */ + this._points = points; + + /** + * Private internal value. + * The inner radius of the star. + * + * @name Phaser.GameObjects.Star#_innerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._innerRadius = innerRadius; + + /** + * Private internal value. + * The outer radius of the star. + * + * @name Phaser.GameObjects.Star#_outerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._outerRadius = outerRadius; + + this.setPosition(x, y); + this.setSize(outerRadius * 2, outerRadius * 2); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the number of points that make up the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setPoints + * @since 3.13.0 + * + * @param {number} value - The number of points the Star will have. + * + * @return {this} This Game Object instance. + */ + setPoints: function (value) + { + this._points = value; + + return this.updateData(); + }, + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setInnerRadius + * @since 3.13.0 + * + * @param {number} value - The inner radius of the star, in pixels. + * + * @return {this} This Game Object instance. + */ + setInnerRadius: function (value) + { + this._innerRadius = value; + + return this.updateData(); + }, + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setOuterRadius + * @since 3.13.0 + * + * @param {number} value - The outer radius of the star, in pixels. + * + * @return {this} This Game Object instance. + */ + setOuterRadius: function (value) + { + this._outerRadius = value; + + return this.updateData(); + }, + + /** + * The number of points that make up the Star shape. + * + * @name Phaser.GameObjects.Star#points + * @type {number} + * @default 5 + * @since 3.13.0 + */ + points: { + + get: function () + { + return this._points; + }, + + set: function (value) + { + this._points = value; + + this.updateData(); + } + + }, + + /** + * The inner radius of the Star shape, in pixels. + * + * @name Phaser.GameObjects.Star#innerRadius + * @type {number} + * @default 32 + * @since 3.13.0 + */ + innerRadius: { + + get: function () + { + return this._innerRadius; + }, + + set: function (value) + { + this._innerRadius = value; + + this.updateData(); + } + + }, + + /** + * The outer radius of the Star shape, in pixels. + * + * @name Phaser.GameObjects.Star#outerRadius + * @type {number} + * @default 64 + * @since 3.13.0 + */ + outerRadius: { + + get: function () + { + return this._outerRadius; + }, + + set: function (value) + { + this._outerRadius = value; + + this.updateData(); + } + + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Star#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + + var points = this._points; + var innerRadius = this._innerRadius; + var outerRadius = this._outerRadius; + + var rot = Math.PI / 2 * 3; + var step = Math.PI / points; + + // So origin 0.5 = the center of the star + var x = outerRadius; + var y = outerRadius; + + path.push(x, y + -outerRadius); + + for (var i = 0; i < points; i++) + { + path.push(x + Math.cos(rot) * outerRadius, y + Math.sin(rot) * outerRadius); + + rot += step; + + path.push(x + Math.cos(rot) * innerRadius, y + Math.sin(rot) * innerRadius); + + rot += step; + } + + path.push(x, y + -outerRadius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Star; + + +/***/ }, + +/***/ 64272 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = StarCanvasRenderer; + + +/***/ }, + +/***/ 93697 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Star = __webpack_require__(55911); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Star Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Star Game Object has been built into Phaser. + * + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#star + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Star} The Game Object that was created. + */ +GameObjectFactory.register('star', function (x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) +{ + return this.displayList.add(new Star(this.scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha)); +}); + + +/***/ }, + +/***/ 81991 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(57017); +} + +if (true) +{ + renderCanvas = __webpack_require__(64272); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 57017 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = src.alpha; + + var submitter = src.customRenderNodes.Submitter || src.defaultRenderNodes.Submitter; + + if (src.isFilled) + { + FillPathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } +}; + +module.exports = StarWebGLRenderer; + + +/***/ }, + +/***/ 36931 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); +var GeomTriangle = __webpack_require__(16483); +var TriangleRender = __webpack_require__(96195); + +/** + * @classdesc + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @class Triangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Triangle = new Class({ + + Extends: Shape, + + Mixins: [ + TriangleRender + ], + + initialize: + + function Triangle (scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 128; } + if (x2 === undefined) { x2 = 64; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 128; } + if (y3 === undefined) { y3 = 128; } + + Shape.call(this, scene, 'Triangle', new GeomTriangle(x1, y1, x2, y2, x3, y3)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the positions of the three vertices of this Triangle shape and updates its internal path data for rendering. + * + * @method Phaser.GameObjects.Triangle#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=0] - The vertical position of the first point in the triangle. + * @param {number} [x2=0] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=0] - The horizontal position of the third point in the triangle. + * @param {number} [y3=0] - The vertical position of the third point in the triangle. + * + * @return {this} This Game Object instance. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + this.geom.setTo(x1, y1, x2, y2, x3, y3); + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Triangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var tri = this.geom; + var line = this._tempLine; + + tri.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + tri.getLineB(line); + + path.push(line.x2, line.y2); + + tri.getLineC(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Triangle; + + +/***/ }, + +/***/ 85172 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + ctx.beginPath(); + + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.lineTo(x3, y3); + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = TriangleCanvasRenderer; + + +/***/ }, + +/***/ 45245 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var Triangle = __webpack_require__(36931); + +/** + * Creates a new Triangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @method Phaser.GameObjects.GameObjectFactory#triangle + * @since 3.13.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Triangle} The Game Object that was created. + */ +GameObjectFactory.register('triangle', function (x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) +{ + return this.displayList.add(new Triangle(this.scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha)); +}); + + +/***/ }, + +/***/ 96195 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(83253); +} + +if (true) +{ + renderCanvas = __webpack_require__(85172); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 83253 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); +var Utils = __webpack_require__(70554); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var calcMatrix = GetCalcMatrix(src, camera, parentMatrix, !drawingContext.useCanvas).calc; + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = src.alpha; + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + var submitter = customRenderNodes.Submitter || defaultRenderNodes.Submitter; + + if (src.isFilled) + { + var fillTintColor = Utils.getTintAppendFloatAlpha(src.fillColor, src.fillAlpha * alpha); + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + (customRenderNodes.FillTri || defaultRenderNodes.FillTri).run( + drawingContext, + calcMatrix, + submitter, + x1, + y1, + x2, + y2, + x3, + y3, + fillTintColor, + fillTintColor, + fillTintColor, + src.lighting + ); + } + + if (src.isStroked) + { + StrokePathWebGL(drawingContext, submitter, calcMatrix, src, alpha, dx, dy); + } +}; + +module.exports = TriangleWebGLRenderer; + + +/***/ }, + +/***/ 68287 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AnimationState = __webpack_require__(9674); +var DefaultImageNodes = __webpack_require__(40939); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var SpriteRender = __webpack_require__(92751); + +/** + * @classdesc + * A Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Sprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Lighting, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.Size, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + SpriteRender + ], + + initialize: + + function Sprite (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Sprite'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Sprite#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Animation State component of this Sprite. + * + * This component provides features to apply animations to this Sprite. + * It is responsible for playing, loading, queuing animations for later playback, + * mixing between animations and setting the current animation frame to this Sprite. + * + * @name Phaser.GameObjects.Sprite#anims + * @type {Phaser.Animations.AnimationState} + * @since 3.0.0 + */ + this.anims = new AnimationState(this); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initRenderNodes(this._defaultRenderNodesMap); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Sprite#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultImageNodes; + } + }, + + /** + * Called automatically by Phaser when this Sprite is added to a Scene. + * + * Registers this Sprite with the Scene's update list so that its `preUpdate` method + * is called each game step, allowing animations to advance each frame. + * + * @method Phaser.GameObjects.Sprite#addedToScene + * @since 3.53.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Called automatically by Phaser when this Sprite is removed from a Scene. + * + * Unregisters this Sprite from the Scene's update list so that its `preUpdate` method + * is no longer called each game step. + * + * @method Phaser.GameObjects.Sprite#removedFromScene + * @since 3.53.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * Update this Sprite's animations. + * + * @method Phaser.GameObjects.Sprite#preUpdate + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * Start playing the given animation on this Sprite. + * + * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. + * + * The benefit of a global animation is that multiple Sprites can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any Sprite. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Sprite. + * + * With the animation created, either globally or locally, you can now play it on this Sprite: + * + * ```javascript + * this.add.sprite(x, y).play('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config + * object instead: + * + * ```javascript + * this.add.sprite(x, y).play({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Sprite to be able to play both local and global animations, make sure they don't + * have conflicting keys. + * + * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * + * Also, see the documentation in the Animation Manager for further details on creating animations. + * + * @method Phaser.GameObjects.Sprite#play + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.0.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * + * @return {this} This Game Object. + */ + play: function (key, ignoreIfPlaying) + { + return this.anims.play(key, ignoreIfPlaying); + }, + + /** + * Start playing the given animation on this Sprite, in reverse. + * + * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. + * + * The benefit of a global animation is that multiple Sprites can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any Sprite. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Sprite. + * + * With the animation created, either globally or locally, you can now play it on this Sprite: + * + * ```javascript + * this.add.sprite(x, y).playReverse('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config + * object instead: + * + * ```javascript + * this.add.sprite(x, y).playReverse({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Sprite to be able to play both local and global animations, make sure they don't + * have conflicting keys. + * + * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * + * Also, see the documentation in the Animation Manager for further details on creating animations. + * + * @method Phaser.GameObjects.Sprite#playReverse + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * + * @return {this} This Game Object. + */ + playReverse: function (key, ignoreIfPlaying) + { + return this.anims.playReverse(key, ignoreIfPlaying); + }, + + /** + * Waits for the specified delay, in milliseconds, then starts playback of the given animation. + * + * If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here. + * + * If an animation is already running and a new animation is given to this method, it will wait for + * the given delay before starting the new animation. + * + * If no animation is currently running, the given one begins after the delay. + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * Prior to Phaser 3.50 this method was called 'delayedPlay'. + * + * @method Phaser.GameObjects.Sprite#playAfterDelay + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {number} delay - The delay, in milliseconds, to wait before starting the animation playing. + * + * @return {this} This Game Object. + */ + playAfterDelay: function (key, delay) + { + return this.anims.playAfterDelay(key, delay); + }, + + /** + * Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback + * of the given animation. + * + * You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an + * idle animation to a walking animation, by making them blend smoothly into each other. + * + * If no animation is currently running, the given one will start immediately. + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * @method Phaser.GameObjects.Sprite#playAfterRepeat + * @fires Phaser.Animations.Events#ANIMATION_START + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param {number} [repeatCount=1] - How many times should the animation repeat before the next one starts? + * + * @return {this} This Game Object. + */ + playAfterRepeat: function (key, repeatCount) + { + return this.anims.playAfterRepeat(key, repeatCount); + }, + + /** + * Sets an animation, or an array of animations, to be played immediately after the current one completes or stops. + * + * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, + * or have the `stop` method called directly on it. + * + * An animation set to repeat forever will never enter a completed state. + * + * You can chain a new animation at any point, including before the current one starts playing, during it, + * or when it ends (via its `animationcomplete` event). + * + * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained + * animations without impacting the animation they're playing. + * + * Call this method with no arguments to reset all currently chained animations. + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * @method Phaser.GameObjects.Sprite#chain + * @since 3.50.0 + * + * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig|string[]|Phaser.Animations.Animation[]|Phaser.Types.Animations.PlayAnimationConfig[])} [key] - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object, or an array of them. + * + * @return {this} This Game Object. + */ + chain: function (key) + { + return this.anims.chain(key); + }, + + /** + * Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` events. + * + * If no animation is playing, no event will be dispatched. + * + * If there is another animation queued (via the `chain` method) then it will start playing immediately. + * + * @method Phaser.GameObjects.Sprite#stop + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.50.0 + * + * @return {this} This Game Object. + */ + stop: function () + { + return this.anims.stop(); + }, + + /** + * Stops the current animation from playing after the specified time delay, given in milliseconds. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * + * @method Phaser.GameObjects.Sprite#stopAfterDelay + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.50.0 + * + * @param {number} delay - The number of milliseconds to wait before stopping this animation. + * + * @return {this} This Game Object. + */ + stopAfterDelay: function (delay) + { + return this.anims.stopAfterDelay(delay); + }, + + /** + * Stops the current animation from playing after the given number of repeats. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * + * @method Phaser.GameObjects.Sprite#stopAfterRepeat + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.50.0 + * + * @param {number} [repeatCount=1] - How many times should the animation repeat before stopping? + * + * @return {this} This Game Object. + */ + stopAfterRepeat: function (repeatCount) + { + return this.anims.stopAfterRepeat(repeatCount); + }, + + /** + * Stops the current animation from playing when it next sets the given frame. + * If this frame doesn't exist within the animation it will not stop it from playing. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * + * @method Phaser.GameObjects.Sprite#stopOnFrame + * @fires Phaser.Animations.Events#ANIMATION_STOP + * @since 3.50.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - The frame to check before stopping this animation. + * + * @return {this} This Game Object. + */ + stopOnFrame: function (frame) + { + return this.anims.stopOnFrame(frame); + }, + + /** + * Build a JSON representation of this Sprite. + * + * @method Phaser.GameObjects.Sprite#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + return Components.ToJSON(this); + }, + + /** + * Handles the pre-destroy step for the Sprite, which removes the Animation component. + * + * @method Phaser.GameObjects.Sprite#preDestroy + * @private + * @since 3.14.0 + */ + preDestroy: function () + { + this.anims.destroy(); + + this.anims = undefined; + } + +}); + +module.exports = Sprite; + + +/***/ }, + +/***/ 76552 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + camera.addToRenderList(src); + + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = SpriteCanvasRenderer; + + +/***/ }, + +/***/ 15567 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var BuildGameObjectAnimation = __webpack_require__(13059); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Sprite = __webpack_require__(68287); + +/** + * Creates a new Sprite Game Object and returns it. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene=true] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectCreator.register('sprite', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + return sprite; +}); + + +/***/ }, + +/***/ 46409 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectFactory = __webpack_require__(39429); +var Sprite = __webpack_require__(68287); + +/** + * Creates a new Sprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectFactory.register('sprite', function (x, y, texture, frame) +{ + return this.displayList.add(new Sprite(this.scene, x, y, texture, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 92751 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(9409); +} + +if (true) +{ + renderCanvas = __webpack_require__(76552); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 9409 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + drawingContext.camera.addToRenderList(src); + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext, + src, + parentMatrix, + 0, + customRenderNodes.Texturer || defaultRenderNodes.Texturer, + customRenderNodes.Transformer || defaultRenderNodes.Transformer + ); +}; + +module.exports = SpriteWebGLRenderer; + + +/***/ }, + +/***/ 18207 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Easing function identifiers. + * + * @ignore + */ +var EasingEncoding = { + None: 0, + + Power0: 1, + Power1: 10, + Power2: 20, + Power3: 30, + Power4: 40, + Linear: 1, + + Gravity: 2, + + Quad: 10, + 'Quad.easeOut': 10, + 'Quad.easeIn': 11, + 'Quad.easeInOut': 12, + + Cubic: 20, + 'Cubic.easeOut': 20, + 'Cubic.easeIn': 21, + 'Cubic.easeInOut': 22, + + Quart: 30, + 'Quart.easeOut': 30, + 'Quart.easeIn': 31, + 'Quart.easeInOut': 32, + + Quint: 40, + 'Quint.easeOut': 40, + 'Quint.easeIn': 41, + 'Quint.easeInOut': 42, + + Sine: 50, + 'Sine.easeOut': 50, + 'Sine.easeIn': 51, + 'Sine.easeInOut': 52, + + Expo: 60, + 'Expo.easeOut': 60, + 'Expo.easeIn': 61, + 'Expo.easeInOut': 62, + + Circ: 70, + 'Circ.easeOut': 70, + 'Circ.easeIn': 71, + 'Circ.easeInOut': 72, + + // // Elastic requires extra parameters, so we skip it. + // Elastic: 80, + // 'Elastic.easeOut': 80, + // 'Elastic.easeIn': 81, + // 'Elastic.easeInOut': 82, + + Back: 90, + 'Back.easeOut': 90, + 'Back.easeIn': 91, + 'Back.easeInOut': 92, + + Bounce: 100, + 'Bounce.easeOut': 100, + 'Bounce.easeIn': 101, + 'Bounce.easeInOut': 102, + + // Stepped could require extra parameters, but we assume just 2. + Stepped: 110, + + Smoothstep: 120, + 'Smoothstep.easeOut': 120, + 'Smoothstep.easeIn': 121, + 'Smoothstep.easeInOut': 122 +}; + +module.exports = EasingEncoding; + + +/***/ }, + +/***/ 68218 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var EasingEncoding = __webpack_require__(18207); + +/** + * Easing function identifiers. + * This is a reverse mapping of EasingEncoding, + * mapping numbers to their string names. + * + * @ignore + */ +var EasingNaming = {}; + +var animations = Object.keys(EasingEncoding); +var animLen = animations.length; + +for (var i = 0; i < animLen; i++) +{ + var key = animations[i]; + var value = EasingEncoding[key]; + EasingNaming[value] = key; +} + +module.exports = EasingNaming; + + +/***/ }, + +/***/ 76573 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var MapStruct = __webpack_require__(90330); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var SubmitterSpriteGPULayer = __webpack_require__(53384); +var Utils = __webpack_require__(70554); +var EasingEncoding = __webpack_require__(18207); +var EasingNaming = __webpack_require__(68218); +var SpriteGPULayerRender = __webpack_require__(71238); + +var getTint = Utils.getTintAppendFloatAlpha; + +/** + * @classdesc + * A SpriteGPULayer GameObject. This is a WebGL only GameObject. + * It is optimized for rendering very large numbers of quads + * following simple tween animations. + * It is suited to complex backgrounds with animation. + * + * A SpriteGPULayer is a composite object that contains a collection of + * Member objects. It stores the rendering data for these + * objects in a GPU buffer, and renders them in a single draw call. + * Because it only updates the GPU buffer when necessary, + * it is up to 100 times faster than rendering the objects individually. + * Avoid changing the contents of the SpriteGPULayer frequently, as this + * requires the whole buffer to be updated. + * + * The layer can generally perform well with a million small quads. + * The exact performance will depend on the device and the size of the quads. + * If the quads are large, the layer will be fill-rate limited. + * Avoid drawing more than a few million pixels per frame. + * + * When populating the SpriteGPULayer, use `addMember` to add a new member + * to the top of the layer. You should populate the layer all at once, + * and leave it unchanged, rather than frequently adding and removing members, + * because it is expensive to update the buffer. + * + * Rather than create a new `SpriteGPULayer.Member` object for each `addMember` call, + * you can reuse the same object. This is more efficient, + * because creating millions of objects has a major performance cost + * and may cause garbage collection issues. + * + * Notes on modifying the SpriteGPULayer: + * + * The following operations are expensive. They require some or all of the + * buffer to be updated: + * + * - `addData` + * - `addMember` + * - `editMember` + * - `patchMember` + * - `resize` + * - `removeMembers` + * + * Members are added at the end of the buffer. Removed members are spliced out + * of the buffer, causing the whole buffer to be updated. + * The index of later members will change if you remove an earlier member. + * If you need to maintain a structure, such as a grid of tiles, + * it's best to "remove" a member by setting its scaleX, scaleY, and alpha to 0. + * It is still rendered, but it does not fill any pixels. + * + * Changes to a small segment of the buffer are less expensive. + * The buffer is split into several segments, and each segment can be updated + * independently. Editing and patching members will only update the segments + * that contain the members being edited. + * Updating occurs at render time, so edits all happen at once. + * This can reduce the amount of data that needs to be updated, + * but it is still more expensive than not updating the buffer at all. + * If you're updating a large number of segments, it may be more efficient + * to call `setAllSegmentsNeedUpdate` and update the whole buffer at once + * rather than make several segment updates in a row. + * + * The animations in the initial member data are used to compile the shader + * and `frameDataTexture`. If you add new animations after the initial + * compilation, the shader and texture will be rebuilt, which is expensive. + * + * Notes on textures: + * + * This layer gains much of its speed from inflexibility. It can only use one + * texture, and that texture must be a single image. + * It cannot use multi-atlas textures. + * + * Further, if the texture is not a power of two in size, + * some texture seaming may occur if you line up sprites exactly. + * This is because the GPU precision is limited by binary logic, + * and texture coordinates will only be perfectly accurate for power of two textures. + * This can be avoided by adding/extruding a pixel of padding around each frame + * in the texture, or by using a power of two texture. + * + * Which should you use? + * + * - If you are using pixel art mode or round pixels, + * you should aim to use a power of two texture. + * - If you are using smooth mode, you can use a non-power of two texture, + * but you should add padding around each frame to avoid seaming. + * - If you are using a single image, or none of the frames in the texture + * need to tile, it doesn't matter. + * + * @class SpriteGPULayer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @webglOnly + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.ElapseTimer + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Visible + * + * @constructor + * @since 4.0.0 + * @param {Phaser.Scene} scene - The Scene to which this SpriteGPULayer belongs. + * @param {Phaser.Textures.Texture} texture - The texture that will be used to render the SpriteGPULayer. This must be sourced from a single image; a multi atlas will not work. + * @param {number} size - The maximum number of quads that this SpriteGPULayer will hold. This can be increased later if necessary. + */ +var SpriteGPULayer = new Class({ + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.ElapseTimer, + Components.Lighting, + Components.RenderNodes, + Components.TextureCrop, + Components.Visible, + SpriteGPULayerRender + ], + + initialize: function SpriteGPULayer (scene, texture, size) + { + GameObject.call(this, scene, 'SpriteGPULayer'); + + /** + * The number of quad members in the SpriteGPULayer. + * + * @name Phaser.GameObjects.SpriteGPULayer#memberCount + * @type {number} + * @since 4.0.0 + */ + this.memberCount = 0; + + /** + * The maximum number of quad members that can be in the SpriteGPULayer. + * This value is read-only. Change buffer size with `resize`. + * + * @name Phaser.GameObjects.SpriteGPULayer#size + * @type {number} + * @since 4.0.0 + * @readonly + */ + this.size = Math.max(size, 0); + + /** + * The number of segments in the buffer. + * This helps to optimize buffer updates by dividing them into smaller segments. + * This is a constant value and should not be altered. + * If you do, all hell will break loose. + * + * Segments divide the buffer into sequential chunks. + * Only updated segments will be uploaded to the GPU. + * Each upload has a fixed cost, but reducing the total amount of data + * can improve performance. + * + * Don't change this value to anything higher than 31. + * Segment logic uses bitwise operations, which are limited to 32 bits, + * so going that high will cause overflows and break everything. + * + * @name Phaser.GameObjects.SpriteGPULayer#_segments + * @type {number} + * @since 4.0.0 + * @readonly + * @private + */ + this._segments = 24; + + /** + * The state of `bufferUpdateSegments` when it's full. + * This is a constant value and should not be altered. + * If you do, all hell will break loose. + * + * @name Phaser.GameObjects.SpriteGPULayer#MAX_BUFFER_UPDATE_SEGMENTS_FULL + * @type {number} + * @since 4.0.0 + * @readonly + * @default 0xffffff + */ + this.MAX_BUFFER_UPDATE_SEGMENTS_FULL = 0xffffff; + + /** + * Which segments of the buffer require updates. + * This is a bitfield with segments equal to `_segments`. + * + * @name Phaser.GameObjects.SpriteGPULayer#bufferUpdateSegments + * @type {number} + * @since 4.0.0 + */ + this.bufferUpdateSegments = 0; + + /** + * The size of each segment of the buffer that requires updates. + * + * @name Phaser.GameObjects.SpriteGPULayer#bufferUpdateSegmentSize + * @type {number} + * @since 4.0.0 + */ + this.bufferUpdateSegmentSize = Math.ceil(this.size / this._segments); + + /** + * The gravity used by member animations in 'Gravity' mode. + * This is the acceleration in pixels per second squared. + * The default is 1024 pixels per second squared. + * + * Any animation can be set to `ease: 'Gravity'` to use this value. + * Instead of `amplitude`, the animation takes + * `velocity` (a number of pixels) and + * `gravityFactor` (-1 to 1) parameters. + * Note that a `gravityFactor` of 0 is assumed to be a mistake, + * and will be converted to 1. + * + * @name Phaser.GameObjects.SpriteGPULayer#gravity + * @type {number} + * @since 4.0.0 + * @default 1024 + */ + this.gravity = 1024; + + /** + * The animations enabled for the SpriteGPULayer. + * This is a map of animation names from `this.EASE` to boolean values. + * Adjust these values with `setAnimationEnabled`. + * + * @name Phaser.GameObjects.SpriteGPULayer#_animationsEnabled + * @type {object} + * @since 4.0.0 + * @private + */ + this._animationsEnabled = {}; + + var animations = Object.keys(EasingEncoding); + var animLen = animations.length; + for (var i = 0; i < animLen; i++) + { + this._animationsEnabled[animations[i]] = false; + } + + /** + * Strings for valid easing functions that can be assigned to + * the `ease` property of an SpriteGPULayerMemberAnimation. + * This is the reverse mapping of `this.EASE_CODES`. + * + * @name Phaser.GameObjects.SpriteGPULayer#EASE + * @type {object} + * @since 4.0.0 + * @readonly + */ + this.EASE = EasingEncoding; + + /** + * Codes for valid easing functions that can be assigned to + * the `ease` property of an SpriteGPULayerMemberAnimation. + * This is the reverse mapping of `this.EASE`. + * + * @name Phaser.GameObjects.SpriteGPULayer#EASE_CODES + * @type {object} + * @since 4.0.0 + * @readonly + */ + this.EASE_CODES = EasingNaming; + + this.setTexture(texture); + this.initRenderNodes(new MapStruct()); + + /** + * A texture containing the frame data for the SpriteGPULayer. + * This is used by the vertex shader. + * + * The texture is composed of pixel strides, where each stride + * is interpreted as 6 16-bit unsigned integers, + * representing the x, y, width, height, and origin x and y of a frame. + * The texture will be up to 4096 pixels wide and as tall as necessary. + * + * There are two sets of data in the texture: frames and animations. + * Frames are taken from the `texture`. + * Animations are defined by calling `setAnimations`, + * and consist of runs of frames suited to shader animation. + * Although the texture will be regenerated by `setAnimations`, + * the frames are stored first, so their indices won't change. + * + * If you change the `texture` of this layer, you will need to + * regenerate this by calling `generateFrameDataTexture`. + * + * @name Phaser.GameObjects.SpriteGPULayer#frameDataTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 4.0.0 + */ + this.frameDataTexture = null; + + /** + * A map of frame names to indices in the frame data texture. + * This is used to convert frame names to indices for the vertex shader. + * + * @name Phaser.GameObjects.SpriteGPULayer#frameDataIndices + * @type {object} + * @since 4.0.0 + */ + this.frameDataIndices = {}; + + /** + * A map of indices to frame names in the frame data texture. + * This is used to convert frame indices back to names for debugging. + * + * @name Phaser.GameObjects.SpriteGPULayer#frameDataIndicesInv + * @type {object} + * @since 4.0.0 + */ + this.frameDataIndicesInv = {}; + + /** + * An ordered list of animations in the frame data texture. + * + * @name Phaser.GameObjects.SpriteGPULayer#animationData + * @type {object[]} + * @since 4.0.0 + */ + this.animationData = []; + + /** + * A map of animation names to animation parameters in + * the frame data texture. + * This is used to convert animation names to indices and durations + * for the vertex shader. + * + * @name Phaser.GameObjects.SpriteGPULayer#animationDataNames + * @type {object} + * @since 4.0.0 + */ + this.animationDataNames = {}; + + /** + * A map of frame indices to animation parameters in + * the frame data texture. + * These are the starting frame indices used by the vertex shader. + * They can be used to map back to names in `animationDataIndices`. + * + * @name Phaser.GameObjects.SpriteGPULayer#animationDataIndices + * @type {object} + * @since 4.0.0 + */ + this.animationDataIndices = {}; + + this.generateFrameDataTexture(); + + /** + * The SubmitterSpriteGPULayer RenderNode for this SpriteGPULayer. + * + * This handles rendering the SpriteGPULayer to the GPU. + * It is created automatically when the SpriteGPULayer is initialized. + * Most RenderNodes are singletons stored in the RenderNodeManager, + * but because this one holds very specific data, + * it is stored in the SpriteGPULayer itself. + * + * @name Phaser.GameObjects.SpriteGPULayer#submitterNode + * @type {Phaser.Renderer.WebGL.RenderNodes.SubmitterSpriteGPULayer} + * @since 4.0.0 + */ + this.submitterNode = new SubmitterSpriteGPULayer(scene.renderer.renderNodes, {}, this); + + this.defaultRenderNodes['Submitter'] = this.submitterNode; + this.renderNodeData[this.submitterNode.name] = {}; + + this.resize(this.size); + + /** + * The next member buffer, used to store member data + * before it is added to the GPU buffer. + * + * @name Phaser.GameObjects.SpriteGPULayer#nextMember + * @type {ArrayBuffer} + * @since 4.0.0 + */ + this.nextMember = new ArrayBuffer(this.getDataByteSize()); + + /** + * A Float32Array view of the next member buffer. + * + * @name Phaser.GameObjects.SpriteGPULayer#nextMemberF32 + * @type {Float32Array} + * @since 4.0.0 + */ + this.nextMemberF32 = new Float32Array(this.nextMember); + + /** + * A Uint32Array view of the next member buffer. + * This is used to write 32-bit integer data to the buffer. + * It is used for color data. + * + * @name Phaser.GameObjects.SpriteGPULayer#nextMemberU32 + * @type {Uint32Array} + * @since 4.0.0 + */ + this.nextMemberU32 = new Uint32Array(this.nextMember); + }, + + /** + * Called when this SpriteGPULayer is added to a Scene. + * Registers it with the Scene's update list so it receives `preUpdate` calls each frame. + * + * @method Phaser.GameObjects.SpriteGPULayer#addedToScene + * @since 4.0.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Called when this SpriteGPULayer is removed from a Scene. + * Deregisters it from the Scene's update list so it no longer receives `preUpdate` calls. + * + * @method Phaser.GameObjects.SpriteGPULayer#removedFromScene + * @since 4.0.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * The update step for this SpriteGPULayer, called each frame by the Scene. + * Advances the internal elapsed timer used for member animations. + * + * @method Phaser.GameObjects.SpriteGPULayer#preUpdate + * @since 4.0.0 + * @param {number} time - The current timestamp, as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in milliseconds, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.updateTimer(time, delta); + }, + + /** + * Get the number of bytes used to define a member. + * If you are directly editing the buffer, you will need this value + * as a 'stride' to move through the buffer. + * + * @method Phaser.GameObjects.SpriteGPULayer#getDataByteSize + * @since 4.0.0 + * @return {number} The number of bytes used for each member. + */ + getDataByteSize: function () + { + return this.submitterNode.instanceBufferLayout.layout.stride; + }, + + /** + * Return a list of features to enable in the shader program. + * This is used when the shader program is compiled. + * + * @method Phaser.GameObjects.SpriteGPULayer#getShaderFeatures + * @since 4.0.0 + * @return {string[]} An array of features to enable in the shader program. + */ + getShaderFeatures: function () + { + var features = []; + + // Add enabled animations. + var animations = Object.keys(this._animationsEnabled); + var animLen = animations.length; + for (var i = 0; i < animLen; i++) + { + if (this._animationsEnabled[animations[i]]) + { + features.push(animations[i]); + } + } + + return features; + }, + + /** + * Set the animations available to the SpriteGPULayer. + * This will call `generateFrameDataTexture` to regenerate + * `frameDataTexture`. + * + * Each animation can be either an Animation object, or an object + * containing a name, duration, and an array of frame names/numbers. + * If an Animation is used, it will be converted to the object form, + * discarding any custom individual frame durations + * and using the animation's duration as default. + * + * This is not a Phaser Animation. It is intended to cycle automatically + * on the GPU without supervision or interaction. It will not emit events, + * allow you to pause the animation, set number of repeats, etc. + * + * @method Phaser.GameObjects.SpriteGPULayer#setAnimations + * @since 4.0.0 + * @param {Phaser.Animations.Animation[]|Phaser.Types.GameObjects.SpriteGPULayer.SetAnimation[]} animations - An array of animations to set. + * @return {this} This SpriteGPULayer object. + */ + setAnimations: function (animations) + { + var animLen = animations.length; + + // Animation frames will start after the texture frames. + var frameNames = this.texture.getFrameNames(true); + var index = frameNames.length; + + for (var i = 0; i < animLen; i++) + { + var anim = animations[i]; + var data = {}; + if (anim.key) + { + // This is a Phaser.Animations.Animation class. + data.name = anim.key; + data.duration = anim.duration; + data.frames = anim.frames; + } + else + { + data.name = anim.name; + data.duration = anim.duration; + data.frames = anim.frames.slice(); + } + + // Add frame indexing data. + data.index = index; + data.frameCount = data.frames.length; + index += data.frameCount; + + // Store animation. + this.animationData.push(data); + this.animationDataNames[data.name] = data; + this.animationDataIndices[data.index] = data; + } + + this.generateFrameDataTexture(); + + return this; + }, + + /** + * Generate `frameDataTexture` for the SpriteGPULayer. + * This is used by the vertex shader to access frame data. + * + * @method Phaser.GameObjects.SpriteGPULayer#generateFrameDataTexture + * @since 4.0.0 + */ + generateFrameDataTexture: function () + { + // Get the frame data. + var texture = this.texture; + var frames = texture.getFrameNames(true); + var frameLen = frames.length; + + // Update the frame data indices. + this.frameDataIndices = {}; + this.frameDataIndicesInv = {}; + for (var i = 0; i < frameLen; i++) + { + var frameName = frames[i]; + var frame = texture.get(frameName); + this.frameDataIndices[frameName] = i; + this.frameDataIndicesInv[i] = frameName; + } + + // Append frames from animations. + var anims = this.animationData; + var animsLen = anims.length; + for (i = 0; i < animsLen; i++) + { + var anim = this.animationData[i]; + var frameCount = anim.frameCount; + for (var j = 0; j < frameCount; j++) + { + frames.push(anim.frames[j]); + } + } + + frameLen = frames.length; + var valuesPerFrame = 3; + var pixelCount = frameLen * valuesPerFrame; + var width = Math.min(pixelCount, 4096); + var height = Math.ceil(pixelCount / 4096); + var dataSize = width * height * 4; + + var textureManager = texture.manager; + + // Generate a Uint8Array with the frame data. + var data = new ArrayBuffer(dataSize); + var u16 = new Uint16Array(data); + var u8 = new Uint8Array(data); + for (i = 0; i < frameLen; i++) + { + var animFrame = frames[i]; + if (typeof animFrame === 'string') + { + frame = texture.get(frames[i]); + } + else if (animFrame && animFrame.key !== undefined) + { + // animFrame comes from a SetAnimation object. + var animTexture = textureManager.get(animFrame.key); + frame = animTexture.get(animFrame.frame); + } + else + { + // animFrame is an AnimationFrame object. + frame = animFrame.frame; + } + + var offset = i * valuesPerFrame * u16.BYTES_PER_ELEMENT; + + // Position + u16[offset] = frame.cutX; + u16[offset + 1] = frame.cutY; + + // Size + u16[offset + 2] = frame.cutWidth; + u16[offset + 3] = frame.cutHeight; + + // Pivot offset + // Multiplied by the size to convert to pixels. + // Offset by 32768 to effectively store as a 16-bit signed integer. + var pivotX = 0.5; + var pivotY = 0.5; + if (frame.customPivot) + { + pivotX = frame.pivotX; + pivotY = frame.pivotY; + } + u16[offset + 4] = Math.round((pivotX - 0.5) * frame.cutWidth) + 32768; + u16[offset + 5] = Math.round((pivotY - 0.5) * frame.cutHeight) + 32768; + } + + // Create or update a texture with the frame data. + if (this.frameDataTexture) + { + this.frameDataTexture.destroy(); + } + this.frameDataTexture = this.scene.renderer.createUint8ArrayTexture(u8, width, height, false, false); + }, + + /** + * Resizes the SpriteGPULayer buffer to a new size. + * Optionally, clears the buffer. + * + * This is an expensive operation, as it requires the whole buffer to be updated. + * It can take many frames to complete. + * + * @method Phaser.GameObjects.SpriteGPULayer#resize + * @since 4.0.0 + * @param {number} count - The new number of members in the SpriteGPULayer. + * @param {boolean} [clear=false] - Whether to clear the buffer. + * @return {this} This SpriteGPULayer object. + */ + resize: function (count, clear) + { + var layout = this.submitterNode.instanceBufferLayout; + var buffer = layout.buffer; + var u8 = buffer.viewU8; + var targetByteSize = count * layout.layout.stride; + + this.size = count; + + buffer.resize(targetByteSize); + + if (clear) + { + this.memberCount = 0; + } + else + { + // Copy data from the old buffer to the new buffer. + var newBuffer = buffer.viewU8; + newBuffer.set(u8.subarray(0, Math.min(newBuffer.byteLength, targetByteSize))); + this.memberCount = Math.min(this.memberCount, count); + } + + this.bufferUpdateSegmentSize = Math.ceil(this.size / this._segments); + this.setAllSegmentsNeedUpdate(); + + return this; + }, + + /** + * Sets a segment of the buffer to require an update. + * + * @method Phaser.GameObjects.SpriteGPULayer#setSegmentNeedsUpdate + * @since 4.0.0 + * @param {number} index - The index at which an update occurred, which requires the segment to be updated. + */ + setSegmentNeedsUpdate: function (index) + { + if ( + index < 0 || + index >= this.size || + this.bufferUpdateSegments === this.MAX_BUFFER_UPDATE_SEGMENTS_FULL + ) + { + return; + } + var segment = Math.floor(index / this.bufferUpdateSegmentSize); + this.bufferUpdateSegments |= (1 << segment); + }, + + /** + * Sets all segments of the buffer to require an update. + * + * @method Phaser.GameObjects.SpriteGPULayer#setAllSegmentsNeedUpdate + * @since 4.0.0 + */ + setAllSegmentsNeedUpdate: function () + { + this.bufferUpdateSegments = this.MAX_BUFFER_UPDATE_SEGMENTS_FULL; + }, + + /** + * Clears all segments of the buffer that require an update. + * + * @method Phaser.GameObjects.SpriteGPULayer#clearAllSegmentsNeedUpdate + * @since 4.0.0 + */ + clearAllSegmentsNeedUpdate: function () + { + this.bufferUpdateSegments = 0; + }, + + /** + * Adds data to the SpriteGPULayer buffer. + * It is inserted at the end of the buffer. + * + * This is mostly used internally by the SpriteGPULayer. + * It takes raw data as a buffer, which is very efficient, + * but `addMember` is easier to use. + * + * Note that, if you add a member with an animation, + * the animation must either already be enabled, + * or you must enable it with `setAnimationEnabled`, + * e.g. `layer.setAnimationEnabled('Linear', true)` or + * `layer.setAnimationEnabled(layer.EASE_CODES[layer.EASE.Linear], true)`. + * + * This is a buffer modification, and is expensive. + * + * @method Phaser.GameObjects.SpriteGPULayer#addData + * @since 4.0.0 + * @param {Float32Array} member - The raw data to add to the buffer. + * @return {this} This SpriteGPULayer object. + */ + addData: function (member) + { + if (this.memberCount >= this.size) + { + return this; + } + + var layout = this.submitterNode.instanceBufferLayout; + var f32 = layout.buffer.viewF32; + var offset = this.memberCount * layout.layout.stride; + + f32.set(member, offset / f32.BYTES_PER_ELEMENT); + + this.setSegmentNeedsUpdate(this.memberCount); + this.memberCount++; + + return this; + }, + + /** + * Adds a member to the SpriteGPULayer. + * This is the easiest way to add a member to the SpriteGPULayer. + * + * This is a buffer modification, and is expensive. + * + * @method Phaser.GameObjects.SpriteGPULayer#addMember + * @since 4.0.0 + * @param {Partial} [member] - The member to add to the SpriteGPULayer. + * @return {this} This SpriteGPULayer object. + */ + addMember: function (member) + { + if (this.memberCount >= this.size) + { + return this; + } + + var f32 = this.nextMemberF32; + var u32 = this.nextMemberU32; + + if (!member) + { + member = {}; + } + + var frame = this.frame; + if (member.frame !== undefined) + { + frame = member.frame.base ? member.frame.base : member.frame; + } + if (typeof frame === 'string') + { + frame = this.texture.get(frame); + + if (!frame) + { + return this; + } + } + + var offset = 0; + + this._setAnimatedValue(member.x, offset); + offset += 4; + + this._setAnimatedValue(member.y, offset); + offset += 4; + + this._setAnimatedValue(member.rotation, offset); + offset += 4; + + this._setAnimatedValue(member.scaleX, offset, 1); + offset += 4; + + this._setAnimatedValue(member.scaleY, offset, 1); + offset += 4; + + this._setAnimatedValue(member.alpha, offset, 1); + offset += 4; + + var animation = member.animation; + if (animation) + { + // Use frame animation. + var animData; + if ( + (typeof animation === 'string') || + (typeof animation === 'number') + ) + { + if (typeof animation === 'string') + { + animData = this.animationDataNames[animation]; + } + else + { + animData = this.animationDataIndices[animation]; + } + this._setAnimatedValue({ + base: animData.index, + amplitude: animData.frameCount, + duration: animData.duration, + ease: EasingEncoding.Linear, + yoyo: false + }, offset); + } + else + { + var base = animation.base; + if (typeof base === 'string') + { + animData = this.animationDataNames[base]; + } + else if (typeof base === 'number') + { + animData = this.animationDataIndices[base]; + } + else + { + // Bad data; fall back to first animation. + animData = this.animationData[0]; + } + this._setAnimatedValue({ + base: animData.index, + amplitude: (typeof animation.amplitude === 'number') ? animation.amplitude : animData.frameCount, + duration: animation.duration || animData.duration, + delay: animation.delay || 0, + ease: animation.ease || EasingEncoding.Linear, + yoyo: !!animation.yoyo + }, offset); + } + } + else + { + // Use single frame. + var frameIndex = this.frameDataIndices[frame.name]; + var memberFrame = member.frame; + if (memberFrame && memberFrame.base !== undefined) + { + this._setAnimatedValue({ + base: frameIndex, + amplitude: memberFrame.amplitude, + duration: memberFrame.duration, + delay: memberFrame.delay, + ease: memberFrame.ease, + yoyo: memberFrame.yoyo + }, offset); + } + else + { + this._setAnimatedValue(frameIndex, offset); + } + } + offset += 4; + + this._setAnimatedValue(member.tintBlend, offset, 1); + offset += 4; + + var tintBottomLeft = member.tintBottomLeft === undefined ? 0xffffff : member.tintBottomLeft; + var tintTopLeft = member.tintTopLeft === undefined ? 0xffffff : member.tintTopLeft; + var tintBottomRight = member.tintBottomRight === undefined ? 0xffffff : member.tintBottomRight; + var tintTopRight = member.tintTopRight === undefined ? 0xffffff : member.tintTopRight; + + var alphaBottomLeft = member.alphaBottomLeft === undefined ? 1 : member.alphaBottomLeft; + var alphaTopLeft = member.alphaTopLeft === undefined ? 1 : member.alphaTopLeft; + var alphaBottomRight = member.alphaBottomRight === undefined ? 1 : member.alphaBottomRight; + var alphaTopRight = member.alphaTopRight === undefined ? 1 : member.alphaTopRight; + + u32[offset++] = getTint( + tintBottomLeft, + alphaBottomLeft + ); + u32[offset++] = getTint( + tintTopLeft, + alphaTopLeft + ); + u32[offset++] = getTint( + tintBottomRight, + alphaBottomRight + ); + u32[offset++] = getTint( + tintTopRight, + alphaTopRight + ); + + f32[offset++] = member.originX === undefined ? 0.5 : member.originX; + f32[offset++] = member.originY === undefined ? 0.5 : member.originY; + + f32[offset++] = member.tintMode || 0; + + f32[offset++] = member.creationTime === undefined ? this.timeElapsed : member.creationTime; + + f32[offset++] = member.scrollFactorX === undefined ? 1 : member.scrollFactorX; + f32[offset++] = member.scrollFactorY === undefined ? 1 : member.scrollFactorY; + + this.addData(this.nextMemberF32); + + return this; + }, + + /** + * Edits a member of the SpriteGPULayer. + * This will update the member's data in the GPU buffer. + * Only the buffer segment containing the target member will be marked for update, + * making this less expensive than a full buffer update. + * + * @method Phaser.GameObjects.SpriteGPULayer#editMember + * @since 4.0.0 + * @param {number} index - The index of the member to edit. + * @param {Partial} member - The new member data. + * @return {this} This SpriteGPULayer object. + */ + editMember: function (index, member) + { + if (index < 0 || index >= this.memberCount) + { + return this; + } + + var currentMemberCount = this.memberCount; + this.memberCount = index; + this.addMember(member); + this.memberCount = currentMemberCount; + + return this; + }, + + /** + * Update a member of the SpriteGPULayer with raw data. + * This will update the member's data in the GPU buffer. + * Only the buffer segment containing the target member will be marked for update, + * making this less expensive than a full buffer update. + * + * You can supply a mask to control which properties are updated. + * This can be useful for updating only a subset of properties. + * Try using `getMemberData` to copy an existing member's data, + * then modify the data you want to change. + * + * The data must be passed in as an Uint32Array. + * This will preserve data that other TypedArrays would not. + * As it uses an underlying ArrayBuffer, you can work on the data + * with any TypedArray view before submitting it. + * + * @method Phaser.GameObjects.SpriteGPULayer#patchMember + * @since 4.0.0 + * @param {number} index - The index of the member to patch. + * @param {Uint32Array} member - The new member data. + * @param {number[]} [mask] - The mask to apply to the member data. A value of 1 will update the member data, a value of 0 will keep the existing member data. + */ + patchMember: function (index, member, mask) + { + if (index < 0 || index >= this.memberCount) + { + return; + } + + var layout = this.submitterNode.instanceBufferLayout; + var buffer = layout.buffer; + var stride = layout.layout.stride; + var byteOffset = index * stride; + var u32 = buffer.viewU32; + + var offset = byteOffset / 4; + + if (mask) + { + for (var i = 0; i < member.length; i++) + { + if (mask[i]) + { + u32[offset + i] = member[i]; + } + } + } + else + { + u32.set(member, offset); + } + + this.setSegmentNeedsUpdate(index); + }, + + /** + * Returns a member of the SpriteGPULayer. + * + * This returns an object copied from the buffer. + * Editing it will not change anything in the SpriteGPULayer. + * The object will be functionally identical to the data used to + * create the buffer, but some values may be different. + * + * - Properties that support animation, but have no amplitude or duration or have easing 'None' (0), will be presented as numbers. + * - Animation easing values will be presented as numbers (the values + * in `this.EASE`). + * - Animation delay values will be normalized to the duration, + * e.g. a delay of 150 with a duration of 100 will return 50. + * - Some rounding may occur due to floating point precision. + * + * @method Phaser.GameObjects.SpriteGPULayer#getMember + * @since 4.0.0 + * @param {number} index - The index of the member to get. + * @return {?Phaser.Types.GameObjects.SpriteGPULayer.Member} The member data, or null if the index is out of bounds. + */ + getMember: function (index) + { + if (index < 0 || index >= this.memberCount) + { + return null; + } + + var layout = this.submitterNode.instanceBufferLayout; + var buffer = layout.buffer; + var stride = layout.layout.stride; + var byteOffset = index * stride; + var f32 = buffer.viewF32; + var u32 = buffer.viewU32; + + var member = {}; + + var offset = byteOffset / f32.BYTES_PER_ELEMENT; + + member.x = this._getAnimatedValue(offset); + offset += 4; + + member.y = this._getAnimatedValue(offset); + offset += 4; + + member.rotation = this._getAnimatedValue(offset); + offset += 4; + + member.scaleX = this._getAnimatedValue(offset); + offset += 4; + + member.scaleY = this._getAnimatedValue(offset); + offset += 4; + + member.alpha = this._getAnimatedValue(offset); + offset += 4; + + // Determine frame or animation values. + var frame = this._getAnimatedValue(offset); + offset += 4; + + if (typeof frame !== 'number') + { + frame = frame.base; + } + + // Get name from frame index. + var frameName = this.frameDataIndicesInv[frame]; + if (frameName === undefined) + { + // Get name from animation index. + var animData = this.animationDataIndices[frame]; + if (animData) + { + member.animation = animData.name; + } + } + else + { + member.frame = frameName; + } + + member.tintBlend = this._getAnimatedValue(offset); + offset += 4; + + member.tintBottomLeft = u32[offset++]; + member.tintTopLeft = u32[offset++]; + member.tintBottomRight = u32[offset++]; + member.tintTopRight = u32[offset++]; + member.alphaBottomLeft = (member.tintBottomLeft >>> 24) / 255; + member.alphaTopLeft = (member.tintTopLeft >>> 24) / 255; + member.alphaBottomRight = (member.tintBottomRight >>> 24) / 255; + member.alphaTopRight = (member.tintTopRight >>> 24) / 255; + member.tintBottomLeft &= 0xffffff; + member.tintTopLeft &= 0xffffff; + member.tintBottomRight &= 0xffffff; + member.tintTopRight &= 0xffffff; + + member.originX = f32[offset++]; + member.originY = f32[offset++]; + member.tintMode = f32[offset++]; + member.creationTime = f32[offset++]; + + member.scrollFactorX = f32[offset++]; + member.scrollFactorY = f32[offset++]; + + return member; + }, + + /** + * Returns the raw data of a member of the SpriteGPULayer. + * This can be useful as the base of efficient editing operations, + * including calls to `addData` and `patchMember`, + * so no data has to be converted. + * + * This returns an Uint32Array copied from the buffer. + * Editing it will not change anything in the SpriteGPULayer. + * The array will be functionally identical to the data used to + * create the buffer. + * + * By default, the data is copied into `this.nextMember`. + * You can use the views `this.nextMemberF32` and `this.nextMemberU32` + * to access the data in different formats. + * If you provide an `out` parameter, the data will be copied to that array, + * and you must construct your own views. + * + * The primary data view is a 42-element array of 32-bit floats. + * Some values are grouped to form animations, of the form: + * + * - 0: base value + * - 1: amplitude + * - 2: duration (if negative, the animation will yoyo) + * - 3: delay (the integer part is the easing, the decimal part is the delay divided by 2 * duration; if negative, the animation will not loop) + * + * The overall structure is thus: + * + * - 0-3: x (animation) + * - 4-7: y (animation) + * - 8-11: rotation (animation) + * - 12-15: scaleX (animation) + * - 16-19: scaleY (animation) + * - 20-23: alpha (animation) + * - 24-27: frame index (animation) + * - 28-31: tintBlend (animation) + * - 32-35: no data + * - 36: originX + * - 37: originY + * - 38: tintMode + * - 39: creationTime + * - 40: scrollFactorX + * - 41: scrollFactorY + * + * Elements 32-35 are only visible in the Uint32Array view. + * They store 32-bit RGBA values for the four corners of the tint: + * + * - 32: bottom-left + * - 33: top-left + * - 34: bottom-right + * - 35: top-right + * + * If the ease for an animation is 'Gravity', the amplitude is replaced + * with a two-part value: the integer part is the `velocity`, + * and the fractional part is the remapped `gravityFactor`. + * To get the true `gravityFactor`, use `gravityFactor * 2 - 1` to map from [0,1] to [-1,1]. + * An output `gravityFactor` of 0 actually means 1. + * + * @method Phaser.GameObjects.SpriteGPULayer#getMemberData + * @since 4.0.0 + * @param {number} index - The index of the member to get. + * @param {Uint32Array} [out] - An optional array to copy the data to. If not provided, `this.nextMember` will be populated, and `nextMemberU32` will be returned. + * @return {?Uint32Array} The member data, or null if the index is out of bounds. + */ + getMemberData: function (index, out) + { + if (index < 0 || index >= this.memberCount) + { + return null; + } + + var layout = this.submitterNode.instanceBufferLayout; + var buffer = layout.buffer; + var stride = layout.layout.stride; + var byteOffset = index * stride; + + if (!out) + { + out = this.nextMemberU32; + } + + var viewU32 = buffer.viewU32; + var bytesPerElement = viewU32.BYTES_PER_ELEMENT; + + out.set(viewU32.subarray(byteOffset / bytesPerElement, byteOffset / bytesPerElement + stride / bytesPerElement)); + + return out; + }, + + /** + * Removes a member or a number of members from the SpriteGPULayer. + * This will update the GPU buffer. + * This is an expensive operation, as it requires the whole buffer to be updated. + * + * The buffer is not resized. + * + * @method Phaser.GameObjects.SpriteGPULayer#removeMembers + * @since 4.0.0 + * @param {number} index - The index of the member to remove. + * @param {number} [count=1] - The number of members to remove, default 1. + * @return {this} This SpriteGPULayer object. + */ + removeMembers: function (index, count) + { + if (index < 0 || index >= this.memberCount) + { + return this; + } + + if (count === undefined) + { + count = 1; + } + + count = Math.min(count, this.memberCount - index); + + var layout = this.submitterNode.instanceBufferLayout; + var stride = layout.layout.stride; + var byteOffset = index * stride; + var byteLength = count * stride; + + var u8 = layout.buffer.viewU8; + u8.set(u8.subarray(byteOffset + byteLength), byteOffset); + + // Mark segments for update. + for (var i = index; i < this.memberCount; i += this.bufferUpdateSegmentSize) + { + this.setSegmentNeedsUpdate(i); + } + + // Update layer properties. + this.memberCount -= count; + + return this; + }, + + /** + * Inserts members into the SpriteGPULayer. + * This will update the GPU buffer. + * This is an expensive operation, as it requires the whole buffer to be + * updated after the insertion point. + * + * @method Phaser.GameObjects.SpriteGPULayer#insertMembers + * @since 4.0.0 + * @param {number} index - The index at which to insert members. + * @param {Phaser.Types.GameObjects.SpriteGPULayer.Member|Phaser.Types.GameObjects.SpriteGPULayer.Member[]} members - The members to insert. + * @return {this} This SpriteGPULayer object. + */ + insertMembers: function (index, members) + { + if (index < 0 || index > this.memberCount) + { + return this; + } + + if (!Array.isArray(members)) + { + members = [ members ]; + } + + var oldMemberCount = this.memberCount; + var layout = this.submitterNode.instanceBufferLayout; + var stride = layout.layout.stride; + var byteOffset = index * stride; + var byteLength = members.length * stride; + + // Move the data after the insertion point. + layout.buffer.viewU8.copyWithin( + + // Target + byteOffset + byteLength, + + // Source + byteOffset, + + // End + oldMemberCount * stride + ); + + // Insert members. + this.memberCount = index; + for (var i = 0; i < members.length; i++) + { + this.addMember(members[i]); + } + + this.memberCount = Math.min(this.size, oldMemberCount + members.length); + + // Mark segments for update. + for (i = index; i < this.memberCount; i += this.bufferUpdateSegmentSize) + { + this.setSegmentNeedsUpdate(i); + } + + return this; + }, + + /** + * Inserts raw data into the SpriteGPULayer. + * This will update the GPU buffer. + * This is an expensive operation, as it requires the whole buffer to be + * updated after the insertion point. + * + * The data must be passed in as a Uint32Array. + * This will preserve data that other TypedArrays would not. + * As it uses an underlying ArrayBuffer, you can work on the data + * with any TypedArray view before submitting it. + * + * The buffer can contain 1 or more members. + * Ensure that the buffer is the correct size for the number of members. + * See `getMemberData` for the structure of the data. + * + * Note that, if you add a member with an animation, + * the animation must either already be enabled, + * or you must enable it with `setAnimationEnabled`, + * e.g. `layer.setAnimationEnabled('Linear', true)` or + * `layer.setAnimationEnabled(layer.EASE_CODES[layer.EASE.Linear], true)`. + * + * @method Phaser.GameObjects.SpriteGPULayer#insertMembersData + * @since 4.0.0 + * @param {number} index - The index at which to insert members. + * @param {Uint32Array} data - The members to insert. + * @return {this} This SpriteGPULayer object. + */ + insertMembersData: function (index, data) + { + if (index < 0 || index > this.memberCount) + { + return this; + } + + var byteLength = data.length * data.BYTES_PER_ELEMENT; + var layout = this.submitterNode.instanceBufferLayout; + var stride = layout.layout.stride; + var byteOffset = index * stride; + + // Move the data after the insertion point. + layout.buffer.viewU8.copyWithin( + + // Target + byteOffset + byteLength, + + // Source + byteOffset, + + // End + this.memberCount * stride + ); + + // Insert members. + layout.buffer.viewU32.set(data, byteOffset / data.BYTES_PER_ELEMENT); + + this.memberCount = Math.min(this.size, this.memberCount + byteLength / stride); + + // Mark segments for update. + for (var i = index; i < this.memberCount; i += this.bufferUpdateSegmentSize) + { + this.setSegmentNeedsUpdate(i); + } + + return this; + }, + + /** + * Sets the values of an animation for a member of this SpriteGPULayer. + * The values are set on `nextMember`, used to add data. + * + * @method Phaser.GameObjects.SpriteGPULayer#_setAnimatedValue + * @since 4.0.0 + * @private + * @param {undefined|number|Phaser.Types.GameObjects.SpriteGPULayer.MemberAnimation} value - The value to set. + * @param {number} index - The offset in `nextMember` to write to. + * @param {number} [defaultValue=0] - A default value to use if `value` is undefined. + */ + _setAnimatedValue: function (value, index, defaultValue) + { + var f32 = this.nextMemberF32; + + if (defaultValue === undefined) + { + defaultValue = 0; + } + + if (typeof value === 'number') + { + f32[index++] = value; + f32[index++] = 0; + f32[index++] = 0; + f32[index] = 0; + } + else if (value === undefined) + { + f32[index++] = defaultValue; + f32[index++] = 0; + f32[index++] = 0; + f32[index] = 0; + } + else + { + var base = value.base || 0; + var ease = value.ease || 0; + var amplitude = value.amplitude || 0; + var duration = Math.abs(value.duration || 0); + var delay = value.delay || 0; + var yoyo = value.yoyo !== undefined ? value.yoyo : true; + var loop = value.loop !== undefined ? value.loop : true; + + if (typeof ease === 'string') + { + ease = this.EASE[ease] || 0; + } + + // Enable the chosen animation type. + var easeString = this.EASE_CODES[ease]; + if (!this._animationsEnabled[easeString]) + { + this.setAnimationEnabled(easeString, true); + } + + if (ease === EasingEncoding.Gravity) + { + var velocity = value.velocity || 0; + var gravityFactor = value.gravityFactor || 1; + + if (gravityFactor >= 1) + { + // We encode the factor as a fraction, so we can't encode 1. + // The shader decodes 0 as 1 if Gravity is used. + // This means a value of 0 will be wrongly interpreted, but why set 0? + gravityFactor = 0; + } + else if (gravityFactor < -1) + { + gravityFactor = -0.999; + } + + // Map gravityFactor range [-1,1] to [0,1]. + gravityFactor = (gravityFactor + 1) / 2; + + // Encode values into amplitude. + amplitude = Math.floor(velocity) + gravityFactor; + } + + // Normalize delay. + // We double the range of the delay to allow for yoyo. + if (duration > 0) + { + delay = (delay / duration) % 2; + } + else + { + delay = 0; + } + if (delay < 0) + { + delay += 2; + } + delay /= 2; + + // Add an integer to encode the type. + delay += ease; + + // Encode yoyo in the sign of duration, which must be positive. + if (yoyo) + { + duration = -duration; + } + + // Encode loop in the sign of delay, which must be positive. + if (!loop) + { + delay = -delay; + } + + f32[index++] = base; + f32[index++] = amplitude; + f32[index++] = duration; + f32[index] = delay; + } + }, + + /** + * Return the values of an animation for a member of this SpriteGPULayer + * in the buffer. + * + * @method Phaser.GameObjects.SpriteGPULayer#_getAnimatedValue + * @since 4.0.0 + * @private + * @param {number} index - The index where the animation begins in the buffer. + * @return {number|Phaser.Types.GameObjects.SpriteGPULayer.MemberAnimation} The animation values. + */ + _getAnimatedValue: function (index) + { + var f32 = this.submitterNode.instanceBufferLayout.buffer.viewF32; + + var base = f32[index++]; + var amplitude = f32[index++]; + var duration = f32[index++]; + var delay = f32[index]; + + if (amplitude === 0 || duration === 0 || ease === 0) + { + return base; + } + + var loop = delay > 0; + if (!loop) + { + delay = -delay; + } + + var yoyo = duration < 0; + if (yoyo) + { + duration = -duration; + } + + // Negate ease after duration, so duration has the correct sign. + var ease = Math.floor(delay); + delay -= ease; + delay = (delay * duration * 2) % duration; + + // Check for Gravity mode. + if (ease === EasingEncoding.Gravity) + { + var velocity = Math.floor(amplitude); + var gravityFactor = (amplitude - velocity) * 2 - 1; + if (gravityFactor === 0) + { + gravityFactor = 1; + } + return { + base: base, + ease: ease, + duration: duration, + delay: delay, + yoyo: yoyo, + velocity: velocity, + gravityFactor: gravityFactor + }; + } + + return { + base: base, + ease: ease, + amplitude: amplitude, + duration: duration, + delay: delay, + yoyo: yoyo + }; + }, + + /** + * Set the enabled state of an animation. + * This will enable or disable the animation in the shader program. + * This method is called automatically when animations are added with + * `addMember`, so you should not need to call it manually. + * + * Every enabled animation has a cost in the shader program. + * In particular, low-end devices may be unable to compile a large number + * of animations, so be careful when enabling many animations. + * + * Note that animations are not disabled automatically, + * even if they are not used by any members. + * There are probably too many members for this to be efficient. + * + * @method Phaser.GameObjects.SpriteGPULayer#setAnimationEnabled + * @since 4.0.0 + * @param {string} name - The name of the animation to enable or disable. + * @param {boolean} enabled - Whether to enable or disable the animation. + * @return {this} This SpriteGPULayer object + */ + setAnimationEnabled: function (name, enabled) + { + this._animationsEnabled[name] = !!enabled; + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.SpriteGPULayer#preDestroy + * @protected + * @since 4.0.0 + */ + preDestroy: function () + { + this.frameDataTexture.destroy(); + + // TODO: Destroy the Submitter RenderNode. + } +}); + +module.exports = SpriteGPULayer; + + +/***/ }, + +/***/ 16193 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BlendModes = __webpack_require__(10312); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var SpriteGPULayer = __webpack_require__(76573); + +/** + * Creates a new SpriteGPULayer Game Object and returns it. + * + * Note: This method will only be available if the SpriteGPULayer Game Object + * has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#spriteGPULayer + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.SpriteGPULayer.SpriteGPULayerConfig} config - The configuration object this Game Object will use to create itself. The `size` property sets the maximum number of sprites the layer can hold, and defaults to 1 if not specified. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.SpriteGPULayer} The Game Object that was created. + */ +GameObjectCreator.register('spriteGPULayer', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var size = GetAdvancedValue(config, 'size', 1); + + var gpuLayer = new SpriteGPULayer(this.scene, key, size); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + // Alpha + gpuLayer.alpha = GetAdvancedValue(config, 'alpha', 1); + + // Blend Mode + gpuLayer.blendMode = GetAdvancedValue(config, 'blendMode', BlendModes.NORMAL); + + // Visible + gpuLayer.visible = GetAdvancedValue(config, 'visible', true); + + if (addToScene) + { + this.scene.sys.displayList.add(gpuLayer); + } + + return gpuLayer; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 96019 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var SpriteGPULayer = __webpack_require__(76573); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new SpriteGPULayer Game Object and adds it to the Scene. + * + * A SpriteGPULayer is a high-performance batch renderer that draws a collection + * of sprites sharing the same texture in a single GPU draw call. Use it when you + * need to render many instances of the same sprite with minimal draw call overhead, + * such as for particle-like effects, tilemaps, or large crowds of identical objects. + * + * Note: This method will only be available if the SpriteGPULayer Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#spriteGPULayer + * @since 4.0.0 + * + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {number} [size] - The maximum number of sprites the SpriteGPULayer can render in a single batch. Default 1. + * + * @return {Phaser.GameObjects.SpriteGPULayer} The Game Object that was created. + */ +GameObjectFactory.register('spriteGPULayer', function (texture, size) +{ + return this.displayList.add(new SpriteGPULayer(this.scene, texture, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 71238 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = __webpack_require__(97591); +var renderCanvas = NOOP; + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 97591 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.SpriteGPULayer#renderWebGL + * @since 4.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - This transform matrix is defined if the game object is nested. + */ +var SpriteGPULayerWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + drawingContext.camera.addToRenderList(src); + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext + ); +}; + +module.exports = SpriteGPULayerWebGLRenderer; + + +/***/ }, + +/***/ 14727 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DefaultStampNodes = __webpack_require__(78705); +var Class = __webpack_require__(83419); +var Image = __webpack_require__(88571); +var StampRender = __webpack_require__(74759); + +/** + * @classdesc + * A Stamp Game Object. + * + * A Stamp is a lightweight Game Object which ignores camera scroll and transform, + * so it is always rendered at a fixed position on-screen regardless of where the + * camera is looking. This makes it ideal for HUDs, score counters, overlays, and + * other screen-space elements that should not move with the game world. + * + * Its primary role is as an internal helper for DynamicTexture rendering, where it + * is used to draw (stamp) textures onto a DynamicTexture surface without the overhead + * of a full scene Game Object lifecycle. It is otherwise functionally similar to + * an Image Game Object. + * + * @class Stamp + * @extends Phaser.GameObjects.Image + * @memberof Phaser.GameObjects + * @constructor + * @since 4.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Stamp = new Class({ + Extends: Image, + + Mixins: [ + StampRender + ], + + initialize: function Stamp (scene, x, y, texture, frame) + { + Image.call(this, scene, x, y, texture, frame); + + this.type = 'Stamp'; + }, + + _defaultRenderNodesMap: { + get: function () + { + return DefaultStampNodes; + } + } +}); + +module.exports = Stamp; + + +/***/ }, + +/***/ 656 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var TransformMatrix = __webpack_require__(61340); + +var tempMatrix = new TransformMatrix(); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Stamp#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Stamp} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StampCanvasRenderer = function (renderer, src, camera) +{ + camera.addToRenderList(src); + + tempMatrix.copyFrom(camera.matrix); + camera.matrix.loadIdentity(); + var scrollX = camera.scrollX; + var scrollY = camera.scrollY; + camera.scrollX = 0; + camera.scrollY = 0; + + renderer.batchSprite(src, src.frame, camera); + + camera.scrollX = scrollX; + camera.scrollY = scrollY; + camera.matrix.copyFrom(tempMatrix); +}; + +module.exports = StampCanvasRenderer; + + +/***/ }, + +/***/ 31479 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Stamp = __webpack_require__(14727); + +/** + * Creates a new Stamp Game Object and returns it. + * + * Note: This method will only be available if the Stamp Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#stamp + * @since 4.0.0 + * + * @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Stamp} The Game Object that was created. + */ +GameObjectCreator.register('stamp', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var stamp = new Stamp(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, stamp, config); + + return stamp; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 85326 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Stamp = __webpack_require__(14727); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Stamp Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Stamp Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#stamp + * @since 4.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Stamp} The Game Object that was created. + */ +GameObjectFactory.register('stamp', function (x, y, texture, frame) +{ + return this.displayList.add(new Stamp(this.scene, x, y, texture, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 74759 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// The Stamp inherits WebGL rendering properties from the Image class. + +var NOOP = __webpack_require__(29747); +var renderCanvas = NOOP; + +if (true) +{ + renderCanvas = __webpack_require__(656); +} + +module.exports = { + + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 84423 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var StencilModifier = __webpack_require__(43520); +var Container = __webpack_require__(31559); +var Layer = __webpack_require__(93595); + +/** + * @classdesc + * A Stencil Game Object. + * + * A Stencil is a special type of Game Object used to place stencils over the canvas. + * You can use it to efficiently control where subsequent objects are rendered. + * It is WebGL-only. + * Study the documentation carefully to understand how it works. + * + * A Stencil is an extended Container Game Object. + * It contains a list of child Game Objects to render to the stencil buffer. + * Think of these as opaque sheets of card held up over the canvas, + * preventing anything from being drawn through them. + * + * The stencil buffer is provided by WebGL. + * It is available if the game render config set `stencil` to `true`. + * It is an 8-bit attachment to framebuffers, like an extra alpha channel. + * But if the stencil channel is not 0 at a pixel, WebGL will skip rendering that pixel. + * There are no degrees of transparency, only on or off. + * + * When you draw objects with alpha to a Stencil, + * a special `alphaStrategy` is used. Compatible shaders switch from rendering + * alpha, to discarding fragments based on their alpha value. + * By default, this uses dithering to preserve alpha gradients. + * You can change `stencilAlphaStrategy` to a threshold value to instead + * discard without dithering. + * If `stencilAlphaStrategy` is `'keep'`, + * or the child's shader does not support alpha strategies, + * transparent pixels will be drawn as opaque to the stencil buffer! + * This is rarely what you want. + * Fragment shaders must `discard` fragments for them to be transparent to the stencil buffer. + * + * By default, most Phaser shaders support alpha strategies. + * Notable exceptions include: + * + * - PointLight (additive lighting) + * - Shader game objects, and extended classes like Noise + * + * To apply an alpha strategy without a compatible shader, + * force stencil composition by setting `stencilCompositeCheck` to `true`. + * This will composite the stencil contents to a framebuffer, + * which is rendered using a compatible shader. + * + * Stencils are drawn as order-independent layers. + * You can add or remove layers in sequence using `addLayer` and `removeLayer`. + * Each layer adds or subtracts 1 from the stencil buffer. + * Only when the stencil is 0 at a pixel will anything be drawn there. + * (This 0-test is a rule set by the renderer's base DrawingContext.) + * Note that overlapping geometry within the same Stencil is additive, + * and can adjust the layer by more than 1 in aggregate. + * The results can be surprising, so try to avoid overlaps. + * + * You can invert the stencil by setting `stencilInvert` to `true`. + * This will use an extra draw call to invert the stencil: + * it adds a layer everywhere that the children would not draw. + * It is more efficient to render a shape that covers the whole area you wish to stencil, + * but if that's not possible, you can use this. + * Inversion makes it possible to render to parts of the screen not touched + * by child geometry. + * It works by filling the camera, then drawing the child stencil in reverse. + * + * You can remove the stencil by using {@link Phaser.GameObjects.StencilReference}. + * This object copies a target Stencil, and re-renders it + * with different stencil options, elsewhere in the display list. + * This is an efficient way to re-use stencil geometry. + * + * You can also clear the stencil by setting `stencilLayerMode` to `clear`. + * It replaces all stencil buffer values with the `stencilClearValue`. + * This should normally set them back to 0 so everything renders again. + * This destroys all layer information. + * It does not use the child list. + * Be careful not to mess up your scene this way. + * + * Set `stencilLayerMode` to `clearRegion` to fill a region + * of the stencil buffer defined by the children, with the `stencilClearValue`. + * This can be used as a selective eraser, or to set a region to a specific value. + * + * You cannot invert the stencil if the `stencilLayerMode` is `clear` or `clearRegion`. + * + * Sequential stencil layers combine and persist, + * because they are drawn to the stencil buffer and stay there until the next frame. + * Do not add too many layers, though. There are only 8 bits in the stencil buffer, + * so it only safely supports 255 layers. + * If you go over this limit, the buffer wraps back to 0. + * You can still add and remove layers in this case, + * and they will continue to be accurately tracked, + * but layer 256 (and subsequent multiples of 256) will be effectively 0 and allow drawing. + * The same applies if you remove layers below 0: it wraps back to 255 + * and prevents drawing. + * + * Deactivate `stencilValueWrap` to prevent the stencil buffer from wrapping. + * This is useful when defining stencils with subtraction, + * and you don't want to underflow from 0 to 255. + * For example, you can use one stencil in `clearRegion` to define a value, + * then use another stencil in `subtractLayer` to erase parts of that region. + * But be careful when using stencils for different purposes: + * if you mix stencil data, you will get unexpected results. + * + * Nested stencils are a separate concern. + * If you add a Stencil as the child of another Stencil, + * the parent Stencil will composite its contents to a framebuffer, + * including child stencils. + * This effectively traps the child stencil in the framebuffer, + * and only the final composite from the framebuffer needs to be considered. + * It is used as the source for the stencil, subject to alpha strategy. + * This requires extra draw calls to composite, + * and framebuffers have poor anti-aliasing quality, + * so you should avoid nesting stencils unless you know what you are doing. + * + * To determine whether the stencil needs to composite to a framebuffer, + * it runs a check before rendering (`'auto'` mode). + * If you know the answer already, + * or if you have a custom game object that Phaser doesn't understand, + * you can set `stencilCompositeCheck` to `true` or `false` + * to skip the auto check. + * If you set it to `false`, it will never composite, + * and any child stencils may render in unexpected ways. + * (Generally, they will appear backwards from what you expect: + * child stencils will not affect the parent stencil, but things drawn later.) + * + * Best practice: use few stencils and don't nest them. + * + * Stencil is best used for efficient, sharp-edged, reused masks. + * You can draw a stencil once, and it will affect everything that is drawn later. + * Its rendering cost is minimal: it is just the draw cost of its children. + * This can be as low as 1 call. + * If there are nested stencils, it will take more calls for the framebuffer. + * + * If you need better quality alpha handling, consider using a Mask filter instead. + * Filters have a higher rendering cost, and apply to just 1 object at a time, + * but they have the best quality. + * (And you can apply them to Containers, to cheat the object limitation.) + * + * @class Stencil + * @extends Phaser.GameObjects.Container + * @extends Phaser.GameObjects.Components.StencilModifier + * @memberof Phaser.GameObjects + * @constructor + * @since 4.2.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to the Stencil. + * @param {Phaser.Types.GameObjects.Stencil.StencilOptions} [options] - The options for the Stencil. + */ +var Stencil = new Class({ + Extends: Container, + + Mixins: [ + StencilModifier + ], + + initialize: function Stencil (scene, x, y, children, options) { + Container.call(this, scene, x, y, children); + + if (options) + { + if (options.stencilAlphaStrategy !== undefined) + { + this.stencilAlphaStrategy = options.stencilAlphaStrategy; + } + else + { + this.stencilAlphaStrategy = scene.renderer.config.stencilAlphaStrategy; + } + if (options.stencilClearValue !== undefined) + { + this.stencilClearValue = options.stencilClearValue; + } + if (options.stencilCompositeCheck !== undefined) + { + this.stencilCompositeCheck = options.stencilCompositeCheck; + } + if (options.stencilInvert !== undefined) + { + this.stencilInvert = options.stencilInvert; + } + if (options.stencilLayerMode !== undefined) + { + this.stencilLayerMode = options.stencilLayerMode; + } + if (options.stencilValueWrap !== undefined) + { + this.stencilValueWrap = options.stencilValueWrap; + } + } + else + { + this.stencilAlphaStrategy = scene.renderer.config.stencilAlphaStrategy; + } + + // Add the stencil render step as the first render step. + this.addRenderStep(this.stencilRenderStep, 0); + }, + + /** + * The stencil render step. + * This is an internal function, which is automatically assigned; + * you should not call it directly. + * + * This runs before other render steps, + * so it can set up the drawing context to render properly. + * It delegates to the appropriate render step function based on the `stencilLayerMode`. + * + * @method Phaser.GameObjects.Stencil#stencilRenderStep + * @webglOnly + * @since 4.2.0 + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - This transform matrix is defined if the game object is nested + * @param {number} [renderStep=0] - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} [displayList] - The display list which is currently being rendered. + * @param {number} [displayListIndex] - The index of the Game Object within the display list. + */ + stencilRenderStep: function (renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) + { + switch (gameObject.stencilLayerMode) + { + case 'clear': + { + gameObject.stencilRenderStepClear(renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex); + break; + } + case 'clearRegion': + { + gameObject.stencilRenderStepClearRegion(renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex); + break; + } + case 'addLayer': + case 'subtractLayer': + default: + { + gameObject.stencilRenderStepLayers(renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex); + break; + } + } + }, + + /** + * The render step used when the `stencilLayerMode` is `addLayer` or `subtractLayer`. + * You should not call this directly. + * + * @method Phaser.GameObjects.Stencil#stencilRenderStepLayers + * @webglOnly + * @since 4.2.0 + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - This transform matrix is defined if the game object is nested + * @param {number} [renderStep=0] - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} [displayList] - The display list which is currently being rendered. + * @param {number} [displayListIndex] - The index of the Game Object within the display list. + */ + stencilRenderStepLayers: function (renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) + { + var gl = renderer.gl; + + // If the tree of child game objects has any stencil children, + // activate forced composite mode on `gameObject`. + var filtersForceComposite = gameObject.filtersForceComposite; + if ( + gameObject.stencilCompositeCheck === true || + (gameObject.stencilCompositeCheck === 'auto' && gameObject.hasStencilChildren(gameObject, drawingContext.camera)) + ) + { + gameObject.enableFilters().setFiltersForceComposite(true); + } + + // Set up the drawing context to render to the stencil buffer. + var currentContext = drawingContext.getClone(); + currentContext.setAlphaStrategy(gameObject.stencilAlphaStrategy); + currentContext.setColorWritemask(false, false, false, false); + var opIncr = gameObject.stencilValueWrap ? gl.INCR_WRAP : gl.INCR; + var opDecr = gameObject.stencilValueWrap ? gl.DECR_WRAP : gl.DECR; + var op = opIncr; + if (gameObject.stencilLayerMode === 'subtractLayer') + { + op = opDecr; + } + currentContext.setStencil(true, gl.ALWAYS, 0, 0xFF, op, op, op, 0, 0xFF); + + currentContext.use(); + + // Invert the stencil area if needed. + if (gameObject.stencilInvert) + { + renderer.renderNodes.getNode('FillCamera').run(currentContext, 0xff000000, drawingContext.useCanvas); + + currentContext = currentContext.getClone(); + currentContext.use(); + + // Invert the stencil operation. + op = op === opIncr ? opDecr : opIncr; + currentContext.setStencil(true, gl.ALWAYS, 0, 0xFF, op, op, op, 0, 0xFF); + } + + // Render the children. + gameObject.renderWebGLStep( + renderer, + gameObject, + currentContext, + parentMatrix, + renderStep + 1, + displayList, + displayListIndex + ); + + currentContext.release(); + + gameObject.setFiltersForceComposite(filtersForceComposite); + }, + + /** + * The render step used when the `stencilLayerMode` is `clear`. + * You should not call this directly. + * + * @method Phaser.GameObjects.Stencil#stencilRenderStepClear + * @webglOnly + * @since 4.2.0 + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - This transform matrix is defined if the game object is nested + * @param {number} [renderStep=0] - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} [displayList] - The display list which is currently being rendered. + * @param {number} [displayListIndex] - The index of the Game Object within the display list. + */ + stencilRenderStepClear: function (renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) + { + var gl = renderer.gl; + + var currentContext = drawingContext.getClone(); + currentContext.state.stencil.clear = gameObject.stencilClearValue; + currentContext.state.stencil.writeMask = 0xFF; + currentContext.use(); + currentContext.clear(gl.STENCIL_BUFFER_BIT); + }, + + /** + * The render step used when the `stencilLayerMode` is `clearRegion`. + * You should not call this directly. + * + * @method Phaser.GameObjects.Stencil#stencilRenderStepClearRegion + * @webglOnly + * @since 4.2.0 + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - This transform matrix is defined if the game object is nested + * @param {number} [renderStep=0] - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} [displayList] - The display list which is currently being rendered. + * @param {number} [displayListIndex] - The index of the Game Object within the display list. + */ + stencilRenderStepClearRegion: function (renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) + { + var gl = renderer.gl; + + // If the tree of child game objects has any stencil children, + // activate forced composite mode on `gameObject`. + var filtersForceComposite = gameObject.filtersForceComposite; + if ( + gameObject.stencilCompositeCheck === true || + (gameObject.stencilCompositeCheck === 'auto' && gameObject.hasStencilChildren(gameObject, drawingContext.camera)) + ) + { + gameObject.enableFilters().setFiltersForceComposite(true); + } + + // Set up the drawing context to render to the stencil buffer. + var currentContext = drawingContext.getClone(); + currentContext.setAlphaStrategy(gameObject.stencilAlphaStrategy); + currentContext.setColorWritemask(false, false, false, false); + var clearValue = gameObject.stencilClearValue; + var op = gl.REPLACE; + currentContext.setStencil(true, gl.ALWAYS, clearValue, 0xFF, op, op, op, clearValue, 0xFF); + + currentContext.use(); + + // Render the children. + gameObject.renderWebGLStep( + renderer, + gameObject, + currentContext, + parentMatrix, + renderStep + 1, + displayList, + displayListIndex + ); + + currentContext.release(); + + gameObject.setFiltersForceComposite(filtersForceComposite); + }, + + /** + * Checks if the game object or any of its children has a stencil. + * This is used internally to determine if the stencil should composite its contents to a framebuffer. + * + * This is a depth-first, succeed-fast search. + * + * @method Phaser.GameObjects.Stencil#hasStencilChildren + * @since 4.2.0 + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to check. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to check. + * @returns {boolean} Whether the game object or any of its children has a stencil. + */ + hasStencilChildren: function (gameObject, camera) + { + if (gameObject instanceof Container || gameObject instanceof Layer) + { + for (var i = 0; i < gameObject.list.length; i++) + { + var child = gameObject.list[i]; + if ( + child && + child.willRender(camera) && + ( + child.isStencilModifier || + this.hasStencilChildren(child, camera) + ) + ) + { + return true; + } + } + } + return false; + } +}); + +module.exports = Stencil; + + +/***/ }, + +/***/ 32247 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var Stencil = __webpack_require__(84423); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetFastValue = __webpack_require__(95540); + +/** + * Creates a new Stencil Game Object and returns it. + * + * Note: This method will only be available if the Stencil Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#stencil + * @since 4.2.0 + * + * @param {Phaser.Types.GameObjects.Stencil.StencilConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Stencil} The Game Object that was created. + */ +GameObjectCreator.register('stencil', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var children = GetFastValue(config, 'children', null); + var options = GetAdvancedValue(config, 'options', {}); + + var stencil = new Stencil(this.scene, x, y, children, options); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, stencil, config); + + return stencil; +}); + + +/***/ }, + +/***/ 67841 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Stencil = __webpack_require__(84423); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Stencil Game Object and adds it to the Scene. + * + * A Stencil is a special type of Game Object used to place stencils over the canvas. + * You can use it to efficiently control where subsequent objects are rendered. + * It is WebGL-only. + * Study the documentation ({@link Phaser.GameObjects.Stencil}) carefully to understand how it works. + * + * A Stencil is an extended Container Game Object. + * It contains a list of child Game Objects to render to the stencil buffer. + * Think of these as opaque sheets of card held up over the canvas, + * preventing anything from being drawn through them. + * + * Note: This method will only be available if the Stencil Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#stencil + * @since 4.2.0 + * + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional Game Object, or array of Game Objects, to add to this Stencil. + * @param {Phaser.Types.GameObjects.Stencil.StencilOptions} [options] - The options for the Stencil. + * + * @return {Phaser.GameObjects.Stencil} The Game Object that was created. + */ +GameObjectFactory.register('stencil', function (x, y, children, options) +{ + return this.displayList.add(new Stencil(this.scene, x, y, children, options)); +}); + + +/***/ }, + +/***/ 63911 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var BlendModes = __webpack_require__(10312); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var Render = __webpack_require__(4775); + +/** + * @classdesc + * A StencilReference Game Object. + * + * A StencilReference is a special type of Game Object that uses a Stencil + * as a reference for its own rendering. This allows you to re-render a Stencil + * using different settings. + * + * For example, you can add a layer with a Stencil with some complex geometry, + * draw objects affected by the stencil layer, + * then use a StencilReference to subtract the same layer without recreating it. + * + * It is WebGL-only. + * + * A StencilReference temporarily changes the settings on the target Stencil, + * then restores them after rendering. + * Thus, it keeps the original Stencil's transforms. + * The stencil options can be changed by setting the properties on this object. + * Note that these properties will be set to default values, + * so if you have configured the targetStencil with its own properties, + * you should configure this with those properties as well, + * altered to your requirements. + * + * See the {@link Phaser.GameObjects.Stencil} documentation for more details. + * + * @class StencilReference + * @extends Phaser.GameObjects.GameObject + * @extends Phaser.GameObjects.Components.StencilModifier + * @extends Phaser.GameObjects.Components.Visible + * @memberof Phaser.GameObjects + * @constructor + * @since 4.2.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.GameObjects.Stencil} targetStencil - The Stencil to use as a reference. + * @param {Phaser.Types.GameObjects.Stencil.StencilOptions} [options] - The options for the StencilReference. + */ +var StencilReference = new Class({ + Extends: GameObject, + + Mixins: [ + Components.StencilModifier, + Components.Visible, + Render + ], + + initialize: function StencilReference(scene, targetStencil, options) { + GameObject.call(this, scene, 'StencilReference'); + + /** + * The Stencil to use as a reference. + * + * @name Phaser.GameObjects.StencilReference#targetStencil + * @type {Phaser.GameObjects.Stencil} + * @since 4.2.0 + */ + this.targetStencil = targetStencil; + + if (options) + { + if (options.stencilAlphaStrategy !== undefined) + { + this.stencilAlphaStrategy = options.stencilAlphaStrategy; + } + else + { + this.stencilAlphaStrategy = scene.renderer.config.stencilAlphaStrategy; + } + if (options.stencilClearValue !== undefined) + { + this.stencilClearValue = options.stencilClearValue; + } + if (options.stencilCompositeCheck !== undefined) + { + this.stencilCompositeCheck = options.stencilCompositeCheck; + } + if (options.stencilInvert !== undefined) + { + this.stencilInvert = options.stencilInvert; + } + if (options.stencilLayerMode !== undefined) + { + this.stencilLayerMode = options.stencilLayerMode; + } + if (options.stencilValueWrap !== undefined) + { + this.stencilValueWrap = options.stencilValueWrap; + } + } + else + { + this.stencilAlphaStrategy = scene.renderer.config.stencilAlphaStrategy; + } + }, + + /** + * The blend mode to use when rendering the stencil reference. + * This is read-only, and is only used for internal compliance. + * Stencil drawing uses its own combination rules. + * + * @name Phaser.GameObjects.StencilReference#blendMode + * @type {number} + * @since 4.2.0 + * @readonly + * @default Phaser.BlendModes.SKIP_CHECK + */ + blendMode: { + get: function() { + return BlendModes.SKIP_CHECK; + }, + set: function(value) { + // Do nothing + } + }, + + /** + * Pre-destroy callback. + * @method Phaser.GameObjects.StencilReference#preDestroy + * @since 4.2.0 + */ + preDestroy: function() + { + this.targetStencil = null; + } +}); + +module.exports = StencilReference; + + +/***/ }, + +/***/ 44023 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var StencilReference = __webpack_require__(63911); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetFastValue = __webpack_require__(95540); + +/** + * Creates a new StencilReference Game Object and returns it. + * + * Note: This method will only be available if the StencilReference Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#stencilreference + * @since 4.2.0 + * + * @param {Phaser.Types.GameObjects.StencilReference.StencilReferenceConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.StencilReference} The Game Object that was created. + */ +GameObjectCreator.register('stencilreference', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var targetStencil = GetFastValue(config, 'targetStencil', null); + var options = GetAdvancedValue(config, 'options', {}); + + var stencilreference = new StencilReference(this.scene, targetStencil, options); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, stencilreference, config); + + return stencilreference; +}); + + +/***/ }, + +/***/ 37889 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var StencilReference = __webpack_require__(63911); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new StencilReference Game Object and adds it to the Scene. + * + * A StencilReference is a special type of Game Object that can be used to reference a Stencil. + * You can use a StencilReference to reference a Stencil, and then use the StencilReference to render the Stencil. + * This is useful for creating complex stencil effects. + * + * Note: This method will only be available if the StencilReference Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#stencilreference + * @since 4.2.0 + * + * @param {Phaser.GameObjects.Stencil} targetStencil - The Stencil to use as a reference. + * @param {Phaser.Types.GameObjects.Stencil.StencilOptions} [options] - The options for the StencilReference. + * + * @return {Phaser.GameObjects.StencilReference} The Game Object that was created. + */ +GameObjectFactory.register('stencilreference', function (targetStencil, options) +{ + return this.displayList.add(new StencilReference(this.scene, targetStencil, options)); +}); + + +/***/ }, + +/***/ 4775 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = __webpack_require__(12217); +var renderCanvas = NOOP; + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 12217 +(module) { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.StencilReference#renderWebGL + * @since 4.2.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.StencilReference} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + * @param {number} renderStep - The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. + * @param {Phaser.GameObjects.GameObject[]} displayList - The display list which is currently being rendered. + * @param {number} displayListIndex - The index of the Game Object within the display list. + */ +var StencilReferenceWebGLRenderer = function (renderer, src, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) +{ + var stencil = src.targetStencil; + + if (!stencil || stencil.isDestroyed) + { + return; + } + + // Cache the stencil options. + var stencilAlphaStrategy = stencil.stencilAlphaStrategy; + var stencilClearValue = stencil.stencilClearValue; + var stencilCompositeCheck = stencil.stencilCompositeCheck; + var stencilInvert = stencil.stencilInvert; + var stencilLayerMode = stencil.stencilLayerMode; + var stencilValueWrap = stencil.stencilValueWrap; + + // Edit the stencil properties. + stencil.stencilAlphaStrategy = src.stencilAlphaStrategy; + stencil.stencilClearValue = src.stencilClearValue; + stencil.stencilCompositeCheck = src.stencilCompositeCheck; + stencil.stencilInvert = src.stencilInvert; + stencil.stencilLayerMode = src.stencilLayerMode; + stencil.stencilValueWrap = src.stencilValueWrap; + + // Get the parent transform of the Stencil, not the StencilReference. + var parentTransform = null; + if (stencil.parentContainer) + { + parentTransform = stencil.parentContainer.getWorldTransformMatrix(); + } + + // Render the stencil. + stencil.renderWebGLStep(renderer, stencil, drawingContext, parentTransform, 0); + + // Restore the stencil options. + stencil.stencilAlphaStrategy = stencilAlphaStrategy; + stencil.stencilClearValue = stencilClearValue; + stencil.stencilCompositeCheck = stencilCompositeCheck; + stencil.stencilInvert = stencilInvert; + stencil.stencilLayerMode = stencilLayerMode; + stencil.stencilValueWrap = stencilValueWrap; +}; + +module.exports = StencilReferenceWebGLRenderer; + + +/***/ }, + +/***/ 14220 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates and returns the rendered dimensions of a Text object, including the width of each line, the maximum line width, the total height (accounting for line spacing), and the number of drawn lines (respecting `maxLines`). + * + * @function Phaser.GameObjects.GetTextSize + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object to calculate the size from. + * @param {Phaser.Types.GameObjects.Text.TextMetrics} size - The Text metrics to use when calculating the size. + * @param {string[]} lines - The lines of text to calculate the size from. + * + * @return {Phaser.Types.GameObjects.Text.GetTextSizeObject} An object containing dimensions of the Text object. + */ +var GetTextSize = function (text, size, lines) +{ + var canvas = text.canvas; + var context = text.context; + var style = text.style; + + var lineWidths = []; + var maxLineWidth = 0; + var drawnLines = lines.length; + + if (style.maxLines > 0 && style.maxLines < lines.length) + { + drawnLines = style.maxLines; + } + + style.syncFont(canvas, context); + + // Text Width + var letterSpacing = text.letterSpacing; + + for (var i = 0; i < drawnLines; i++) + { + var lineWidth = style.strokeThickness; + + if (letterSpacing === 0) + { + lineWidth += context.measureText(lines[i]).width; + } + else + { + var line = lines[i]; + + for (var j = 0; j < line.length; j++) + { + lineWidth += context.measureText(line[j]).width; + } + + if (line.length > 1) + { + lineWidth += letterSpacing * (line.length - 1); + } + } + + // Adjust for wrapped text + if (style.wordWrap) + { + lineWidth -= context.measureText(' ').width; + } + + lineWidths[i] = Math.ceil(lineWidth); + maxLineWidth = Math.max(maxLineWidth, lineWidths[i]); + } + + // Text Height + + var lineHeight = size.fontSize + style.strokeThickness; + var height = lineHeight * drawnLines; + var lineSpacing = text.lineSpacing; + + // Adjust for line spacing + if (drawnLines > 1) + { + height += lineSpacing * (drawnLines - 1); + } + + return { + width: maxLineWidth, + height: height, + lines: drawnLines, + lineWidths: lineWidths, + lineSpacing: lineSpacing, + lineHeight: lineHeight + }; +}; + +module.exports = GetTextSize; + + +/***/ }, + +/***/ 79557 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CanvasPool = __webpack_require__(27919); + +/** + * Calculates the ascent, descent, and fontSize metrics for a given TextStyle by rendering text to a temporary offscreen canvas and measuring the pixel boundaries. It uses the `actualBoundingBoxAscent`/`actualBoundingBoxDescent` API where available, falling back to a pixel-scanning approach for older browsers. + * + * @function Phaser.GameObjects.MeasureText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.TextStyle} textStyle - The TextStyle object to measure. + * + * @return {Phaser.Types.GameObjects.Text.TextMetrics} An object containing the ascent, descent and fontSize of the TextStyle. + */ +var MeasureText = function (textStyle) +{ + var canvas = CanvasPool.create(this); + var context = canvas.getContext('2d', { willReadFrequently: true }); + + textStyle.syncFont(canvas, context); + + var metrics = context.measureText(textStyle.testString); + + if ('actualBoundingBoxAscent' in metrics) + { + var ascent = metrics.actualBoundingBoxAscent; + var descent = metrics.actualBoundingBoxDescent; + + CanvasPool.remove(canvas); + + return { + ascent: ascent, + descent: descent, + fontSize: ascent + descent + }; + } + + var width = Math.ceil(metrics.width * textStyle.baselineX); + var baseline = width; + var height = 2 * baseline; + + baseline = baseline * textStyle.baselineY | 0; + + canvas.width = width; + canvas.height = height; + + context.fillStyle = '#f00'; + context.fillRect(0, 0, width, height); + + context.font = textStyle._font; + + context.textBaseline = 'alphabetic'; + context.fillStyle = '#000'; + context.fillText(textStyle.testString, 0, baseline); + + var output = { + ascent: 0, + descent: 0, + fontSize: 0 + }; + + var imagedata = context.getImageData(0, 0, width, height); + + if (!imagedata) + { + output.ascent = baseline; + output.descent = baseline + 6; + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; + } + + var pixels = imagedata.data; + var numPixels = pixels.length; + var line = width * 4; + var i; + var j; + var idx = 0; + var stop = false; + + // ascent. scan from top to bottom until we find a non red pixel + for (i = 0; i < baseline; i++) + { + for (j = 0; j < line; j += 4) + { + if (pixels[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx += line; + } + else + { + break; + } + } + + output.ascent = baseline - i; + + idx = numPixels - line; + stop = false; + + // descent. scan from bottom to top until we find a non red pixel + for (i = height; i > baseline; i--) + { + for (j = 0; j < line; j += 4) + { + if (pixels[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx -= line; + } + else + { + break; + } + } + + output.descent = (i - baseline); + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; +}; + +module.exports = MeasureText; + + +/***/ }, + +/***/ 50171 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AddToDOM = __webpack_require__(40366); +var CanvasPool = __webpack_require__(27919); +var DefaultImageNodes = __webpack_require__(40939); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var GetTextSize = __webpack_require__(14220); +var GetValue = __webpack_require__(35154); +var RemoveFromDOM = __webpack_require__(35846); +var TextRender = __webpack_require__(61771); +var TextStyle = __webpack_require__(35762); +var UUID = __webpack_require__(45650); + +/** + * @classdesc + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * **Important:** The font name must be quoted if it contains certain combinations of digits or + * special characters, either when creating the Text object, or when setting the font via `setFont` + * or `setFontFamily`, e.g.: + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { fontFamily: 'Georgia, "Goudy Bookletter 1911", Times, serif' }); + * ``` + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { font: '"Press Start 2P"' }); + * ``` + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do this for you, so you will require the use of a 3rd party font loader, + * or have the fonts readily available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * @class Text + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {Phaser.Types.GameObjects.Text.TextStyle} style - The text style configuration object. + * + * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#Valid_family_names + */ +var Text = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Lighting, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TextRender + ], + + initialize: + + function Text (scene, x, y, text, style) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + GameObject.call(this, scene, 'Text'); + + /** + * The renderer in use by this Text object. + * + * @name Phaser.GameObjects.Text#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.12.0 + */ + this.renderer = scene.sys.renderer; + + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initRenderNodes(this._defaultRenderNodesMap); + + /** + * The canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = CanvasPool.create(this); + + /** + * The context of the canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context; + + /** + * The Text Style object. + * + * Manages the style of this Text object. + * + * @name Phaser.GameObjects.Text#style + * @type {Phaser.GameObjects.TextStyle} + * @since 3.0.0 + */ + this.style = new TextStyle(this, style); + + /** + * Whether to automatically round line positions. + * + * @name Phaser.GameObjects.Text#autoRound + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.autoRound = true; + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + * + * @name Phaser.GameObjects.Text#splitRegExp + * @type {object} + * @since 3.0.0 + */ + this.splitRegExp = /(?:\r\n|\r|\n)/; + + /** + * The text to display. + * + * @name Phaser.GameObjects.Text#_text + * @type {string} + * @private + * @since 3.12.0 + */ + this._text = undefined; + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + * + * @name Phaser.GameObjects.Text#padding + * @type {Phaser.Types.GameObjects.Text.TextPadding} + * @since 3.0.0 + */ + this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; + + /** + * The width of this Text object. + * + * @name Phaser.GameObjects.Text#width + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.width = 1; + + /** + * The height of this Text object. + * + * @name Phaser.GameObjects.Text#height + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.height = 1; + + /** + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. + * + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + * + * @name Phaser.GameObjects.Text#lineSpacing + * @type {number} + * @since 3.13.0 + */ + this.lineSpacing = 0; + + /** + * Adds / Removes spacing between characters. + * Can be a negative or positive number. + * + * If you update this property directly, instead of using the `setLetterSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + * + * @name Phaser.GameObjects.Text#letterSpacing + * @type {number} + * @since 3.60.0 + */ + this.letterSpacing = 0; + + // If resolution wasn't set, force it to 1 + if (this.style.resolution === 0) + { + this.style.resolution = 1; + } + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Text#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The internal unique key to refer to the texture in the TextureManager. + * + * @name Phaser.GameObjects.Text#_textureKey + * @type {string} + * @private + * @since 3.80.0 + */ + this._textureKey = UUID(); + + // Create a Texture for this Text object + this.texture = scene.sys.textures.addCanvas(this._textureKey, this.canvas); + + // Set the context to be the CanvasTexture context + this.context = this.texture.context; + + // Get the frame + this.frame = this.texture.get(); + + // Set the resolution + this.frame.source.resolution = this.style.resolution; + + if (this.renderer && this.renderer.gl) + { + // Clear the default 1x1 glTexture, as we override it later + this.renderer.deleteTexture(this.frame.source.glTexture); + + this.frame.source.glTexture = null; + } + + this.initRTL(); + + this.setText(text); + + if (style && style.padding) + { + this.setPadding(style.padding); + } + + if (style && style.lineSpacing) + { + this.setLineSpacing(style.lineSpacing); + } + + if (style && style.letterSpacing) + { + this.setLetterSpacing(style.letterSpacing); + } + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.Text#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultImageNodes; + } + }, + + /** + * Initialize right to left text. + * + * @method Phaser.GameObjects.Text#initRTL + * @since 3.0.0 + */ + initRTL: function () + { + if (!this.style.rtl) + { + this.canvas.dir = 'ltr'; + this.context.direction = 'ltr'; + return; + } + + // Here is where the crazy starts. + // + // Due to browser implementation issues, you cannot fillText BiDi text to a canvas + // that is not part of the DOM. It just completely ignores the direction property. + + this.canvas.dir = 'rtl'; + + // Experimental atm, but one day ... + this.context.direction = 'rtl'; + + // Add it to the DOM, but hidden within the parent canvas. + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + + // And finally we set the x origin + this.originX = 1; + }, + + /** + * Applies word wrapping to the given text and returns the result. If a custom word wrap + * callback has been set, it will be invoked. Otherwise, the advanced or basic word wrap + * algorithm will be used, depending on the style configuration. If no word wrap settings + * are active, the original text is returned unchanged. + * + * @method Phaser.GameObjects.Text#runWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * + * @return {string} The text after wrapping has been applied. + */ + runWordWrap: function (text) + { + var style = this.style; + + if (style.wordWrapCallback) + { + var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); + + if (Array.isArray(wrappedLines)) + { + wrappedLines = wrappedLines.join('\n'); + } + + return wrappedLines; + } + else if (style.wordWrapWidth) + { + if (style.wordWrapUseAdvanced) + { + return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); + } + else + { + return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); + } + } + else + { + return text; + } + }, + + /** + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * + * @method Phaser.GameObjects.Text#advancedWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + advancedWordWrap: function (text, context, wordWrapWidth) + { + var output = ''; + + // Condense consecutive spaces and split into lines + var lines = text + .replace(/ +/gi, ' ') + .split(this.splitRegExp); + + var linesCount = lines.length; + + for (var i = 0; i < linesCount; i++) + { + var line = lines[i]; + var out = ''; + + // Trim whitespace + line = line.replace(/^ *|\s*$/gi, ''); + + // If entire line is less than wordWrapWidth append the entire line and exit early + var lineLetterSpacingWidth = line.length * this.letterSpacing; + var lineWidth = context.measureText(line).width + lineLetterSpacingWidth; + + if (lineWidth < wordWrapWidth) + { + output += line + '\n'; + continue; + } + + // Otherwise, calculate new lines + var currentLineWidth = wordWrapWidth; + + // Split into words + var words = line.split(' '); + + for (var j = 0; j < words.length; j++) + { + var word = words[j]; + var wordWithSpace = word + ' '; + var letterSpacingWidth = wordWithSpace.length * this.letterSpacing; + var wordWidth = context.measureText(wordWithSpace).width + letterSpacingWidth; + + if (wordWidth > currentLineWidth) + { + // Break word + if (j === 0) + { + // Shave off letters from word until it's small enough + var newWord = wordWithSpace; + + while (newWord.length) + { + newWord = newWord.slice(0, -1); + var newLetterSpacingWidth = newWord.length * this.letterSpacing; + wordWidth = context.measureText(newWord).width + newLetterSpacingWidth; + + if (wordWidth <= currentLineWidth) + { + break; + } + } + + // If wordWrapWidth is too small for even a single letter, shame user + // failure with a fatal error + if (!newWord.length) + { + throw new Error('wordWrapWidth < a single character'); + } + + // Replace current word in array with remainder + var secondPart = word.substr(newWord.length); + + words[j] = secondPart; + + // Append first piece to output + out += newWord; + } + + // If existing word length is 0, don't include it + var offset = (words[j].length) ? j : j + 1; + + // Collapse rest of sentence and remove any trailing white space + var remainder = words.slice(offset).join(' ').replace(/[ \n]*$/gi, ''); + + // Prepend remainder to next line + lines.splice(i + 1, 0, remainder); + + linesCount = lines.length; + break; // Processing on this line + + // Append word with space to output + } + else + { + out += wordWithSpace; + currentLineWidth -= wordWidth; + } + } + + // Append processed line to output + output += out.replace(/[ \n]*$/gi, '') + '\n'; + } + + // Trim the end of the string + output = output.replace(/[\s|\n]*$/gi, ''); + + return output; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * + * @method Phaser.GameObjects.Text#basicWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + basicWordWrap: function (text, context, wordWrapWidth) + { + var result = ''; + var lines = text.split(this.splitRegExp); + var lastLineIndex = lines.length - 1; + var whiteSpaceWidth = context.measureText(' ').width; + + for (var i = 0; i <= lastLineIndex; i++) + { + var spaceLeft = wordWrapWidth; + var words = lines[i].split(' '); + var lastWordIndex = words.length - 1; + + for (var j = 0; j <= lastWordIndex; j++) + { + var word = words[j]; + var letterSpacingWidth = word.length * this.letterSpacing; + var wordWidth = context.measureText(word).width + letterSpacingWidth; + var wordWidthWithSpace = wordWidth; + + if (j < lastWordIndex) + { + wordWidthWithSpace += whiteSpaceWidth; + } + + if (wordWidthWithSpace > spaceLeft) + { + // Skip printing the newline if it's the first word of the line that is greater + // than the word wrap width. + if (j > 0) + { + result += '\n'; + spaceLeft = wordWrapWidth; + } + } + + result += word; + + if (j < lastWordIndex) + { + result += ' '; + spaceLeft -= wordWidthWithSpace; + } + else + { + spaceLeft -= wordWidth; + } + } + + if (i < lastLineIndex) + { + result += '\n'; + } + } + + return result; + }, + + /** + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * + * @method Phaser.GameObjects.Text#getWrappedText + * @since 3.0.0 + * + * @param {string} [text] - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + * + * @return {string[]} An array of strings with the pieces of wrapped text. + */ + getWrappedText: function (text) + { + if (text === undefined) { text = this._text; } + + this.style.syncFont(this.canvas, this.context); + + var wrappedLines = this.runWordWrap(text); + + return wrappedLines.split(this.splitRegExp); + }, + + /** + * Set the text to display. + * + * An array of strings will be joined with `\n` line breaks. + * + * @method Phaser.GameObjects.Text#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. + * + * @return {this} This Text object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this._text) + { + this._text = value.toString(); + + this.updateText(); + } + + return this; + }, + + /** + * Appends the given text to the content already being displayed by this Text object. + * + * An array of strings will be joined with `\n` line breaks. + * + * @method Phaser.GameObjects.Text#appendText + * @since 3.60.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be appended to the existing content of this Text object. + * @param {boolean} [addCR=true] - Insert a carriage-return before the string value. + * + * @return {this} This Text object. + */ + appendText: function (value, addCR) + { + if (addCR === undefined) { addCR = true; } + + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + value = value.toString(); + + var newText = this._text.concat((addCR) ? '\n' + value : value); + + if (newText !== this._text) + { + this._text = newText; + + this.updateText(); + } + + return this; + }, + + /** + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); + * + * @method Phaser.GameObjects.Text#setStyle + * @since 3.0.0 + * + * @param {object} style - The style settings to set. + * + * @return {this} This Text object. + */ + setStyle: function (style) + { + return this.style.setStyle(style); + }, + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * **Important:** The font name must be quoted if it contains certain combinations of digits or + * special characters: + * + * ```javascript + * Text.setFont('"Press Start 2P"'); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * Text.setFont('Georgia, "Goudy Bookletter 1911", Times, serif'); + * ``` + * + * @method Phaser.GameObjects.Text#setFont + * @since 3.0.0 + * + * @param {string} font - The font family or font settings to set. + * + * @return {this} This Text object. + * + * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#Valid_family_names + */ + setFont: function (font) + { + return this.style.setFont(font); + }, + + /** + * Set the font family. + * + * **Important:** The font name must be quoted if it contains certain combinations of digits or + * special characters: + * + * ```javascript + * Text.setFontFamily('"Press Start 2P"'); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * Text.setFontFamily('Georgia, "Goudy Bookletter 1911", Times, serif'); + * ``` + * + * @method Phaser.GameObjects.Text#setFontFamily + * @since 3.0.0 + * + * @param {string} family - The font family. + * + * @return {this} This Text object. + * + * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#Valid_family_names + */ + setFontFamily: function (family) + { + return this.style.setFontFamily(family); + }, + + /** + * Set the font size. Can be a string with a valid CSS unit, i.e. `16px`, or a number. + * + * @method Phaser.GameObjects.Text#setFontSize + * @since 3.0.0 + * + * @param {(string|number)} size - The font size. + * + * @return {this} This Text object. + */ + setFontSize: function (size) + { + return this.style.setFontSize(size); + }, + + /** + * Set the font style. + * + * @method Phaser.GameObjects.Text#setFontStyle + * @since 3.0.0 + * + * @param {string} style - The font style. + * + * @return {this} This Text object. + */ + setFontStyle: function (style) + { + return this.style.setFontStyle(style); + }, + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * + * @method Phaser.GameObjects.Text#setFixedSize + * @since 3.0.0 + * + * @param {number} width - The fixed width to set. `0` disables fixed width. + * @param {number} height - The fixed height to set. `0` disables fixed height. + * + * @return {this} This Text object. + */ + setFixedSize: function (width, height) + { + return this.style.setFixedSize(width, height); + }, + + /** + * Set the background color. + * + * @method Phaser.GameObjects.Text#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - The background color. + * + * @return {this} This Text object. + */ + setBackgroundColor: function (color) + { + return this.style.setBackgroundColor(color); + }, + + /** + * Set the fill style to be used by the Text object. + * + * This can be any valid CanvasRenderingContext2D fillStyle value, such as + * a color (in hex, rgb, rgba, hsl or named values), a gradient or a pattern. + * + * See the [MDN fillStyle docs](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle) for more details. + * + * @method Phaser.GameObjects.Text#setFill + * @since 3.0.0 + * + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. + * + * @return {this} This Text object. + */ + setFill: function (fillStyle) + { + return this.style.setFill(fillStyle); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text#setColor + * @since 3.0.0 + * + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill color. + * + * @return {this} This Text object. + */ + setColor: function (color) + { + return this.style.setColor(color); + }, + + /** + * Set the stroke settings. + * + * @method Phaser.GameObjects.Text#setStroke + * @since 3.0.0 + * + * @param {(string|CanvasGradient|CanvasPattern)} color - The stroke color. + * @param {number} thickness - The stroke thickness. + * + * @return {this} This Text object. + */ + setStroke: function (color, thickness) + { + return this.style.setStroke(color, thickness); + }, + + /** + * Set the shadow settings. + * + * @method Phaser.GameObjects.Text#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. + * + * @return {this} This Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); + }, + + /** + * Set the shadow offset. + * + * @method Phaser.GameObjects.Text#setShadowOffset + * @since 3.0.0 + * + * @param {number} x - The horizontal shadow offset. + * @param {number} y - The vertical shadow offset. + * + * @return {this} This Text object. + */ + setShadowOffset: function (x, y) + { + return this.style.setShadowOffset(x, y); + }, + + /** + * Set the shadow color. + * + * @method Phaser.GameObjects.Text#setShadowColor + * @since 3.0.0 + * + * @param {string} color - The shadow color. + * + * @return {this} This Text object. + */ + setShadowColor: function (color) + { + return this.style.setShadowColor(color); + }, + + /** + * Set the shadow blur radius. + * + * @method Phaser.GameObjects.Text#setShadowBlur + * @since 3.0.0 + * + * @param {number} blur - The shadow blur radius. + * + * @return {this} This Text object. + */ + setShadowBlur: function (blur) + { + return this.style.setShadowBlur(blur); + }, + + /** + * Enable or disable shadow stroke. + * + * @method Phaser.GameObjects.Text#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow stroke is enabled or not. + * + * @return {this} This Text object. + */ + setShadowStroke: function (enabled) + { + return this.style.setShadowStroke(enabled); + }, + + /** + * Enable or disable shadow fill. + * + * @method Phaser.GameObjects.Text#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow fill is enabled or not. + * + * @return {this} This Text object. + */ + setShadowFill: function (enabled) + { + return this.style.setShadowFill(enabled); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Text#setWordWrapWidth + * @since 3.0.0 + * + * @param {number | null} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {this} This Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + return this.style.setWordWrapWidth(width, useAdvancedWrap); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Text#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {this} This Text object. + */ + setWordWrapCallback: function (callback, scope) + { + return this.style.setWordWrapCallback(callback, scope); + }, + + /** + * Set the alignment of the text in this Text object. + * + * The argument can be one of: `left`, `right`, `center` or `justify`. + * + * Alignment only works if the Text object has more than one line of text. + * + * @method Phaser.GameObjects.Text#setAlign + * @since 3.0.0 + * + * @param {string} [align='left'] - The text alignment for multi-line text. + * + * @return {this} This Text object. + */ + setAlign: function (align) + { + return this.style.setAlign(align); + }, + + /** + * Set the resolution of the Texture used by this Text object. + * + * Setting resolution above 1 is useful only if you're scaling up this Text object (or an ancestor) or zooming a Camera on it. + * Otherwise, any extra detail in the Texture would just be lost during rendering. + * + * Please use with caution, as the more high-resolution Text you have, the more memory it uses. + * + * @method Phaser.GameObjects.Text#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use, relative to 1. + * + * @return {this} This Text object. + */ + setResolution: function (value) + { + return this.style.setResolution(value); + }, + + /** + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * + * @method Phaser.GameObjects.Text#setLineSpacing + * @since 3.13.0 + * + * @param {number} value - The amount to add to the font height to achieve the overall line height. + * + * @return {this} This Text object. + */ + setLineSpacing: function (value) + { + this.lineSpacing = value; + + return this.updateText(); + }, + + /** + * Sets the letter spacing value. + * + * This will add, or remove spacing between each character of this Text Game Object. The value can be + * either positive or negative. Positive values increase the space between each character, whilst negative + * values decrease it. Note that some fonts are spaced naturally closer together than others. + * + * Please understand that enabling this feature will cause Phaser to render each character in this Text object + * one by one, rather than use a draw for the whole string. This makes it extremely expensive when used with + * either long strings, or lots of strings in total. You will be better off creating bitmap font text if you + * need to display large quantities of characters with fine control over the letter spacing. + * + * @method Phaser.GameObjects.Text#setLetterSpacing + * @since 3.70.0 + * + * @param {number} value - The amount to add to the letter width. Set to zero to disable. + * + * @return {this} This Text object. + */ + setLetterSpacing: function (value) + { + this.letterSpacing = value; + + return this.updateText(); + }, + + /** + * Sets the padding applied around the text content when calculating the canvas size. + * + * The first argument can be either a number or a padding configuration object. When a number + * is given, it is applied to all four sides unless the other arguments override them. When an + * object is given, you can specify `left`, `right`, `top`, and `bottom` individually, or use + * `x` to set both left and right simultaneously, and `y` to set both top and bottom. + * + * @method Phaser.GameObjects.Text#setPadding + * @since 3.0.0 + * + * @param {(number|Phaser.Types.GameObjects.Text.TextPadding)} left - The left padding value, or a padding config object. + * @param {number} [top] - The top padding value. + * @param {number} [right] - The right padding value. + * @param {number} [bottom] - The bottom padding value. + * + * @return {this} This Text object. + */ + setPadding: function (left, top, right, bottom) + { + if (typeof left === 'object') + { + var config = left; + + // If they specify x and/or y this applies to all + var x = GetValue(config, 'x', null); + + if (x !== null) + { + left = x; + right = x; + } + else + { + left = GetValue(config, 'left', 0); + right = GetValue(config, 'right', left); + } + + var y = GetValue(config, 'y', null); + + if (y !== null) + { + top = y; + bottom = y; + } + else + { + top = GetValue(config, 'top', 0); + bottom = GetValue(config, 'bottom', top); + } + } + else + { + if (left === undefined) { left = 0; } + if (top === undefined) { top = left; } + if (right === undefined) { right = left; } + if (bottom === undefined) { bottom = top; } + } + + this.padding.left = left; + this.padding.top = top; + this.padding.right = right; + this.padding.bottom = bottom; + + return this.updateText(); + }, + + /** + * Set the maximum number of lines to draw. + * + * @method Phaser.GameObjects.Text#setMaxLines + * @since 3.0.0 + * + * @param {number} [max=0] - The maximum number of lines to draw. + * + * @return {this} This Text object. + */ + setMaxLines: function (max) + { + return this.style.setMaxLines(max); + }, + + /** + * Render text from right-to-left or left-to-right. + * + * @method Phaser.GameObjects.Text#setRTL + * @since 3.70.0 + * + * @param {boolean} [rtl=true] - Set to `true` to render from right-to-left. + * + * @return {this} This Text object. + */ + setRTL: function (rtl) + { + if (rtl === undefined) { rtl = true; } + + var style = this.style; + + if (style.rtl === rtl) + { + return this; + } + + style.rtl = rtl; + + if (rtl) + { + this.canvas.dir = 'rtl'; + this.context.direction = 'rtl'; + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + } + else + { + this.canvas.dir = 'ltr'; + this.context.direction = 'ltr'; + } + + if (style.align === 'left') + { + style.align = 'right'; + } + else if (style.align === 'right') + { + style.align = 'left'; + } + + return this; + }, + + /** + * Recalculates and re-renders the text content onto the internal canvas. This is called + * automatically whenever the text string or any style property changes. It handles word + * wrapping, text sizing, multi-line layout, alignment, shadows, stroke, and letter spacing. + * If the renderer is WebGL, the updated canvas is re-uploaded to the GPU as a new texture. + * You should call this manually only if you have updated `lineSpacing` or `letterSpacing` + * directly without using their corresponding setter methods. + * + * @method Phaser.GameObjects.Text#updateText + * @since 3.0.0 + * + * @return {this} This Text object. + */ + updateText: function () + { + var canvas = this.canvas; + var context = this.context; + var style = this.style; + var resolution = style.resolution; + var size = style.metrics; + + style.syncFont(canvas, context); + + var outputText = this._text; + + if (style.wordWrapWidth || style.wordWrapCallback) + { + outputText = this.runWordWrap(this._text); + } + + // Split text into lines + var lines = outputText.split(this.splitRegExp); + + var textSize = GetTextSize(this, size, lines); + + var padding = this.padding; + + var textWidth; + + if (style.fixedWidth === 0) + { + this.width = textSize.width + padding.left + padding.right; + + textWidth = textSize.width; + } + else + { + this.width = style.fixedWidth; + + textWidth = this.width - padding.left - padding.right; + + if (textWidth < textSize.width) + { + textWidth = textSize.width; + } + } + + if (style.fixedHeight === 0) + { + this.height = textSize.height + padding.top + padding.bottom; + } + else + { + this.height = style.fixedHeight; + } + + var w = this.width; + var h = this.height; + + this.updateDisplayOrigin(); + + w *= resolution; + h *= resolution; + + w = Math.max(w, 1); + h = Math.max(h, 1); + + if (canvas.width !== w || canvas.height !== h) + { + canvas.width = w; + canvas.height = h; + + this.frame.setSize(w, h); + + // Resizing the canvas changes the size of the texture source. + // Because this is a dedicated texture for this Text object, + // we know this is a simple resize. + this.frame.source.updateSize(w, h); + this.frame.source.resolution = resolution; + this.frame.updateUVs(); + + // Because resizing the canvas resets the context + style.syncFont(canvas, context); + + if (style.rtl) + { + context.direction = 'rtl'; + } + } + else + { + context.clearRect(0, 0, w, h); + } + + context.save(); + + context.scale(resolution, resolution); + + if (style.backgroundColor) + { + context.fillStyle = style.backgroundColor; + context.fillRect(0, 0, w, h); + } + + style.syncStyle(canvas, context); + + // Apply padding + context.translate(padding.left, padding.top); + + var linePositionX; + var linePositionY; + + // Draw text line by line + for (var i = 0; i < textSize.lines; i++) + { + linePositionX = style.strokeThickness / 2; + linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; + + if (i > 0) + { + linePositionY += (textSize.lineSpacing * i); + } + + if (style.rtl) + { + linePositionX = w - linePositionX - padding.left - padding.right; + } + else if (style.align === 'right') + { + linePositionX += textWidth - textSize.lineWidths[i]; + } + else if (style.align === 'center') + { + linePositionX += (textWidth - textSize.lineWidths[i]) / 2; + } + else if (style.align === 'justify') + { + // To justify text line its width must be no less than 85% of defined width + var minimumLengthToApplyJustification = 0.85; + + if (textSize.lineWidths[i] / textSize.width >= minimumLengthToApplyJustification) + { + var extraSpace = textSize.width - textSize.lineWidths[i]; + var spaceSize = context.measureText(' ').width; + var trimmedLine = lines[i].trim(); + var array = trimmedLine.split(' '); + + extraSpace += (lines[i].length - trimmedLine.length) * spaceSize; + + var extraSpaceCharacters = Math.floor(extraSpace / spaceSize); + var idx = 0; + + while (extraSpaceCharacters > 0) + { + array[idx] += ' '; + idx = (idx + 1) % (array.length - 1 || 1); + --extraSpaceCharacters; + } + + lines[i] = array.join(' '); + } + } + + if (this.autoRound) + { + linePositionX = Math.round(linePositionX); + linePositionY = Math.round(linePositionY); + } + + var letterSpacing = this.letterSpacing; + + // Apply stroke to the whole line only if there's no custom letter spacing + + if (style.strokeThickness && letterSpacing === 0) + { + style.syncShadow(context, style.shadowStroke); + + context.strokeText(lines[i], linePositionX, linePositionY); + } + + if (style.color) + { + style.syncShadow(context, style.shadowFill); + + // Looping fillText could be an expensive operation, we should ignore it if it is not needed + + if (letterSpacing !== 0) + { + var charPositionX = 0; + + var line = lines[i].split(''); + + // Draw text letter by letter + for (var l = 0; l < line.length; l++) + { + if (style.strokeThickness) + { + style.syncShadow(context, style.shadowStroke); + + context.strokeText(line[l], linePositionX + charPositionX, linePositionY); + + style.syncShadow(context, style.shadowFill); + } + + context.fillText(line[l], linePositionX + charPositionX, linePositionY); + + charPositionX += context.measureText(line[l]).width + letterSpacing; + } + } + else + { + context.fillText(lines[i], linePositionX, linePositionY); + } + } + } + + context.restore(); + + if (this.renderer && this.renderer.gl) + { + this.frame.source.glTexture = this.renderer.canvasToTexture(canvas, this.frame.source.glTexture, true); + + if (false) + // removed by dead control flow +{} + } + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = this.width; + input.hitArea.height = this.height; + } + + return this; + }, + + /** + * Get the current text metrics. + * + * @method Phaser.GameObjects.Text#getTextMetrics + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.Text.TextMetrics} The text metrics. + */ + getTextMetrics: function () + { + return this.style.getTextMetrics(); + }, + + /** + * The text string being rendered by this Text Game Object. + * + * @name Phaser.GameObjects.Text#text + * @type {string} + * @since 3.0.0 + */ + text: { + + get: function () + { + return this._text; + }, + + set: function (value) + { + this.setText(value); + } + + }, + + /** + * Build a JSON representation of the Text object. + * + * @method Phaser.GameObjects.Text#toJSON + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.JSONGameObject} A JSON representation of the Text object. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra Text data is added here + + var data = { + autoRound: this.autoRound, + text: this._text, + style: this.style.toJSON(), + padding: { + left: this.padding.left, + right: this.padding.right, + top: this.padding.top, + bottom: this.padding.bottom + } + }; + + out.data = data; + + return out; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Text#preDestroy + * @protected + * @since 3.0.0 + */ + preDestroy: function () + { + RemoveFromDOM(this.canvas); + + CanvasPool.remove(this.canvas); + + var texture = this.texture; + + if (texture) + { + texture.destroy(); + } + } + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.Text#originX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.Text#originY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + +}); + +module.exports = Text; + + +/***/ }, + +/***/ 79724 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TextCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + if (src.width === 0 || src.height === 0) + { + return; + } + + camera.addToRenderList(src); + + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = TextCanvasRenderer; + + +/***/ }, + +/***/ 71259 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Text = __webpack_require__(50171); + +/** + * Creates a new Text Game Object and returns it. + * + * A Text Game Object renders a string of text to an internal Canvas texture, which is then + * used as the source for rendering to the game canvas. It supports a wide range of styling + * options including font family, size, weight, fill color, stroke, drop shadow, text alignment, + * word wrapping, padding, fixed dimensions, and right-to-left rendering. The text content and + * style can be updated at any time after creation. + * + * Unlike the factory method (`scene.add.text`), this creator method returns the Text Game Object + * without automatically adding it to the Scene's display list. Use the `add` property in the + * config object, or pass `true` as the `addToScene` argument, to add it to the Scene. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#text + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Text.TextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectCreator.register('text', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + // style Object = { + // font: [ 'font', '16px Courier' ], + // backgroundColor: [ 'backgroundColor', null ], + // fill: [ 'fill', '#fff' ], + // stroke: [ 'stroke', '#fff' ], + // strokeThickness: [ 'strokeThickness', 0 ], + // shadowOffsetX: [ 'shadow.offsetX', 0 ], + // shadowOffsetY: [ 'shadow.offsetY', 0 ], + // shadowColor: [ 'shadow.color', '#000' ], + // shadowBlur: [ 'shadow.blur', 0 ], + // shadowStroke: [ 'shadow.stroke', false ], + // shadowFill: [ 'shadow.fill', false ], + // align: [ 'align', 'left' ], + // maxLines: [ 'maxLines', 0 ], + // fixedWidth: [ 'fixedWidth', false ], + // fixedHeight: [ 'fixedHeight', false ], + // rtl: [ 'rtl', false ] + // } + + var content = GetAdvancedValue(config, 'text', ''); + var style = GetAdvancedValue(config, 'style', null); + + // Padding + // { padding: 2 } + // { padding: { x: , y: }} + // { padding: { left: , top: }} + // { padding: { left: , right: , top: , bottom: }} + + var padding = GetAdvancedValue(config, 'padding', null); + + if (padding !== null) + { + style.padding = padding; + } + + var text = new Text(this.scene, 0, 0, content, style); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, text, config); + + // Text specific config options: + + text.autoRound = GetAdvancedValue(config, 'autoRound', true); + text.resolution = GetAdvancedValue(config, 'resolution', 1); + + return text; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 68005 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Text = __webpack_require__(50171); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Text Game Object and adds it to the Scene. + * + * The Text object renders one or more lines of styled text to an internal hidden Canvas, which is + * then uploaded as a texture and displayed within the Scene. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do this for you, so you will require the use of a 3rd party font loader, + * or have the fonts already available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#text + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {Phaser.Types.GameObjects.Text.TextStyle} [style] - The Text style configuration object. + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectFactory.register('text', function (x, y, text, style) +{ + return this.displayList.add(new Text(this.scene, x, y, text, style)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 61771 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(34397); +} + +if (true) +{ + renderCanvas = __webpack_require__(79724); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 35762 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var MeasureText = __webpack_require__(79557); + +// Key: [ Object Key, Default Value ] + +var propertyMap = { + fontFamily: [ 'fontFamily', 'Courier' ], + fontSize: [ 'fontSize', '16px' ], + fontStyle: [ 'fontStyle', '' ], + backgroundColor: [ 'backgroundColor', null ], + color: [ 'color', '#fff' ], + stroke: [ 'stroke', '#fff' ], + strokeThickness: [ 'strokeThickness', 0 ], + shadowOffsetX: [ 'shadow.offsetX', 0 ], + shadowOffsetY: [ 'shadow.offsetY', 0 ], + shadowColor: [ 'shadow.color', '#000' ], + shadowBlur: [ 'shadow.blur', 0 ], + shadowStroke: [ 'shadow.stroke', false ], + shadowFill: [ 'shadow.fill', false ], + align: [ 'align', 'left' ], + maxLines: [ 'maxLines', 0 ], + fixedWidth: [ 'fixedWidth', 0 ], + fixedHeight: [ 'fixedHeight', 0 ], + resolution: [ 'resolution', 0 ], + rtl: [ 'rtl', false ], + testString: [ 'testString', '|MÉqgy' ], + baselineX: [ 'baselineX', 1.2 ], + baselineY: [ 'baselineY', 1.4 ], + wordWrapWidth: [ 'wordWrap.width', null ], + wordWrapCallback: [ 'wordWrap.callback', null ], + wordWrapCallbackScope: [ 'wordWrap.callbackScope', null ], + wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] +}; + +/** + * @classdesc + * A TextStyle class manages all of the style settings for a Text object. + * + * Text Game Objects create a TextStyle instance automatically, which is + * accessed via the `Text.style` property. You do not normally need to + * instantiate one yourself. + * + * @class TextStyle + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. + * @param {Phaser.Types.GameObjects.Text.TextStyle} style - The style settings to set. + */ +var TextStyle = new Class({ + + initialize: + + function TextStyle (text, style) + { + /** + * The Text object that this TextStyle is styling. + * + * @name Phaser.GameObjects.TextStyle#parent + * @type {Phaser.GameObjects.Text} + * @since 3.0.0 + */ + this.parent = text; + + /** + * The font family. + * + * @name Phaser.GameObjects.TextStyle#fontFamily + * @type {string} + * @default 'Courier' + * @since 3.0.0 + */ + this.fontFamily; + + /** + * The font size. + * + * @name Phaser.GameObjects.TextStyle#fontSize + * @type {(string|number)} + * @default '16px' + * @since 3.0.0 + */ + this.fontSize; + + /** + * The font style. + * + * @name Phaser.GameObjects.TextStyle#fontStyle + * @type {string} + * @since 3.0.0 + */ + this.fontStyle; + + /** + * The background color. + * + * @name Phaser.GameObjects.TextStyle#backgroundColor + * @type {string} + * @since 3.0.0 + */ + this.backgroundColor; + + /** + * The text fill color. + * + * @name Phaser.GameObjects.TextStyle#color + * @type {(string|CanvasGradient|CanvasPattern)} + * @default '#fff' + * @since 3.0.0 + */ + this.color; + + /** + * The text stroke color. + * + * @name Phaser.GameObjects.TextStyle#stroke + * @type {(string|CanvasGradient|CanvasPattern)} + * @default '#fff' + * @since 3.0.0 + */ + this.stroke; + + /** + * The text stroke thickness. + * + * @name Phaser.GameObjects.TextStyle#strokeThickness + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.strokeThickness; + + /** + * The horizontal shadow offset. + * + * @name Phaser.GameObjects.TextStyle#shadowOffsetX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetX; + + /** + * The vertical shadow offset. + * + * @name Phaser.GameObjects.TextStyle#shadowOffsetY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetY; + + /** + * The shadow color. + * + * @name Phaser.GameObjects.TextStyle#shadowColor + * @type {string} + * @default '#000' + * @since 3.0.0 + */ + this.shadowColor; + + /** + * The shadow blur radius. + * + * @name Phaser.GameObjects.TextStyle#shadowBlur + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowBlur; + + /** + * Whether shadow stroke is enabled or not. + * + * @name Phaser.GameObjects.TextStyle#shadowStroke + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowStroke; + + /** + * Whether shadow fill is enabled or not. + * + * @name Phaser.GameObjects.TextStyle#shadowFill + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowFill; + + /** + * The text alignment. + * + * @name Phaser.GameObjects.TextStyle#align + * @type {string} + * @default 'left' + * @since 3.0.0 + */ + this.align; + + /** + * The maximum number of lines to draw. + * + * @name Phaser.GameObjects.TextStyle#maxLines + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxLines; + + /** + * The fixed width of the text. + * + * `0` means no fixed width. + * + * @name Phaser.GameObjects.TextStyle#fixedWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedWidth; + + /** + * The fixed height of the text. + * + * `0` means no fixed height. + * + * @name Phaser.GameObjects.TextStyle#fixedHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedHeight; + + /** + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. + * + * @name Phaser.GameObjects.TextStyle#resolution + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.resolution; + + /** + * Whether the text should render right to left. + * + * @name Phaser.GameObjects.TextStyle#rtl + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rtl; + + /** + * The test string to use when measuring the font. + * + * @name Phaser.GameObjects.TextStyle#testString + * @type {string} + * @default '|MÉqgy' + * @since 3.0.0 + */ + this.testString; + + /** + * The amount of horizontal padding added to the width of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.TextStyle#baselineX + * @type {number} + * @default 1.2 + * @since 3.3.0 + */ + this.baselineX; + + /** + * The amount of vertical padding added to the height of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.TextStyle#baselineY + * @type {number} + * @default 1.4 + * @since 3.3.0 + */ + this.baselineY; + + /** + * The maximum width of a line of text in pixels. Null means no line wrapping. Setting this + * property directly will not re-run the word wrapping algorithm. To change the width and + * re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}. + * + * @name Phaser.GameObjects.TextStyle#wordWrapWidth + * @type {number | null} + * @default null + * @since 3.24.0 + */ + this.wordWrapWidth; + + /** + * A custom function that will be responsible for wrapping the text. It will receive two + * arguments: text (the string to wrap), textObject (this Text instance). It should return + * the wrapped lines either as an array of lines or as a string with newline characters in + * place to indicate where breaks should happen. Setting this directly will not re-run the + * word wrapping algorithm. To change the callback and re-wrap, use + * {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}. + * + * @name Phaser.GameObjects.TextStyle#wordWrapCallback + * @type {TextStyleWordWrapCallback | null} + * @default null + * @since 3.24.0 + */ + this.wordWrapCallback; + + /** + * The scope that will be applied when the wordWrapCallback is invoked. Setting this directly will not re-run the + * word wrapping algorithm. To change the callback and re-wrap, use + * {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}. + * + * @name Phaser.GameObjects.TextStyle#wordWrapCallbackScope + * @type {object | null} + * @default null + * @since 3.24.0 + */ + this.wordWrapCallbackScope; + + /** + * Whether or not to use the advanced wrapping algorithm. If true, spaces are collapsed and + * whitespace is trimmed from lines. If false, spaces and whitespace are left as is. Setting + * this property directly will not re-run the word wrapping algorithm. To change the + * advanced setting and re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}. + * + * @name Phaser.GameObjects.TextStyle#wordWrapUseAdvanced + * @type {boolean} + * @default false + * @since 3.24.0 + */ + this.wordWrapUseAdvanced; + + /** + * The font style, size and family. + * + * @name Phaser.GameObjects.TextStyle#_font + * @type {string} + * @private + * @since 3.0.0 + */ + this._font; + + // Set to defaults + user style + this.setStyle(style, false, true); + }, + + /** + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); + * + * @method Phaser.GameObjects.TextStyle#setStyle + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Text.TextStyle} style - The style settings to set. + * @param {boolean} [updateText=true] - Whether to update the text immediately. + * @param {boolean} [setDefaults=false] - Use the default values if not set, or the local values. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStyle: function (style, updateText, setDefaults) + { + if (updateText === undefined) { updateText = true; } + if (setDefaults === undefined) { setDefaults = false; } + + for (var key in propertyMap) + { + var value = (setDefaults) ? propertyMap[key][1] : this[key]; + + if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') + { + // Callback & scope should be set without processing the values + this[key] = GetValue(style, propertyMap[key][0], value); + } + else if (style && key === 'fontSize' && typeof style.fontSize === 'number') + { + this[key] = style.fontSize.toString() + 'px'; + } + else + { + this[key] = GetAdvancedValue(style, propertyMap[key][0], value); + } + } + + // Allow for 'font' override + var font = GetValue(style, 'font', null); + + if (font !== null) + { + this.setFont(font, false); + } + + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); + + // Allow for 'fill' to be used in place of 'color' + var fill = GetValue(style, 'fill', null); + + if (fill !== null) + { + this.color = fill; + } + + var metrics = GetValue(style, 'metrics', false); + + // Provide optional TextMetrics in the style object to avoid the canvas look-up / scanning + // Doing this is reset if you then change the font of this TextStyle after creation + if (metrics) + { + this.metrics = { + ascent: GetValue(metrics, 'ascent', 0), + descent: GetValue(metrics, 'descent', 0), + fontSize: GetValue(metrics, 'fontSize', 0) + }; + } + else if (updateText || !this.metrics) + { + this.metrics = MeasureText(this); + } + + if (updateText) + { + return this.parent.updateText(); + } + else + { + return this.parent; + } + }, + + /** + * Synchronize the font settings to the given Canvas Rendering Context. + * + * @method Phaser.GameObjects.TextStyle#syncFont + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + */ + syncFont: function (canvas, context) + { + context.font = this._font; + }, + + /** + * Synchronize the text style settings to the given Canvas Rendering Context. + * + * @method Phaser.GameObjects.TextStyle#syncStyle + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + */ + syncStyle: function (canvas, context) + { + context.textBaseline = 'alphabetic'; + + context.fillStyle = this.color; + context.strokeStyle = this.stroke; + + context.lineWidth = this.strokeThickness; + context.lineCap = 'round'; + context.lineJoin = 'round'; + }, + + /** + * Synchronize the shadow settings to the given Canvas Rendering Context. + * + * @method Phaser.GameObjects.TextStyle#syncShadow + * @since 3.0.0 + * + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {boolean} enabled - Whether shadows are enabled or not. + */ + syncShadow: function (context, enabled) + { + if (enabled) + { + context.shadowOffsetX = this.shadowOffsetX; + context.shadowOffsetY = this.shadowOffsetY; + context.shadowColor = this.shadowColor; + context.shadowBlur = this.shadowBlur; + } + else + { + context.shadowOffsetX = 0; + context.shadowOffsetY = 0; + context.shadowColor = 0; + context.shadowBlur = 0; + } + }, + + /** + * Update the style settings for the parent Text object. + * + * @method Phaser.GameObjects.TextStyle#update + * @since 3.0.0 + * + * @param {boolean} recalculateMetrics - Whether to recalculate font and text metrics. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + update: function (recalculateMetrics) + { + if (recalculateMetrics) + { + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); + + this.metrics = MeasureText(this); + } + + return this.parent.updateText(); + }, + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * @method Phaser.GameObjects.TextStyle#setFont + * @since 3.0.0 + * + * @param {(string|object)} font - The font family or font settings to set. + * @param {boolean} [updateText=true] - Whether to update the text immediately. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFont: function (font, updateText) + { + if (updateText === undefined) { updateText = true; } + + var fontFamily = font; + var fontSize = ''; + var fontStyle = ''; + + if (typeof font !== 'string') + { + fontFamily = GetValue(font, 'fontFamily', 'Courier'); + fontSize = GetValue(font, 'fontSize', '16px'); + fontStyle = GetValue(font, 'fontStyle', ''); + } + else + { + var fontSplit = font.split(' '); + + var i = 0; + + fontStyle = (fontSplit.length > 2) ? fontSplit[i++] : ''; + fontSize = fontSplit[i++] || '16px'; + fontFamily = fontSplit[i++] || 'Courier'; + } + + if (fontFamily !== this.fontFamily || fontSize !== this.fontSize || fontStyle !== this.fontStyle) + { + this.fontFamily = fontFamily; + this.fontSize = fontSize; + this.fontStyle = fontStyle; + + if (updateText) + { + this.update(true); + } + } + + return this.parent; + }, + + /** + * Set the font family. This should be a valid CSS font-family value, such as `'Arial'`, `'verdana'`, or `'Courier'`. Font names with spaces should be wrapped in single quotes, e.g. `'Comic Sans MS'`. + * + * @method Phaser.GameObjects.TextStyle#setFontFamily + * @since 3.0.0 + * + * @param {string} family - The font family. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontFamily: function (family) + { + if (this.fontFamily !== family) + { + this.fontFamily = family; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the font style, such as `'bold'`, `'italic'`, or `'bold italic'`. Use an empty string to clear the style. + * + * @method Phaser.GameObjects.TextStyle#setFontStyle + * @since 3.0.0 + * + * @param {string} style - The font style. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontStyle: function (style) + { + if (this.fontStyle !== style) + { + this.fontStyle = style; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the font size. Can be a string with a valid CSS unit, i.e. `16px`, or a number. + * + * @method Phaser.GameObjects.TextStyle#setFontSize + * @since 3.0.0 + * + * @param {(number|string)} size - The font size. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontSize: function (size) + { + if (typeof size === 'number') + { + size = size.toString() + 'px'; + } + + if (this.fontSize !== size) + { + this.fontSize = size; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the test string to use when measuring the font. + * + * @method Phaser.GameObjects.TextStyle#setTestString + * @since 3.0.0 + * + * @param {string} string - The test string to use when measuring the font. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setTestString: function (string) + { + this.testString = string; + + return this.update(true); + }, + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * + * @method Phaser.GameObjects.TextStyle#setFixedSize + * @since 3.0.0 + * + * @param {number} width - The fixed width to set. + * @param {number} height - The fixed height to set. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFixedSize: function (width, height) + { + this.fixedWidth = width; + this.fixedHeight = height; + + if (width) + { + this.parent.width = width; + } + + if (height) + { + this.parent.height = height; + } + + return this.update(false); + }, + + /** + * Set the background color displayed behind the text. This should be a CSS color string, such as `'#ff0000'` or `'rgba(0,0,0,0.5)'`. Set to `null` to disable. + * + * @method Phaser.GameObjects.TextStyle#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - The background color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setBackgroundColor: function (color) + { + this.backgroundColor = color; + + return this.update(false); + }, + + /** + * Set the text fill color. This can be any valid CSS color string such as a hex value `'#ff0000'`, an rgba string, or a named color. It can also be a CanvasGradient or CanvasPattern for more complex fill styles. + * + * @method Phaser.GameObjects.TextStyle#setFill + * @since 3.0.0 + * + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFill: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * Set the text fill color. This can be any valid CSS color string, CanvasGradient, or CanvasPattern. + * + * @method Phaser.GameObjects.TextStyle#setColor + * @since 3.0.0 + * + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setColor: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * Set the resolution used by the Text object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because + * it uses larger internal Canvas textures for the Text. + * + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * + * @method Phaser.GameObjects.TextStyle#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setResolution: function (value) + { + this.resolution = value; + + return this.update(false); + }, + + /** + * Set the stroke settings. + * + * @method Phaser.GameObjects.TextStyle#setStroke + * @since 3.0.0 + * + * @param {(string|CanvasGradient|CanvasPattern)} color - The stroke color. + * @param {number} thickness - The stroke thickness. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStroke: function (color, thickness) + { + if (thickness === undefined) { thickness = this.strokeThickness; } + + if (color === undefined && this.strokeThickness !== 0) + { + // Reset the stroke to zero (disabling it) + this.strokeThickness = 0; + + this.update(true); + } + else if (this.stroke !== color || this.strokeThickness !== thickness) + { + this.stroke = color; + this.strokeThickness = thickness; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the shadow settings. + * + * Calling this method always re-renders the parent Text object, + * so only call it when you actually change the shadow settings. + * + * @method Phaser.GameObjects.TextStyle#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (color === undefined) { color = '#000'; } + if (blur === undefined) { blur = 0; } + if (shadowStroke === undefined) { shadowStroke = false; } + if (shadowFill === undefined) { shadowFill = true; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + this.shadowColor = color; + this.shadowBlur = blur; + this.shadowStroke = shadowStroke; + this.shadowFill = shadowFill; + + return this.update(false); + }, + + /** + * Set the shadow offset. + * + * @method Phaser.GameObjects.TextStyle#setShadowOffset + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + + return this.update(false); + }, + + /** + * Set the shadow color. + * + * @method Phaser.GameObjects.TextStyle#setShadowColor + * @since 3.0.0 + * + * @param {string} [color='#000'] - The shadow color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowColor: function (color) + { + if (color === undefined) { color = '#000'; } + + this.shadowColor = color; + + return this.update(false); + }, + + /** + * Set the shadow blur radius. + * + * @method Phaser.GameObjects.TextStyle#setShadowBlur + * @since 3.0.0 + * + * @param {number} [blur=0] - The shadow blur radius. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowBlur: function (blur) + { + if (blur === undefined) { blur = 0; } + + this.shadowBlur = blur; + + return this.update(false); + }, + + /** + * Enable or disable shadow stroke. + * + * @method Phaser.GameObjects.TextStyle#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow stroke is enabled or not. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowStroke: function (enabled) + { + this.shadowStroke = enabled; + + return this.update(false); + }, + + /** + * Enable or disable shadow fill. + * + * @method Phaser.GameObjects.TextStyle#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow fill is enabled or not. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowFill: function (enabled) + { + this.shadowFill = enabled; + + return this.update(false); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. + * + * Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.TextStyle#setWordWrapWidth + * @since 3.0.0 + * + * @param {number | null} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + if (useAdvancedWrap === undefined) { useAdvancedWrap = false; } + + this.wordWrapWidth = width; + this.wordWrapUseAdvanced = useAdvancedWrap; + + return this.update(false); + }, + + /** + * Set a custom callback for wrapping lines. + * + * Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.TextStyle#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapCallback: function (callback, scope) + { + if (scope === undefined) { scope = null; } + + this.wordWrapCallback = callback; + this.wordWrapCallbackScope = scope; + + return this.update(false); + }, + + /** + * Set the alignment of the text in this Text object. + * + * The argument can be one of: `left`, `right`, `center` or `justify`. + * + * Alignment only works if the Text object has more than one line of text. + * + * @method Phaser.GameObjects.TextStyle#setAlign + * @since 3.0.0 + * + * @param {string} [align='left'] - The text alignment for multi-line text. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setAlign: function (align) + { + if (align === undefined) { align = 'left'; } + + this.align = align; + + return this.update(false); + }, + + /** + * Set the maximum number of lines to draw. + * + * @method Phaser.GameObjects.TextStyle#setMaxLines + * @since 3.0.0 + * + * @param {number} [max=0] - The maximum number of lines to draw. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setMaxLines: function (max) + { + if (max === undefined) { max = 0; } + + this.maxLines = max; + + return this.update(false); + }, + + /** + * Get the current text metrics. + * + * @method Phaser.GameObjects.TextStyle#getTextMetrics + * @since 3.0.0 + * + * @return {Phaser.Types.GameObjects.Text.TextMetrics} The text metrics. + */ + getTextMetrics: function () + { + var metrics = this.metrics; + + return { + ascent: metrics.ascent, + descent: metrics.descent, + fontSize: metrics.fontSize + }; + }, + + /** + * Build a JSON representation of this Text Style. + * + * @method Phaser.GameObjects.TextStyle#toJSON + * @since 3.0.0 + * + * @return {object} A JSON representation of this Text Style. + */ + toJSON: function () + { + var output = {}; + + for (var key in propertyMap) + { + output[key] = this[key]; + } + + output.metrics = this.getTextMetrics(); + + return output; + }, + + /** + * Destroy this Text Style. + * + * @method Phaser.GameObjects.TextStyle#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent = undefined; + } + +}); + +module.exports = TextStyle; + + +/***/ }, + +/***/ 34397 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TextWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + if (src.width === 0 || src.height === 0) + { + return; + } + + drawingContext.camera.addToRenderList(src); + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext, + src, + parentMatrix, + 0, + customRenderNodes.Texturer || defaultRenderNodes.Texturer, + customRenderNodes.Transformer || defaultRenderNodes.Transformer + ); +}; + +module.exports = TextWebGLRenderer; + + +/***/ }, + +/***/ 20839 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AnimationState = __webpack_require__(9674); +var CanvasPool = __webpack_require__(27919); +var DefaultTileSpriteNodes = __webpack_require__(41571); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var Smoothing = __webpack_require__(68703); +var TileSpriteRender = __webpack_require__(56295); +var UUID = __webpack_require__(45650); +var Vector2 = __webpack_require__(26099); + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * @classdesc + * A TileSprite is a Sprite that has a repeating texture. + * + * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and + * are designed so that you can create game backdrops using seamless textures as a source. + * + * You shouldn't ever create a TileSprite any larger than your actual canvas size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the canvas size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * Prior to Phaser 4, TileSprite did not support rotation. + * In WebGL, it required the texture to be a power of two in size, + * and did not support compressed textures or DynamicTextures. + * It could introduce aliasing artifacts for textures that were not + * a power of two in size. + * These restrictions have been lifted in v4. + * + * @class TileSprite + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {number} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} textureKey - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. Cannot be a DynamicTexture. + * @param {(string|number)} [frameKey] - An optional frame from the Texture this Game Object is rendering with. + */ +var TileSprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Lighting, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + TileSpriteRender + ], + + initialize: + + function TileSprite (scene, x, y, width, height, textureKey, frameKey) + { + var renderer = scene.sys.renderer; + + var isCanvas = renderer && !renderer.gl; + + GameObject.call(this, scene, 'TileSprite'); + + var displayTexture = scene.sys.textures.get(textureKey); + var displayFrame = displayTexture.get(frameKey); + + width = width ? Math.floor(width) : displayFrame.width; + height = height ? Math.floor(height) : displayFrame.height; + + /** + * Internal tile position vector. + * + * @name Phaser.GameObjects.TileSprite#_tilePosition + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tilePosition = new Vector2(); + + /** + * Internal tile scale vector. + * + * @name Phaser.GameObjects.TileSprite#_tileScale + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tileScale = new Vector2(1, 1); + + /** + * Internal tile rotation value. + * + * @name Phaser.GameObjects.TileSprite#_tileRotation + * @type {number} + * @private + * @since 4.0.0 + */ + this._tileRotation = 0; + + /** + * Whether the Tile Sprite has changed in some way, requiring a re-render of its tile texture. + * + * Such changes include the texture frame and scroll position of the Tile Sprite. + * + * This is irrelevant in WebGL mode. + * + * @name Phaser.GameObjects.TileSprite#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + /** + * The renderer in use by this Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = renderer; + + /** + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#canvas + * @type {?HTMLCanvasElement} + * @since 3.12.0 + */ + this.canvas = isCanvas ? CanvasPool.create(this, width, height) : null; + + /** + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#context + * @type {?CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.context = isCanvas ? this.canvas.getContext('2d', { willReadFrequently: false }) : null; + + /** + * The internal unique key to refer to the texture in the TextureManager. + * + * @name Phaser.GameObjects.TileSprite#_displayTextureKey + * @type {string} + * @private + * @since 3.80.0 + */ + this._displayTextureKey = UUID(); + + /** + * The internal Texture to which the TileSprite renders its fill pattern. Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#displayTexture + * @type {?(Phaser.Textures.Texture|Phaser.Textures.CanvasTexture)} + * @private + * @since 3.12.0 + */ + this.displayTexture = isCanvas ? scene.sys.textures.addCanvas(this._displayTextureKey, this.canvas) : null; + + /** + * The internal Texture Frame the TileSprite is using as its fill pattern. Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#displayFrame + * @type {?Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.displayFrame = this.displayTexture ? this.displayTexture.get() : null; + + /** + * The frame currently displayed. This is used internally to track + * animation updates. + * + * @name Phaser.GameObjects.TileSprite#currentFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 4.0.0 + */ + this.currentFrame = null; + + /** + * The Canvas that the TileSprite's texture is rendered to. + * This is used to create a WebGL texture from. + * + * @name Phaser.GameObjects.TileSprite#fillCanvas + * @type {HTMLCanvasElement} + * @since 3.12.0 + */ + this.fillCanvas = isCanvas ? CanvasPool.create2D(this, displayFrame.width, this.displayFrame.height) : null; + + /** + * The Canvas Context used to render the TileSprite's texture. + * + * @name Phaser.GameObjects.TileSprite#fillContext + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.fillContext = this.fillCanvas ? this.fillCanvas.getContext('2d', { willReadFrequently: false }) : null; + + /** + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTextureWrapper. In Canvas it's a Canvas Fill Pattern. + * + * @name Phaser.GameObjects.TileSprite#fillPattern + * @type {?(Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper|CanvasPattern)} + * @since 3.12.0 + */ + this.fillPattern = null; + + /** + * The Animation State component of this TileSprite. + * + * This component provides features to apply animations to this TileSprite. + * It is responsible for playing, loading, queuing animations for later playback, + * mixing between animations and setting the current animation frame to this TileSprite. + * + * @name Phaser.GameObjects.TileSprite#anims + * @type {Phaser.Animations.AnimationState} + * @since 3.0.0 + */ + this.anims = new AnimationState(this); + + this.setTexture(textureKey, frameKey); + this.setPosition(x, y); + this.setSize(width, height); + this.setOrigin(0.5, 0.5); + this.initRenderNodes(this._defaultRenderNodesMap); + }, + + /** + * The default render nodes for this Game Object. + * + * @name Phaser.GameObjects.TileSprite#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultTileSpriteNodes; + } + }, + + /** + * Adds this TileSprite to the Scene's update list, so that its `preUpdate` method + * is called each game step to advance its animations. Called automatically when + * this Game Object is added to a Scene. + * + * @method Phaser.GameObjects.TileSprite#addedToScene + * @since 3.50.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Removes this TileSprite from the Scene's update list, stopping its `preUpdate` + * method from being called. Called automatically when this Game Object is removed + * from a Scene. + * + * @method Phaser.GameObjects.TileSprite#removedFromScene + * @since 3.50.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * Update this TileSprite's animations. + * + * @method Phaser.GameObjects.TileSprite#preUpdate + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.TileSprite#setFrame + * @since 3.0.0 + * + * @param {(string|number)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + var newFrame = this.texture.get(frame); + + if (!newFrame.cutWidth || !newFrame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + this.frame = newFrame; + + this.dirty = true; + + return this; + }, + + /** + * No-op method for compatibility with Animation. + * + * @method Phaser.GameObjects.TileSprite#setSizeToFrame + * @since 4.0.0 + * @return {this} This Tile Sprite instance. + */ + setSizeToFrame: function () + { + return this; + }, + + /** + * Sets the horizontal and vertical scroll position of the tiling texture, updating + * {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * Either value may be omitted to leave it unchanged. + * + * @method Phaser.GameObjects.TileSprite#setTilePosition + * @since 3.3.0 + * + * @param {number} [x] - The x position of this sprite's tiling texture. + * @param {number} [y] - The y position of this sprite's tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTilePosition: function (x, y) + { + if (x !== undefined) + { + this.tilePositionX = x; + } + + if (y !== undefined) + { + this.tilePositionY = y; + } + + return this; + }, + + /** + * Sets the rotation of the tiling texture, in radians, updating + * {@link Phaser.GameObjects.TileSprite#tileRotation}. + * The texture rotates around its own origin, independently of the TileSprite's world rotation. + * + * @method Phaser.GameObjects.TileSprite#setTileRotation + * @since 4.0.0 + * + * @param {number} [radians=0] - The rotation of the tiling texture, in radians. + */ + setTileRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.tileRotation = radians; + + return this; + }, + + /** + * Sets the horizontal and vertical scale of the tiling texture, updating + * {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * The scale is independent of the TileSprite's own scale. If only `x` is provided, + * both axes are set to the same value. + * + * @method Phaser.GameObjects.TileSprite#setTileScale + * @since 3.12.0 + * + * @param {number} [x] - The horizontal scale of the tiling texture. If not given it will use the current `tileScaleX` value. + * @param {number} [y=x] - The vertical scale of the tiling texture. If not given it will use the `x` value. + * + * @return {this} This Tile Sprite instance. + */ + setTileScale: function (x, y) + { + if (x === undefined) { x = this.tileScaleX; } + if (y === undefined) { y = x; } + + this.tileScaleX = x; + this.tileScaleY = y; + + return this; + }, + + /** + * Render the tile texture if it is dirty, or if the frame has changed. + * + * This is called automatically during Canvas rendering. + * It is not used by WebGL. + * + * @method Phaser.GameObjects.TileSprite#updateTileTexture + * @private + * @since 3.0.0 + */ + updateTileTexture: function () + { + if (!this.renderer || this.renderer.gl) + { + return; + } + + // Draw the texture to our fillCanvas + + var frame = this.frame; + + var ctx = this.fillContext; + var canvas = this.fillCanvas; + + var fw = frame.cutWidth; + var fh = frame.cutHeight; + + ctx.clearRect(0, 0, fw, fh); + + canvas.width = fw; + canvas.height = fh; + + ctx.drawImage( + frame.source.image, + frame.cutX, frame.cutY, + frame.cutWidth, frame.cutHeight, + 0, 0, + fw, fh + ); + + this.fillPattern = ctx.createPattern(canvas, 'repeat'); + + this.currentFrame = frame; + }, + + /** + * Draw the fill pattern to the internal canvas. + * + * This is called automatically during Canvas rendering. + * It is not used by WebGL. + * + * @method Phaser.GameObjects.TileSprite#updateCanvas + * @private + * @since 3.12.0 + */ + updateCanvas: function () + { + var canvas = this.canvas; + var width = this.width; + var height = this.height; + + var newFrame = this.currentFrame !== this.frame; + + if (canvas.width !== width || canvas.height !== height || newFrame) + { + canvas.width = width; + canvas.height = height; + + this.displayFrame.setSize(width, height); + this.updateDisplayOrigin(); + + if (newFrame) + { + this.updateTileTexture(); + } + + this.dirty = true; + } + + if (!this.dirty || this.renderer && this.renderer.gl) + { + this.dirty = false; + return; + } + + var ctx = this.context; + + if (!this.scene.sys.game.config.antialias) + { + Smoothing.disable(ctx); + } + + var scaleX = this._tileScale.x; + var scaleY = this._tileScale.y; + + var positionX = this._tilePosition.x; + var positionY = this._tilePosition.y; + + ctx.clearRect(0, 0, width, height); + + ctx.save(); + + ctx.rotate(this._tileRotation); + + ctx.scale(scaleX, scaleY); + + ctx.translate(-positionX, -positionY); + + ctx.fillStyle = this.fillPattern; + + var scaledWidth = Math.max(width, Math.abs(width / scaleX)); + var scaledHeight = Math.max(height, Math.abs(height / scaleY)); + var hypotenuse = Math.sqrt(scaledWidth * scaledWidth + scaledHeight * scaledHeight); + + ctx.fillRect( + positionX - hypotenuse, + positionY - hypotenuse, + 2 * hypotenuse, + 2 * hypotenuse + ); + + ctx.restore(); + + this.dirty = false; + }, + + /** + * Sets the size of this TileSprite's output region. + * + * This does not change the scale. + * + * If you have enabled this Game Object for input, changing the size will also change the + * size of the hit area, unless you have defined a custom hit area. + * + * @method Phaser.GameObjects.TileSprite#setSize + * @since 4.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + this.updateDisplayOrigin(); + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = width; + input.hitArea.height = height; + } + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.TileSprite#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (this.canvas) + { + CanvasPool.remove(this.canvas); + } + if (this.fillCanvas) + { + CanvasPool.remove(this.fillCanvas); + } + + this.fillPattern = null; + this.fillContext = null; + this.fillCanvas = null; + + this.displayTexture = null; + this.displayFrame = null; + + this.renderer = null; + + this.anims.destroy(); + + this.anims = undefined; + }, + + /** + * The horizontal scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionX: { + + get: function () + { + return this._tilePosition.x; + }, + + set: function (value) + { + this._tilePosition.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionY: { + + get: function () + { + return this._tilePosition.y; + }, + + set: function (value) + { + this._tilePosition.y = value; + this.dirty = true; + } + + }, + + /** + * The rotation of the Tile Sprite texture, in radians. + * + * @name Phaser.GameObjects.TileSprite#tileRotation + * @type {number} + * @default 0 + * @since 4.0.0 + */ + tileRotation: { + get: function () + { + return this._tileRotation; + }, + + set: function (radians) + { + this._tileRotation = radians; + this.dirty = true; + } + }, + + /** + * The horizontal scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleX + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleX: { + + get: function () + { + return this._tileScale.x; + }, + + set: function (value) + { + this._tileScale.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleY + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleY: { + + get: function () + { + return this._tileScale.y; + }, + + set: function (value) + { + this._tileScale.y = value; + this.dirty = true; + } + + } + +}); + +module.exports = TileSprite; + + +/***/ }, + +/***/ 46992 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TileSpriteCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + src.updateCanvas(); + + camera.addToRenderList(src); + + renderer.batchSprite(src, src.displayFrame, camera, parentMatrix); +}; + +module.exports = TileSpriteCanvasRenderer; + + +/***/ }, + +/***/ 14167 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var TileSprite = __webpack_require__(20839); + +/** + * Creates a new TileSprite Game Object and returns it. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tileSprite + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.TileSprite.TileSpriteConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectCreator.register('tileSprite', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 512); + var height = GetAdvancedValue(config, 'height', 512); + var key = GetAdvancedValue(config, 'key', ''); + var frame = GetAdvancedValue(config, 'frame', ''); + + var tile = new TileSprite(this.scene, x, y, width, height, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, tile, config); + + return tile; +}); + + +/***/ }, + +/***/ 91681 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var TileSprite = __webpack_require__(20839); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tileSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {number} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {(string|Phaser.Textures.Texture)} texture - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. Cannot be a DynamicTexture. + * @param {(string|number)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectFactory.register('tileSprite', function (x, y, width, height, texture, frame) +{ + return this.displayList.add(new TileSprite(this.scene, x, y, width, height, texture, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 56295 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(18553); +} + +if (true) +{ + renderCanvas = __webpack_require__(46992); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 18553 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TileSpriteWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + var width = src.width; + var height = src.height; + + if (width === 0 || height === 0) + { + return; + } + + var camera = drawingContext.camera; + camera.addToRenderList(src); + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext, + src, + parentMatrix, + 0, + customRenderNodes.Texturer || defaultRenderNodes.Texturer, + customRenderNodes.Transformer || defaultRenderNodes.Transformer + ); +}; + +module.exports = TileSpriteWebGLRenderer; + + +/***/ }, + +/***/ 18471 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var DefaultImageNodes = __webpack_require__(40939); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Events = __webpack_require__(51708); +var GameEvents = __webpack_require__(8443); +var GameObject = __webpack_require__(95643); +var MATH_CONST = __webpack_require__(36383); +var SoundEvents = __webpack_require__(14463); +var UUID = __webpack_require__(45650); +var VideoRender = __webpack_require__(10247); + +/** + * @classdesc + * A Video Game Object. + * + * This Game Object is capable of handling playback of a video file, video stream or media stream. + * + * You can optionally 'preload' the video into the Phaser Video Cache: + * + * ```javascript + * preload () { + * this.load.video('ripley', 'assets/aliens.mp4'); + * } + * + * create () { + * this.add.video(400, 300, 'ripley'); + * } + * ``` + * + * You don't have to 'preload' the video. You can also play it directly from a URL: + * + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4'); + * } + * ``` + * + * To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do + * all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a + * physics body, etc. + * + * Transparent videos are also possible via the WebM file format. Providing the video file has was encoded with + * an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render + * in-game with full transparency. + * + * Transparent videos are supported by the HEVC (H.265) codec, + * but only on some devices and browsers, and sometimes the alpha channel is ignored, + * which can be a problem if you're aiming for a consistent experience. + * We advise against relying on HEVC. + * + * Playback is handled entirely via the Request Video Frame API, which is supported by most modern browsers. + * A polyfill is provided for older browsers. + * + * ### Autoplaying Videos + * + * Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings. + * The policies that control autoplaying are vast and vary between browser. You can, and should, read more about + * it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide + * + * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_, + * and it will often allow the video to play immediately: + * + * ```javascript + * preload () { + * this.load.video('pixar', 'nemo.mp4', true); + * } + * ``` + * + * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without + * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies + * the browsers MEI settings. See the MDN Autoplay Guide for further details. + * + * Or: + * + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4', true); + * } + * ``` + * + * You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video + * to play immediately, but the audio will not start. + * + * More details about video playback and the supported media formats can be found on MDN: + * + * https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement + * https://developer.mozilla.org/en-US/docs/Web/Media/Formats + * + * @class Video + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.20.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Lighting + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.RenderNodes + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} [key] - Optional key of the Video this Game Object will play, as stored in the Video Cache. + */ +var Video = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Lighting, + Components.Mask, + Components.Origin, + Components.RenderNodes, + Components.ScrollFactor, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + VideoRender + ], + + initialize: + + function Video (scene, x, y, key) + { + GameObject.call(this, scene, 'Video'); + + /** + * A reference to the HTML Video Element this Video Game Object is playing. + * + * Will be `undefined` until a video is loaded for playback. + * + * @name Phaser.GameObjects.Video#video + * @type {?HTMLVideoElement} + * @since 3.20.0 + */ + this.video; + + /** + * The Phaser Texture this Game Object is using to render the video to. + * + * Will be `undefined` until a video is loaded for playback. + * + * @name Phaser.GameObjects.Video#videoTexture + * @type {?Phaser.Textures.Texture} + * @since 3.20.0 + */ + this.videoTexture; + + /** + * A reference to the TextureSource backing the `videoTexture` Texture object. + * + * Will be `undefined` until a video is loaded for playback. + * + * @name Phaser.GameObjects.Video#videoTextureSource + * @type {?Phaser.Textures.TextureSource} + * @since 3.20.0 + */ + this.videoTextureSource; + + /** + * A Phaser `CanvasTexture` instance that holds the most recent snapshot taken from the video. + * + * This will only be set if the `snapshot` or `snapshotArea` methods have been called. + * + * Until those methods are called, this property will be `undefined`. + * + * @name Phaser.GameObjects.Video#snapshotTexture + * @type {?Phaser.Textures.CanvasTexture} + * @since 3.20.0 + */ + this.snapshotTexture; + + /** + * If you have saved this video to a texture via the `saveTexture` method, this controls if the video + * is rendered with `flipY` in WebGL or not. + * If you find your video is appearing upside down within a shader or + * custom renderer, flip this property. + * + * @name Phaser.GameObjects.Video#glFlipY + * @type {boolean} + * @since 4.0.0 + */ + this.glFlipY = true; + + /** + * The key used by the texture as stored in the Texture Manager. + * + * @name Phaser.GameObjects.Video#_key + * @type {string} + * @private + * @since 3.20.0 + */ + this._key = UUID(); + + /** + * An internal flag holding the current state of the video lock, should document interaction be required + * before playback can begin. + * + * @name Phaser.GameObjects.Video#touchLocked + * @type {boolean} + * @readonly + * @since 3.20.0 + */ + this.touchLocked = false; + + /** + * Should the video auto play when document interaction is required and happens? + * + * @name Phaser.GameObjects.Video#playWhenUnlocked + * @type {boolean} + * @since 3.20.0 + */ + this.playWhenUnlocked = false; + + /** + * Has the video created its texture and populated it with the first frame of video? + * + * @name Phaser.GameObjects.Video#frameReady + * @type {boolean} + * @since 3.60.0 + */ + this.frameReady = false; + + /** + * This read-only property returns `true` if the video is currently stalled, i.e. it has stopped + * playing due to a lack of data, or too much data, but hasn't yet reached the end of the video. + * + * This is set if the Video DOM element emits any of the following events: + * + * `stalled` + * `suspend` + * `waiting` + * + * And is cleared if the Video DOM element emits the `playing` event, or handles + * a requestVideoFrame call. + * + * Listen for the Phaser Event `VIDEO_STALLED` to be notified and inspect the event + * to see which DOM event caused it. + * + * Note that being stalled isn't always a negative thing. A video can be stalled if it + * has downloaded enough data in to its buffer to not need to download any more until + * the current batch of frames have rendered. + * + * @name Phaser.GameObjects.Video#isStalled + * @type {boolean} + * @readonly + * @since 3.60.0 + */ + this.isStalled = false; + + /** + * Records the number of times the video has failed to play, + * typically because the user hasn't interacted with the page yet. + * + * @name Phaser.GameObjects.Video#failedPlayAttempts + * @type {number} + * @since 3.60.0 + */ + this.failedPlayAttempts = 0; + + /** + * If the browser supports the Request Video Frame API then this + * property will hold the metadata that is returned from + * the callback each time it is invoked. + * + * See https://wicg.github.io/video-rvfc/#video-frame-metadata-callback + * for a complete list of all properties that will be in this object. + * Likely of most interest is the `mediaTime` property: + * + * The media presentation timestamp (PTS) in seconds of the frame presented + * (e.g. its timestamp on the video.currentTime timeline). MAY have a zero + * value for live-streams or WebRTC applications. + * + * If the browser doesn't support the API then this property will be undefined. + * + * @name Phaser.GameObjects.Video#metadata + * @type {VideoFrameCallbackMetadata} + * @since 3.60.0 + */ + this.metadata; + + /** + * The current retry elapsed time. + * + * @name Phaser.GameObjects.Video#retry + * @type {number} + * @since 3.20.0 + */ + this.retry = 0; + + /** + * If a video fails to play due to a lack of user interaction, this is the + * amount of time, in ms, that the video will wait before trying again to + * play. The default is 500ms. + * + * @name Phaser.GameObjects.Video#retryInterval + * @type {number} + * @since 3.20.0 + */ + this.retryInterval = 500; + + /** + * The video was muted due to a system event, such as the game losing focus. + * + * @name Phaser.GameObjects.Video#_systemMuted + * @type {boolean} + * @private + * @since 3.20.0 + */ + this._systemMuted = false; + + /** + * The video was muted due to game code, not a system event. + * + * @name Phaser.GameObjects.Video#_codeMuted + * @type {boolean} + * @private + * @since 3.20.0 + */ + this._codeMuted = false; + + /** + * The video was paused due to a system event, such as the game losing focus. + * + * @name Phaser.GameObjects.Video#_systemPaused + * @type {boolean} + * @private + * @since 3.20.0 + */ + this._systemPaused = false; + + /** + * The video was paused due to game code, not a system event. + * + * @name Phaser.GameObjects.Video#_codePaused + * @type {boolean} + * @private + * @since 3.20.0 + */ + this._codePaused = false; + + /** + * The locally bound event callback handlers. + * + * @name Phaser.GameObjects.Video#_callbacks + * @type {any} + * @private + * @since 3.20.0 + */ + this._callbacks = { + ended: this.completeHandler.bind(this), + legacy: this.legacyPlayHandler.bind(this), + playing: this.playingHandler.bind(this), + seeked: this.seekedHandler.bind(this), + seeking: this.seekingHandler.bind(this), + stalled: this.stalledHandler.bind(this), + suspend: this.stalledHandler.bind(this), + waiting: this.stalledHandler.bind(this) + }; + + /** + * The locally bound callback handler specifically for load and load error events. + * + * @name Phaser.GameObjects.Video#_loadCallbackHandler + * @type {function} + * @private + * @since 3.60.0 + */ + this._loadCallbackHandler = this.loadErrorHandler.bind(this); + + /** + * The locally bound callback handler specifically for the loadedmetadata event. + * + * @name Phaser.GameObjects.Video#_metadataCallbackHandler + * @type {function} + * @private + * @since 3.80.0 + */ + this._metadataCallbackHandler = this.metadataHandler.bind(this); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Video#_crop + * @type {object} + * @private + * @since 3.20.0 + */ + this._crop = this.resetCropObject(); + + /** + * An object containing in and out markers for sequence playback. + * + * @name Phaser.GameObjects.Video#markers + * @type {any} + * @since 3.20.0 + */ + this.markers = {}; + + /** + * The in marker. + * + * @name Phaser.GameObjects.Video#_markerIn + * @type {number} + * @private + * @since 3.20.0 + */ + this._markerIn = 0; + + /** + * The out marker. + * + * @name Phaser.GameObjects.Video#_markerOut + * @type {number} + * @private + * @since 3.20.0 + */ + this._markerOut = 0; + + /** + * Are we playing a marked segment of the video? + * + * @name Phaser.GameObjects.Video#_playingMarker + * @type {boolean} + * @private + * @since 3.60.0 + */ + this._playingMarker = false; + + /** + * The previous frame's mediaTime. + * + * @name Phaser.GameObjects.Video#_lastUpdate + * @type {number} + * @private + * @since 3.60.0 + */ + this._lastUpdate = 0; + + /** + * The key of the current video as stored in the Video cache. + * + * If the video did not come from the cache this will be an empty string. + * + * @name Phaser.GameObjects.Video#cacheKey + * @type {string} + * @readonly + * @since 3.60.0 + */ + this.cacheKey = ''; + + /** + * Is the video currently seeking? + * + * This is set to `true` when the `seeking` event is fired, + * and set to `false` when the `seeked` event is fired. + * + * @name Phaser.GameObjects.Video#isSeeking + * @type {boolean} + * @readonly + * @since 3.60.0 + */ + this.isSeeking = false; + + /** + * Has Video.play been called? This is reset if a new Video is loaded. + * + * @name Phaser.GameObjects.Video#_playCalled + * @type {boolean} + * @private + * @since 3.60.0 + */ + this._playCalled = false; + + /** + * Has Video.getFirstFrame been called? This is reset if a new Video is loaded or played. + * + * @name Phaser.GameObjects.Video#_getFrame + * @type {boolean} + * @private + * @since 3.85.0 + */ + this._getFrame = false; + + /** + * The Callback ID returned by Request Video Frame. + * + * @name Phaser.GameObjects.Video#_rfvCallbackId + * @type {number} + * @private + * @since 3.60.0 + */ + this._rfvCallbackId = 0; + + var game = scene.sys.game; + + /** + * A reference to Device.Video. + * + * @name Phaser.GameObjects.Video#_device + * @type {string[]} + * @private + * @since 3.60.0 + */ + this._device = game.device.video; + + this.setPosition(x, y); + this.setSize(256, 256); + this.initRenderNodes(this._defaultRenderNodesMap); + + game.events.on(GameEvents.PAUSE, this.globalPause, this); + game.events.on(GameEvents.RESUME, this.globalResume, this); + + var sound = scene.sys.sound; + + if (sound) + { + sound.on(SoundEvents.GLOBAL_MUTE, this.globalMute, this); + } + + if (key) + { + this.load(key); + } + }, + + /** + * The default render node map for this Game Object. + * + * @name Phaser.GameObjects.Video#_defaultRenderNodesMap + * @type {Map} + * @private + * @webglOnly + * @readonly + * @since 4.0.0 + */ + _defaultRenderNodesMap: { + get: function () + { + return DefaultImageNodes; + } + }, + + /** + * Adds this Video to the Scene's update list, ensuring it receives + * `preUpdate` calls each game step. This is called automatically by + * the Scene when this Game Object is added to it. + * + * @method Phaser.GameObjects.Video#addedToScene + * @since 3.20.0 + */ + addedToScene: function () + { + this.scene.sys.updateList.add(this); + }, + + /** + * Removes this Video from the Scene's update list, stopping it from + * receiving `preUpdate` calls. This is called automatically by the + * Scene when this Game Object is removed from it. + * + * @method Phaser.GameObjects.Video#removedFromScene + * @since 3.20.0 + */ + removedFromScene: function () + { + this.scene.sys.updateList.remove(this); + }, + + /** + * Loads a Video from the Video Cache, ready for playback with the `Video.play` method. + * + * If a video is already playing, this method allows you to change the source of the current video element. + * It works by first stopping the current video and then starts playback of the new source through the existing video element. + * + * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked + * state, even if you change the source of the video. By changing the source to a new video you avoid having to + * go through the unlock process again. + * + * @method Phaser.GameObjects.Video#load + * @since 3.60.0 + * + * @param {string} key - The key of the Video this Game Object will play, as stored in the Video Cache. + * + * @return {this} This Video Game Object for method chaining. + */ + load: function (key) + { + var video = this.scene.sys.cache.video.get(key); + + if (video) + { + this.cacheKey = key; + + this.loadHandler(video.url, video.noAudio, video.crossOrigin); + } + else + { + console.warn('No video in cache for key: ' + key); + } + + return this; + }, + + /** + * This method allows you to change the source of the current video element. It works by first stopping the + * current video, if playing. Then deleting the video texture, if one has been created. Finally, it makes a + * new video texture and starts playback of the new source through the existing video element. + * + * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked + * state, even if you change the source of the video. By changing the source to a new video you avoid having to + * go through the unlock process again. + * + * @method Phaser.GameObjects.Video#changeSource + * @since 3.20.0 + * + * @param {string} key - The key of the Video this Game Object will swap to playing, as stored in the Video Cache. + * @param {boolean} [autoplay=true] - Should the video start playing immediately, once the swap is complete? + * @param {boolean} [loop=false] - Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. + * @param {number} [markerIn] - Optional in marker time, in seconds, for playback of a sequence of the video. + * @param {number} [markerOut] - Optional out marker time, in seconds, for playback of a sequence of the video. + * + * @return {this} This Video Game Object for method chaining. + */ + changeSource: function (key, autoplay, loop, markerIn, markerOut) + { + if (autoplay === undefined) { autoplay = true; } + if (loop === undefined) { loop = false; } + + if (this.cacheKey !== key) + { + this.load(key); + + if (autoplay) + { + this.play(loop, markerIn, markerOut); + } + } + }, + + /** + * Returns the key of the currently played video, as stored in the Video Cache. + * + * If the video did not come from the cache this will return an empty string. + * + * @method Phaser.GameObjects.Video#getVideoKey + * @since 3.20.0 + * + * @return {string} The key of the video being played from the Video Cache, if any. + */ + getVideoKey: function () + { + return this.cacheKey; + }, + + /** + * Loads a Video from the given URL, ready for playback with the `Video.play` method. + * + * If a video is already playing, this method allows you to change the source of the current video element. + * It works by first stopping the current video and then starts playback of the new source through the existing video element. + * + * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked + * state, even if you change the source of the video. By changing the source to a new video you avoid having to + * go through the unlock process again. + * + * @method Phaser.GameObjects.Video#loadURL + * @since 3.60.0 + * + * @param {(string|string[]|Phaser.Types.Loader.FileTypes.VideoFileURLConfig|Phaser.Types.Loader.FileTypes.VideoFileURLConfig[])} [urls] - The absolute or relative URL to load the video files from. + * @param {boolean} [noAudio=false] - Does the video have an audio track? If not you can enable auto-playing on it. + * @param {string} [crossOrigin] - The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. + * + * @return {this} This Video Game Object for method chaining. + */ + loadURL: function (urls, noAudio, crossOrigin) + { + if (noAudio === undefined) { noAudio = false; } + + var urlConfig = this._device.getVideoURL(urls); + + if (!urlConfig) + { + console.warn('No supported video format found for ' + urls); + } + else + { + this.cacheKey = ''; + + this.loadHandler(urlConfig.url, noAudio, crossOrigin); + } + + return this; + }, + + /** + * Loads a Video from the given MediaStream object, ready for playback with the `Video.play` method. + * + * @method Phaser.GameObjects.Video#loadMediaStream + * @since 3.50.0 + * + * @param {MediaStream} stream - The MediaStream object. + * @param {boolean} [noAudio=false] - Does the video have an audio track? If not you can enable auto-playing on it. + * @param {string} [crossOrigin] - The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. + * + * @return {this} This Video Game Object for method chaining. + */ + loadMediaStream: function (stream, noAudio, crossOrigin) + { + return this.loadHandler(null, noAudio, crossOrigin, stream); + }, + + /** + * Internal method that loads a Video from the given URL, ready for playback with the + * `Video.play` method. + * + * Normally you don't call this method directly, but instead use the `Video.loadURL` method, + * or the `Video.load` method if you have preloaded the video. + * + * Calling this method will skip checking if the browser supports the given format in + * the URL, where-as the other two methods enforce these checks. + * + * @method Phaser.GameObjects.Video#loadHandler + * @since 3.60.0 + * + * @param {string} [url] - The absolute or relative URL to load the video file from. Set to `null` if passing in a MediaStream object. + * @param {boolean} [noAudio] - Does the video have an audio track? If not you can enable auto-playing on it. + * @param {string} [crossOrigin] - The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. + * @param {string} [stream] - A MediaStream object if this is playing a stream instead of a file. + * + * @return {this} This Video Game Object for method chaining. + */ + loadHandler: function (url, noAudio, crossOrigin, stream) + { + if (!noAudio) { noAudio = false; } + + var video = this.video; + + if (video) + { + // Re-use the existing video element + + this.removeLoadEventHandlers(); + + this.stop(); + } + else + { + video = document.createElement('video'); + + video.controls = false; + + video.setAttribute('playsinline', 'playsinline'); + video.setAttribute('preload', 'auto'); + video.setAttribute('disablePictureInPicture', 'true'); + } + + if (noAudio) + { + video.muted = true; + video.defaultMuted = true; + + video.setAttribute('autoplay', 'autoplay'); + } + else + { + video.muted = false; + video.defaultMuted = false; + + video.removeAttribute('autoplay'); + } + + if (!crossOrigin) + { + video.removeAttribute('crossorigin'); + } + else + { + video.setAttribute('crossorigin', crossOrigin); + } + + if (stream) + { + if ('srcObject' in video) + { + try + { + video.srcObject = stream; + } + catch (err) + { + if (err.name !== 'TypeError') + { + throw err; + } + + video.src = URL.createObjectURL(stream); + } + } + else + { + video.src = URL.createObjectURL(stream); + } + } + else + { + video.src = url; + } + + this.retry = 0; + this.video = video; + + this._playCalled = false; + + video.load(); + + this.addLoadEventHandlers(); + + var texture = this.scene.sys.textures.get(this._key); + + this.setTexture(texture); + + return this; + }, + + /** + * This method handles the Request Video Frame callback. + * + * It is called by the browser when a new video frame is ready to be displayed. + * + * It's also responsible for the creation of the video texture, if it doesn't + * already exist. If it does, it updates the texture as required. + * + * For more details about the Request Video Frame callback, see: + * https://web.dev/requestvideoframecallback-rvfc + * + * @method Phaser.GameObjects.Video#requestVideoFrame + * @fires Phaser.GameObjects.Events#VIDEO_CREATED + * @fires Phaser.GameObjects.Events#VIDEO_LOOP + * @fires Phaser.GameObjects.Events#VIDEO_COMPLETE + * @fires Phaser.GameObjects.Events#VIDEO_PLAY + * @fires Phaser.GameObjects.Events#VIDEO_TEXTURE + * @since 3.60.0 + * + * @param {DOMHighResTimeStamp} now - The current time in milliseconds. + * @param {VideoFrameCallbackMetadata} metadata - Useful metadata about the video frame that was most recently presented for composition. See https://wicg.github.io/video-rvfc/#video-frame-metadata-callback + */ + requestVideoFrame: function (now, metadata) + { + var video = this.video; + + if (!video) + { + return; + } + + var width = metadata.width; + var height = metadata.height; + + var texture = this.videoTexture; + var textureSource = this.videoTextureSource; + var newVideo = (!texture || textureSource.source !== video); + + if (newVideo) + { + // First frame of a new video + this._codePaused = video.paused; + this._codeMuted = video.muted; + + if (!texture) + { + texture = this.scene.sys.textures.create(this._key, video, width, height); + + texture.add('__BASE', 0, 0, 0, width, height); + + this.setTexture(texture); + + this.videoTexture = texture; + this.videoTextureSource = texture.source[0]; + + this.videoTextureSource.setFlipY(this.glFlipY); + + this.emit(Events.VIDEO_TEXTURE, this, texture); + } + else + { + // Re-use the existing texture + textureSource.source = video; + textureSource.width = width; + textureSource.height = height; + + // Resize base frame + texture.get().setSize(width, height); + } + + this.setSizeToFrame(); + this.updateDisplayOrigin(); + } + else + { + textureSource.update(); + } + + this.isStalled = false; + + this.metadata = metadata; + + var currentTime = metadata.mediaTime; + + if (newVideo) + { + this._lastUpdate = currentTime; + + this.emit(Events.VIDEO_CREATED, this, width, height); + + if (!this.frameReady) + { + this.frameReady = true; + + this.emit(Events.VIDEO_PLAY, this); + } + } + + if (this._playingMarker) + { + if (currentTime >= this._markerOut) + { + if (video.loop) + { + video.currentTime = this._markerIn; + + this.emit(Events.VIDEO_LOOP, this); + } + else + { + this.stop(false); + + this.emit(Events.VIDEO_COMPLETE, this); + } + } + } + else if (currentTime < this._lastUpdate) + { + this.emit(Events.VIDEO_LOOP, this); + } + + this._lastUpdate = currentTime; + + if (this._getFrame) + { + this.removeEventHandlers(); + + video.pause(); + + this._getFrame = false; + } + else + { + this._rfvCallbackId = this.video.requestVideoFrameCallback(this.requestVideoFrame.bind(this)); + } + }, + + /** + * Starts this video playing. + * + * If the video is already playing, or has been queued to play with `changeSource` then this method just returns. + * + * Videos can only autoplay if the browser has been unlocked. This happens if you have interacted with the browser, i.e. + * by clicking on it or pressing a key, or due to server settings. The policies that control autoplaying are vast and + * vary between browser. You can read more here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide + * + * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is loaded, + * and it will often allow the video to play immediately: + * + * ```javascript + * preload () { + * this.load.video('pixar', 'nemo.mp4', true); + * } + * ``` + * + * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without + * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies + * the browsers MEI settings. See the MDN Autoplay Guide for details. + * + * If you need audio in your videos, then you'll have to consider the fact that the video cannot start playing until the + * user has interacted with the browser, into your game flow. + * + * @method Phaser.GameObjects.Video#play + * @since 3.20.0 + * + * @param {boolean} [loop=false] - Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. + * @param {number} [markerIn] - Optional in marker time, in seconds, for playback of a sequence of the video. + * @param {number} [markerOut] - Optional out marker time, in seconds, for playback of a sequence of the video. + * + * @return {this} This Video Game Object for method chaining. + */ + play: function (loop, markerIn, markerOut) + { + if (markerIn === undefined) { markerIn = -1; } + if (markerOut === undefined) { markerOut = MATH_CONST.MAX_SAFE_INTEGER; } + + var video = this.video; + + if (!video || this.isPlaying()) + { + if (!video) + { + console.warn('Video not loaded'); + } + + return this; + } + + // We can reset these each time play is called, even if the video hasn't started yet + + if (loop === undefined) { loop = video.loop; } + + video.loop = loop; + + this._markerIn = markerIn; + this._markerOut = markerOut; + this._playingMarker = (markerIn > -1 && markerOut > markerIn && markerOut < MATH_CONST.MAX_SAFE_INTEGER); + + // But we go no further if play has already been called + + if (!this._playCalled) + { + this._getFrame = false; + + this._rfvCallbackId = video.requestVideoFrameCallback(this.requestVideoFrame.bind(this)); + + this._playCalled = true; + + this.createPlayPromise(); + } + + return this; + }, + + /** + * Attempts to get the first frame of the video by running the `requestVideoFrame` callback once, + * then stopping. This is useful if you need to grab the first frame of the video to display behind + * a 'play' button, without actually calling the 'play' method. + * + * If the video is already playing, or has been queued to play with `changeSource` then this method just returns. + * + * @method Phaser.GameObjects.Video#getFirstFrame + * @since 3.85.0 + * + * @return {this} This Video Game Object for method chaining. + */ + getFirstFrame: function () + { + var video = this.video; + + if (!video || this.isPlaying()) + { + if (!video) + { + console.warn('Video not loaded'); + } + + return this; + } + + if (!this._playCalled) + { + this._getFrame = true; + + this._rfvCallbackId = video.requestVideoFrameCallback(this.requestVideoFrame.bind(this)); + + this.createPlayPromise(); + } + + return this; + }, + + /** + * Adds the loading specific event handlers to the video element. + * + * @method Phaser.GameObjects.Video#addLoadEventHandlers + * @since 3.60.0 + */ + addLoadEventHandlers: function () + { + var video = this.video; + + if (video) + { + video.addEventListener('error', this._loadCallbackHandler); + video.addEventListener('abort', this._loadCallbackHandler); + video.addEventListener('loadedmetadata', this._metadataCallbackHandler); + } + }, + + /** + * Removes the loading specific event handlers from the video element. + * + * @method Phaser.GameObjects.Video#removeLoadEventHandlers + * @since 3.60.0 + */ + removeLoadEventHandlers: function () + { + var video = this.video; + + if (video) + { + video.removeEventListener('error', this._loadCallbackHandler); + video.removeEventListener('abort', this._loadCallbackHandler); + } + }, + + /** + * Adds the playback specific event handlers to the video element. + * + * @method Phaser.GameObjects.Video#addEventHandlers + * @since 3.60.0 + */ + addEventHandlers: function () + { + var video = this.video; + + // Set these _after_ calling `video.play` or they don't fire + // (really useful, thanks browsers!) + + if (video) + { + var callbacks = this._callbacks; + + for (var callback in callbacks) + { + video.addEventListener(callback, callbacks[callback]); + } + } + }, + + /** + * Removes the playback specific event handlers from the video element. + * + * @method Phaser.GameObjects.Video#removeEventHandlers + * @since 3.60.0 + */ + removeEventHandlers: function () + { + var video = this.video; + + if (video) + { + var callbacks = this._callbacks; + + for (var callback in callbacks) + { + video.removeEventListener(callback, callbacks[callback]); + } + } + }, + + /** + * Creates the video.play promise and adds the success and error handlers to it. + * + * Not all browsers support the video.play promise, so this method will fall back to + * the old-school way of handling the video.play call. + * + * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play#browser_compatibility for details. + * + * @method Phaser.GameObjects.Video#createPlayPromise + * @since 3.60.0 + * + * @param {boolean} [catchError=true] - Should the error be caught and the video marked as failed to play? + */ + createPlayPromise: function (catchError) + { + if (catchError === undefined) { catchError = true; } + + var video = this.video; + + var playPromise = video.play(); + + if (playPromise !== undefined) + { + var success = this.playSuccess.bind(this); + var error = this.playError.bind(this); + + if (!catchError) + { + var _this = this; + + error = function () + { + _this.failedPlayAttempts++; + }; + } + + playPromise.then(success).catch(error); + } + else + { + // Old-school fallback here for pre-2019 browsers + video.addEventListener('playing', this._callbacks.legacy); + + if (!catchError) + { + this.failedPlayAttempts++; + } + } + }, + + /** + * Adds a sequence marker to this video. + * + * Markers allow you to split a video up into sequences, delineated by a start and end time, given in seconds. + * + * You can then play back specific markers via the `playMarker` method. + * + * Note that marker timing is _not_ frame-perfect. You should construct your videos in such a way that you allow for + * plenty of extra padding before and after each sequence to allow for discrepancies in browser seek and currentTime accuracy. + * + * See https://github.com/w3c/media-and-entertainment/issues/4 for more details about this issue. + * + * @method Phaser.GameObjects.Video#addMarker + * @since 3.20.0 + * + * @param {string} key - A unique name to give this marker. + * @param {number} markerIn - The time, in seconds, representing the start of this marker. + * @param {number} markerOut - The time, in seconds, representing the end of this marker. + * + * @return {this} This Video Game Object for method chaining. + */ + addMarker: function (key, markerIn, markerOut) + { + if (!isNaN(markerIn) && markerIn >= 0 && !isNaN(markerOut) && markerOut > markerIn) + { + this.markers[key] = [ markerIn, markerOut ]; + } + + return this; + }, + + /** + * Plays a pre-defined sequence in this video. + * + * Markers allow you to split a video up into sequences, delineated by a start and end time, given in seconds and + * specified via the `addMarker` method. + * + * Note that marker timing is _not_ frame-perfect. You should construct your videos in such a way that you allow for + * plenty of extra padding before and after each sequence to allow for discrepancies in browser seek and currentTime accuracy. + * + * See https://github.com/w3c/media-and-entertainment/issues/4 for more details about this issue. + * + * @method Phaser.GameObjects.Video#playMarker + * @since 3.20.0 + * + * @param {string} key - The name of the marker sequence to play. + * @param {boolean} [loop=false] - Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. + * + * @return {this} This Video Game Object for method chaining. + */ + playMarker: function (key, loop) + { + var marker = this.markers[key]; + + if (marker) + { + this.play(loop, marker[0], marker[1]); + } + + return this; + }, + + /** + * Removes a previously set marker from this video. + * + * If the marker is currently playing it will _not_ stop playback. + * + * @method Phaser.GameObjects.Video#removeMarker + * @since 3.20.0 + * + * @param {string} key - The name of the marker to remove. + * + * @return {this} This Video Game Object for method chaining. + */ + removeMarker: function (key) + { + delete this.markers[key]; + + return this; + }, + + /** + * Takes a snapshot of the current frame of the video and renders it to a CanvasTexture object, + * which is then returned. You can optionally resize the grab by passing a width and height. + * + * This method returns a reference to the `Video.snapshotTexture` object. Calling this method + * multiple times will overwrite the previous snapshot with the most recent one. + * + * @method Phaser.GameObjects.Video#snapshot + * @since 3.20.0 + * + * @param {number} [width] - The width of the resulting CanvasTexture. + * @param {number} [height] - The height of the resulting CanvasTexture. + * + * @return {Phaser.Textures.CanvasTexture} The CanvasTexture the snapshot was drawn to. + */ + snapshot: function (width, height) + { + if (width === undefined) { width = this.width; } + if (height === undefined) { height = this.height; } + + return this.snapshotArea(0, 0, this.width, this.height, width, height); + }, + + /** + * Takes a snapshot of the specified area of the current frame of the video and renders it to a CanvasTexture object, + * which is then returned. You can optionally resize the grab by passing a different `destWidth` and `destHeight`. + * + * This method returns a reference to the `Video.snapshotTexture` object. Calling this method + * multiple times will overwrite the previous snapshot with the most recent one. + * + * @method Phaser.GameObjects.Video#snapshotArea + * @since 3.20.0 + * + * @param {number} [x=0] - The horizontal location of the top-left of the area to grab from. + * @param {number} [y=0] - The vertical location of the top-left of the area to grab from. + * @param {number} [srcWidth] - The width of area to grab from the video. If not given it will grab the full video dimensions. + * @param {number} [srcHeight] - The height of area to grab from the video. If not given it will grab the full video dimensions. + * @param {number} [destWidth] - The destination width of the grab, allowing you to resize it. + * @param {number} [destHeight] - The destination height of the grab, allowing you to resize it. + * + * @return {Phaser.Textures.CanvasTexture} The CanvasTexture the snapshot was drawn to. + */ + snapshotArea: function (x, y, srcWidth, srcHeight, destWidth, destHeight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (srcWidth === undefined) { srcWidth = this.width; } + if (srcHeight === undefined) { srcHeight = this.height; } + if (destWidth === undefined) { destWidth = srcWidth; } + if (destHeight === undefined) { destHeight = srcHeight; } + + var video = this.video; + var snap = this.snapshotTexture; + + if (!snap) + { + snap = this.scene.sys.textures.createCanvas(UUID(), destWidth, destHeight); + + this.snapshotTexture = snap; + + if (video) + { + snap.context.drawImage(video, x, y, srcWidth, srcHeight, 0, 0, destWidth, destHeight); + } + } + else + { + snap.setSize(destWidth, destHeight); + + if (video) + { + snap.context.drawImage(video, x, y, srcWidth, srcHeight, 0, 0, destWidth, destHeight); + } + } + + return snap.update(); + }, + + /** + * Stores a copy of this Videos `snapshotTexture` in the Texture Manager using the given key. + * + * This texture is created when the `snapshot` or `snapshotArea` methods are called. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of the + * snapshot by using the texture key: + * + * ```javascript + * var vid = this.add.video(0, 0, 'intro'); + * + * vid.snapshot(); + * + * vid.saveSnapshotTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of the `snapshotTexture`, for example by calling `snapshot` again, + * will automatically update _any_ Game Object that is using it as a texture. + * Calling `saveSnapshotTexture` again will not save another copy of the same texture, + * it will just rename the existing one. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame. + * + * @method Phaser.GameObjects.Video#saveSnapshotTexture + * @since 3.20.0 + * + * @param {string} key - The unique key to store the texture as within the global Texture Manager. + * + * @return {Phaser.Textures.CanvasTexture} The Texture that was saved. + */ + saveSnapshotTexture: function (key) + { + if (this.snapshotTexture) + { + this.scene.sys.textures.renameTexture(this.snapshotTexture.key, key); + } + else + { + this.snapshotTexture = this.scene.sys.textures.createCanvas(key, this.width, this.height); + } + + return this.snapshotTexture; + }, + + /** + * This internal method is called automatically if the playback Promise resolves successfully. + * + * @method Phaser.GameObjects.Video#playSuccess + * @fires Phaser.GameObjects.Events#VIDEO_UNLOCKED + * @since 3.60.0 + */ + playSuccess: function () + { + if (!this._playCalled) + { + // The stop method has been called but the Promise has resolved + // after this, so we need to just abort. + return; + } + + this.addEventHandlers(); + + this._codePaused = false; + + if (this.touchLocked) + { + this.touchLocked = false; + + this.emit(Events.VIDEO_UNLOCKED, this); + } + + var sound = this.scene.sys.sound; + + if (sound && sound.mute) + { + // Mute will be set based on the global mute state of the Sound Manager (if there is one) + this.setMute(true); + } + + if (this._markerIn > -1) + { + this.video.currentTime = this._markerIn; + } + }, + + /** + * This internal method is called automatically if the playback Promise fails to resolve. + * + * @method Phaser.GameObjects.Video#playError + * @fires Phaser.GameObjects.Events#VIDEO_ERROR + * @fires Phaser.GameObjects.Events#VIDEO_UNSUPPORTED + * @fires Phaser.GameObjects.Events#VIDEO_LOCKED + * @since 3.60.0 + * + * @param {DOMException} error - The Promise DOM Exception error. + */ + playError: function (error) + { + var name = error.name; + + if (name === 'NotAllowedError') + { + this.touchLocked = true; + this.playWhenUnlocked = true; + this.failedPlayAttempts = 1; + + this.emit(Events.VIDEO_LOCKED, this); + } + else if (name === 'NotSupportedError') + { + this.stop(false); + + this.emit(Events.VIDEO_UNSUPPORTED, this, error); + } + else + { + this.stop(false); + + this.emit(Events.VIDEO_ERROR, this, error); + } + }, + + /** + * Called when the video emits a `playing` event. + * + * This is the legacy handler for browsers that don't support Promise based playback. + * + * @method Phaser.GameObjects.Video#legacyPlayHandler + * @since 3.60.0 + */ + legacyPlayHandler: function () + { + var video = this.video; + + if (video) + { + this.playSuccess(); + + video.removeEventListener('playing', this._callbacks.legacy); + } + }, + + /** + * Called when the video emits a `playing` event. + * + * @method Phaser.GameObjects.Video#playingHandler + * @fires Phaser.GameObjects.Events#VIDEO_PLAYING + * @since 3.60.0 + */ + playingHandler: function () + { + this.isStalled = false; + + this.emit(Events.VIDEO_PLAYING, this); + }, + + /** + * This internal method is called automatically if the video fails to load. + * + * @method Phaser.GameObjects.Video#loadErrorHandler + * @fires Phaser.GameObjects.Events#VIDEO_ERROR + * @since 3.20.0 + * + * @param {Event} event - The error Event. + */ + loadErrorHandler: function (event) + { + this.stop(false); + + this.emit(Events.VIDEO_ERROR, this, event); + }, + + /** + * This internal method is called automatically when the video metadata is available. + * + * @method Phaser.GameObjects.Video#metadataHandler + * @fires Phaser.GameObjects.Events#VIDEO_METADATA + * @since 3.80.0 + * + * @param {Event} event - The loadedmetadata Event. + */ + metadataHandler: function (event) + { + this.emit(Events.VIDEO_METADATA, this, event); + }, + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Video#setSizeToFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame|boolean} [frame] - The frame to base the size of this Game Object on. + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function (frame) + { + if (!frame) { frame = this.frame; } + + this.width = frame.realWidth; + this.height = frame.realHeight; + + if (this.scaleX !== 1) + { + this.scaleX = this.displayWidth / this.width; + } + + if (this.scaleY !== 1) + { + this.scaleY = this.displayHeight / this.height; + } + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = this.width; + input.hitArea.height = this.height; + } + + return this; + }, + + /** + * This internal method is called automatically if the video stalls, for whatever reason. + * + * @method Phaser.GameObjects.Video#stalledHandler + * @fires Phaser.GameObjects.Events#VIDEO_STALLED + * @since 3.60.0 + * + * @param {Event} event - The stall Event. + */ + stalledHandler: function (event) + { + this.isStalled = true; + + this.emit(Events.VIDEO_STALLED, this, event); + }, + + /** + * Called when the video completes playback, i.e. reaches an `ended` state. + * + * This will never happen if the video is coming from a live stream, where the duration is `Infinity`. + * + * @method Phaser.GameObjects.Video#completeHandler + * @fires Phaser.GameObjects.Events#VIDEO_COMPLETE + * @since 3.20.0 + */ + completeHandler: function () + { + this._playCalled = false; + + this.emit(Events.VIDEO_COMPLETE, this); + }, + + /** + * The internal update step. + * + * @method Phaser.GameObjects.Video#preUpdate + * @private + * @since 3.20.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time in ms since the last frame. + */ + preUpdate: function (time, delta) + { + var video = this.video; + + if (!video || !this._playCalled) + { + return; + } + + if (this.touchLocked && this.playWhenUnlocked) + { + this.retry += delta; + + if (this.retry >= this.retryInterval) + { + this.createPlayPromise(false); + + this.retry = 0; + } + } + }, + + /** + * Seeks to a given point in the video. The value is given as a float between 0 and 1, + * where 0 represents the start of the video and 1 represents the end. + * + * Seeking only works if the video has a duration, so will not work for live streams. + * + * When seeking begins, this video will emit a `seeking` event. When the video completes + * seeking (i.e. reaches its designated timestamp) it will emit a `seeked` event. + * + * If you wish to seek based on time instead, use the `Video.setCurrentTime` method. + * + * Unfortunately, the DOM video element does not guarantee frame-accurate seeking. + * This has been an ongoing subject of discussion: https://github.com/w3c/media-and-entertainment/issues/4 + * + * @method Phaser.GameObjects.Video#seekTo + * @since 3.20.0 + * + * @param {number} value - The point in the video to seek to. A value between 0 and 1. + * + * @return {this} This Video Game Object for method chaining. + */ + seekTo: function (value) + { + var video = this.video; + + if (video) + { + var duration = video.duration; + + if (duration !== Infinity && !isNaN(duration)) + { + var seekTime = duration * value; + + this.setCurrentTime(seekTime); + } + } + + return this; + }, + + /** + * A double-precision floating-point value indicating the current playback time in seconds. + * + * If the media has not started to play and has not been seeked, this value is the media's initial playback time. + * + * For a more accurate value, use the `Video.metadata.mediaTime` property instead. + * + * @method Phaser.GameObjects.Video#getCurrentTime + * @since 3.20.0 + * + * @return {number} A double-precision floating-point value indicating the current playback time in seconds. + */ + getCurrentTime: function () + { + return (this.video) ? this.video.currentTime : 0; + }, + + /** + * Seeks to a given playback time in the video. The value is given in _seconds_ or as a string. + * + * Seeking only works if the video has a duration, so will not work for live streams. + * + * When seeking begins, this video will emit a `seeking` event. When the video completes + * seeking (i.e. reaches its designated timestamp) it will emit a `seeked` event. + * + * You can provide a string prefixed with either a `+` or a `-`, such as `+2.5` or `-2.5`. + * In this case it will seek to +/- the value given, relative to the _current time_. + * + * If you wish to seek based on a duration percentage instead, use the `Video.seekTo` method. + * + * @method Phaser.GameObjects.Video#setCurrentTime + * @since 3.20.0 + * + * @param {(string|number)} value - The playback time to seek to in seconds. Can be expressed as a string, such as `+2` to seek 2 seconds ahead from the current time. + * + * @return {this} This Video Game Object for method chaining. + */ + setCurrentTime: function (value) + { + var video = this.video; + + if (video) + { + if (typeof value === 'string') + { + var op = value[0]; + var num = parseFloat(value.substr(1)); + + if (op === '+') + { + value = video.currentTime + num; + } + else if (op === '-') + { + value = video.currentTime - num; + } + } + + video.currentTime = value; + } + + return this; + }, + + /** + * Internal seeking handler. + * + * @method Phaser.GameObjects.Video#seekingHandler + * @fires Phaser.GameObjects.Events#VIDEO_SEEKING + * @private + * @since 3.20.0 + */ + seekingHandler: function () + { + this.isSeeking = true; + + this.emit(Events.VIDEO_SEEKING, this); + }, + + /** + * Internal seeked handler. + * + * @method Phaser.GameObjects.Video#seekedHandler + * @fires Phaser.GameObjects.Events#VIDEO_SEEKED + * @private + * @since 3.20.0 + */ + seekedHandler: function () + { + this.isSeeking = false; + + this.emit(Events.VIDEO_SEEKED, this); + }, + + /** + * Returns the current progress of the video as a float. + * + * Progress is defined as a value between 0 (the start) and 1 (the end). + * + * Progress can only be returned if the video has a duration. Some videos, + * such as those coming from a live stream, do not have a duration. In this + * case the method will return -1. + * + * @method Phaser.GameObjects.Video#getProgress + * @since 3.20.0 + * + * @return {number} The current progress of playback. If the video has no duration, will always return -1. + */ + getProgress: function () + { + var video = this.video; + + if (video) + { + var duration = video.duration; + + if (duration !== Infinity && !isNaN(duration)) + { + return video.currentTime / duration; + } + } + + return -1; + }, + + /** + * A double-precision floating-point value which indicates the duration (total length) of the media in seconds, + * on the media's timeline. If no media is present on the element, or the media is not valid, the returned value is NaN. + * + * If the media has no known end (such as for live streams of unknown duration, web radio, media incoming from WebRTC, + * and so forth), this value is +Infinity. + * + * If no video has been loaded, this method will return 0. + * + * @method Phaser.GameObjects.Video#getDuration + * @since 3.20.0 + * + * @return {number} A double-precision floating-point value indicating the duration of the media in seconds. + */ + getDuration: function () + { + return (this.video) ? this.video.duration : 0; + }, + + /** + * Sets the muted state of the currently playing video, if one is loaded. + * + * @method Phaser.GameObjects.Video#setMute + * @since 3.20.0 + * + * @param {boolean} [value=true] - The mute value. `true` if the video should be muted, otherwise `false`. + * + * @return {this} This Video Game Object for method chaining. + */ + setMute: function (value) + { + if (value === undefined) { value = true; } + + this._codeMuted = value; + + var video = this.video; + + if (video) + { + video.muted = (this._systemMuted) ? true : value; + } + + return this; + }, + + /** + * Returns a boolean indicating if this Video is currently muted. + * + * @method Phaser.GameObjects.Video#isMuted + * @since 3.20.0 + * + * @return {boolean} A boolean indicating if this Video is currently muted, or not. + */ + isMuted: function () + { + return this._codeMuted; + }, + + /** + * Internal global mute handler. Will mute the video, if playing, if the global sound system mutes. + * + * @method Phaser.GameObjects.Video#globalMute + * @private + * @since 3.20.0 + * + * @param {(Phaser.Sound.WebAudioSoundManager|Phaser.Sound.HTML5AudioSoundManager)} soundManager - A reference to the Sound Manager that emitted the event. + * @param {boolean} mute - The mute value. `true` if the Sound Manager is now muted, otherwise `false`. + */ + globalMute: function (soundManager, value) + { + this._systemMuted = value; + + var video = this.video; + + if (video) + { + video.muted = (this._codeMuted) ? true : value; + } + }, + + /** + * Internal global pause handler. Will pause the video if the Game itself pauses. + * + * @method Phaser.GameObjects.Video#globalPause + * @private + * @since 3.20.0 + */ + globalPause: function () + { + this._systemPaused = true; + + if (this.video && !this.video.ended) + { + this.removeEventHandlers(); + + this.video.pause(); + } + }, + + /** + * Internal global resume handler. Will resume a paused video if the Game itself resumes. + * + * @method Phaser.GameObjects.Video#globalResume + * @private + * @since 3.20.0 + */ + globalResume: function () + { + this._systemPaused = false; + + if (this.video && !this._codePaused && !this.video.ended) + { + this.createPlayPromise(); + } + }, + + /** + * Sets the paused state of the currently loaded video. + * + * If the video is playing, calling this method with `true` will pause playback. + * If the video is paused, calling this method with `false` will resume playback. + * + * If no video is loaded, this method does nothing. + * + * If the video has not yet been played, `Video.play` will be called with no parameters. + * + * If the video has ended, this method will do nothing. + * + * @method Phaser.GameObjects.Video#setPaused + * @since 3.20.0 + * + * @param {boolean} [value=true] - The paused value. `true` if the video should be paused, `false` to resume it. + * + * @return {this} This Video Game Object for method chaining. + */ + setPaused: function (value) + { + if (value === undefined) { value = true; } + + var video = this.video; + + this._codePaused = value; + + if (video && !video.ended) + { + if (value) + { + if (!video.paused) + { + this.removeEventHandlers(); + + video.pause(); + } + } + else if (!value) + { + if (!this._playCalled) + { + this.play(); + } + else if (video.paused && !this._systemPaused) + { + this.createPlayPromise(); + } + } + } + + return this; + }, + + /** + * Pauses the current Video, if one is playing. + * + * If no video is loaded, this method does nothing. + * + * Call `Video.resume` to resume playback. + * + * @method Phaser.GameObjects.Video#pause + * @since 3.60.0 + * + * @return {this} This Video Game Object for method chaining. + */ + pause: function () + { + return this.setPaused(true); + }, + + /** + * Resumes the current Video, if one was previously playing and has been paused. + * + * If no video is loaded, this method does nothing. + * + * Call `Video.pause` to pause playback. + * + * @method Phaser.GameObjects.Video#resume + * @since 3.60.0 + * + * @return {this} This Video Game Object for method chaining. + */ + resume: function () + { + return this.setPaused(false); + }, + + /** + * Returns a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). + * + * @method Phaser.GameObjects.Video#getVolume + * @since 3.20.0 + * + * @return {number} A double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). + */ + getVolume: function () + { + return (this.video) ? this.video.volume : 1; + }, + + /** + * Sets the volume of the currently playing video. + * + * The value given is a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). + * + * @method Phaser.GameObjects.Video#setVolume + * @since 3.20.0 + * + * @param {number} [value=1] - A double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). + * + * @return {this} This Video Game Object for method chaining. + */ + setVolume: function (value) + { + if (value === undefined) { value = 1; } + + if (this.video) + { + this.video.volume = Clamp(value, 0, 1); + } + + return this; + }, + + /** + * Returns a double that indicates the rate at which the media is being played back. + * + * @method Phaser.GameObjects.Video#getPlaybackRate + * @since 3.20.0 + * + * @return {number} A double that indicates the rate at which the media is being played back. + */ + getPlaybackRate: function () + { + return (this.video) ? this.video.playbackRate : 1; + }, + + /** + * Sets the playback rate of the current video. + * + * The value given is a double that indicates the rate at which the media is being played back. + * + * @method Phaser.GameObjects.Video#setPlaybackRate + * @since 3.20.0 + * + * @param {number} [rate] - A double that indicates the rate at which the media is being played back. + * + * @return {this} This Video Game Object for method chaining. + */ + setPlaybackRate: function (rate) + { + if (this.video) + { + this.video.playbackRate = rate; + } + + return this; + }, + + /** + * Returns a boolean which indicates whether the media element should start over when it reaches the end. + * + * @method Phaser.GameObjects.Video#getLoop + * @since 3.20.0 + * + * @return {boolean} A boolean which indicates whether the media element will start over when it reaches the end. + */ + getLoop: function () + { + return (this.video) ? this.video.loop : false; + }, + + /** + * Sets the loop state of the current video. + * + * The value given is a boolean which indicates whether the media element will start over when it reaches the end. + * + * Not all videos can loop, for example live streams. + * + * Please note that not all browsers support _seamless_ video looping for all encoding formats. + * + * @method Phaser.GameObjects.Video#setLoop + * @since 3.20.0 + * + * @param {boolean} [value=true] - A boolean which indicates whether the media element will start over when it reaches the end. + * + * @return {this} This Video Game Object for method chaining. + */ + setLoop: function (value) + { + if (value === undefined) { value = true; } + + if (this.video) + { + this.video.loop = value; + } + + return this; + }, + + /** + * Returns a boolean which indicates whether the video is currently playing. + * + * @method Phaser.GameObjects.Video#isPlaying + * @since 3.20.0 + * + * @return {boolean} A boolean which indicates whether the video is playing, or not. + */ + isPlaying: function () + { + return (this.video) ? !(this.video.paused || this.video.ended) : false; + }, + + /** + * Returns a boolean which indicates whether the video is currently paused. + * + * @method Phaser.GameObjects.Video#isPaused + * @since 3.20.0 + * + * @return {boolean} A boolean which indicates whether the video is paused, or not. + */ + isPaused: function () + { + return ((this.video && this._playCalled && this.video.paused) || this._codePaused || this._systemPaused); + }, + + /** + * Stores this Video in the Texture Manager using the given key as a dynamic texture, + * which any texture-based Game Object, such as a Sprite, can use as its source: + * + * ```javascript + * const vid = this.add.video(0, 0, 'intro'); + * + * vid.play(); + * + * vid.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * If the video is not yet playing then you need to listen for the `TEXTURE_READY` event before + * you can use this texture on a Game Object: + * + * ```javascript + * const vid = this.add.video(0, 0, 'intro'); + * + * vid.play(); + * + * vid.once('textureready', (video, texture, key) => { + * + * this.add.image(400, 300, key); + * + * }); + * + * vid.saveTexture('doodle'); + * ``` + * + * The saved texture is automatically updated as the video plays. If you pause this video, + * or change its source, then the saved texture updates instantly. + * + * Calling `saveTexture` again will not save another copy of the same texture, it will just rename the existing one. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame. + * + * If you intend to save the texture so you can use it as the input for a Shader, you may need to toggle the + * `flipY` parameter if you find the video renders upside down in your shader. + * + * @method Phaser.GameObjects.Video#saveTexture + * @since 3.20.0 + * + * @param {string} key - The unique key to store the texture as within the global Texture Manager. + * @param {boolean} [flipY=true] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y` during upload? + * + * @return {boolean} Returns `true` if the texture is available immediately, otherwise returns `false` and you should listen for the `TEXTURE_READY` event. + */ + saveTexture: function (key, flipY) + { + if (flipY === undefined) { flipY = true; } + + if (this.videoTexture) + { + this.scene.sys.textures.renameTexture(this._key, key); + this.videoTextureSource.setFlipY(flipY); + } + + this._key = key; + this.glFlipY = flipY; + + return (this.videoTexture) ? true : false; + }, + + /** + * Stops the video playing and clears all internal event listeners. + * + * If you only wish to pause playback of the video, and resume it a later time, use the `Video.pause` method instead. + * + * If the video hasn't finished downloading, calling this method will not abort the download. To do that you need to + * call `destroy` instead. + * + * @method Phaser.GameObjects.Video#stop + * @fires Phaser.GameObjects.Events#VIDEO_STOP + * @since 3.20.0 + * + * @param {boolean} [emitStopEvent=true] - Should the `VIDEO_STOP` event be emitted? + * + * @return {this} This Video Game Object for method chaining. + */ + stop: function (emitStopEvent) + { + if (emitStopEvent === undefined) { emitStopEvent = true; } + + var video = this.video; + + if (video) + { + this.removeEventHandlers(); + + video.cancelVideoFrameCallback(this._rfvCallbackId); + + video.pause(); + } + + this.retry = 0; + this._playCalled = false; + + if (emitStopEvent) + { + this.emit(Events.VIDEO_STOP, this); + } + + return this; + }, + + /** + * Removes the Video element from the DOM by calling parentNode.removeChild on itself. + * + * Also removes the autoplay and src attributes and nulls the `Video.video` reference. + * + * If you loaded an external video via `Video.loadURL` then you should call this function + * to clear up once you are done with the instance, but don't want to destroy this + * Video Game Object. + * + * This method is called automatically by `Video.destroy`. + * + * @method Phaser.GameObjects.Video#removeVideoElement + * @since 3.20.0 + */ + removeVideoElement: function () + { + var video = this.video; + + if (!video) + { + return; + } + + if (video.parentNode) + { + video.parentNode.removeChild(video); + } + + while (video.hasChildNodes()) + { + video.removeChild(video.firstChild); + } + + video.removeAttribute('autoplay'); + video.removeAttribute('src'); + + this.video = null; + }, + + /** + * Handles the pre-destroy step for the Video object. + * + * This calls `Video.stop` and optionally `Video.removeVideoElement`. + * + * If any Sprites are using this Video as their texture it is up to you to manage those. + * + * @method Phaser.GameObjects.Video#preDestroy + * @private + * @since 3.21.0 + */ + preDestroy: function () + { + this.stop(false); + + this.removeLoadEventHandlers(); + + this.removeVideoElement(); + + var game = this.scene.sys.game.events; + + game.off(GameEvents.PAUSE, this.globalPause, this); + game.off(GameEvents.RESUME, this.globalResume, this); + + var sound = this.scene.sys.sound; + + if (sound) + { + sound.off(SoundEvents.GLOBAL_MUTE, this.globalMute, this); + } + } + +}); + +module.exports = Video; + + +/***/ }, + +/***/ 58352 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Video#renderCanvas + * @since 3.20.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Video} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var VideoCanvasRenderer = function (renderer, src, camera, parentMatrix) +{ + if (src.videoTexture) + { + camera.addToRenderList(src); + + renderer.batchSprite(src, src.frame, camera, parentMatrix); + } +}; + +module.exports = VideoCanvasRenderer; + + +/***/ }, + +/***/ 11511 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Video = __webpack_require__(18471); + +/** + * Creates a new Video Game Object and returns it. + * + * Note: This method will only be available if the Video Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#video + * @since 3.20.0 + * + * @param {Phaser.Types.GameObjects.Video.VideoConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Video} The Game Object that was created. + */ +GameObjectCreator.register('video', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + + var video = new Video(this.scene, 0, 0, key); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, video, config); + + return video; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 89025 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Video = __webpack_require__(18471); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Video Game Object and adds it to the Scene. + * + * This Game Object is capable of handling playback of a video file, video stream or media stream. + * + * You can optionally 'preload' the video into the Phaser Video Cache: + * + * ```javascript + * preload () { + * this.load.video('ripley', 'assets/aliens.mp4'); + * } + * + * create () { + * this.add.video(400, 300, 'ripley'); + * } + * ``` + * + * You don't have to 'preload' the video. You can also play it directly from a URL: + * + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4'); + * } + * ``` + * + * To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do + * all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a + * physics body, etc. + * + * Transparent videos are also possible via the WebM file format. Providing the video file has been encoded with + * an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render + * in-game with full transparency. + * + * ### Autoplaying Videos + * + * Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings. + * The policies that control autoplaying are vast and vary between browser. You can, and should, read more about + * it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide + * + * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_, + * and it will often allow the video to play immediately: + * + * ```javascript + * preload () { + * this.load.video('pixar', 'nemo.mp4', true); + * } + * ``` + * + * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without + * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies + * the browsers MEI settings. See the MDN Autoplay Guide for further details. + * + * Or: + * + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4', true); + * } + * ``` + * + * You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video + * to play immediately, but the audio will not start. + * + * More details about video playback and the supported media formats can be found on MDN: + * + * https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement + * https://developer.mozilla.org/en-US/docs/Web/Media/Formats + * + * Note: This method will only be available if the Video Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#video + * @since 3.20.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} [key] - Optional key of the Video this Game Object will play, as stored in the Video Cache. + * + * @return {Phaser.GameObjects.Video} The Game Object that was created. + */ +GameObjectFactory.register('video', function (x, y, key) +{ + return this.displayList.add(new Video(this.scene, x, y, key)); +}); + + +/***/ }, + +/***/ 10247 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var NOOP = __webpack_require__(29747); +var renderWebGL = NOOP; +var renderCanvas = NOOP; + +if (true) +{ + renderWebGL = __webpack_require__(29849); +} + +if (true) +{ + renderCanvas = __webpack_require__(58352); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }, + +/***/ 29849 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Video#renderWebGL + * @since 3.20.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Video} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var VideoWebGLRenderer = function (renderer, src, drawingContext, parentMatrix) +{ + if (!src.videoTexture) + { + return; + } + + drawingContext.camera.addToRenderList(src); + + var customRenderNodes = src.customRenderNodes; + var defaultRenderNodes = src.defaultRenderNodes; + + (customRenderNodes.Submitter || defaultRenderNodes.Submitter).run( + drawingContext, + src, + parentMatrix, + 0, + customRenderNodes.Texturer || defaultRenderNodes.Texturer, + customRenderNodes.Transformer || defaultRenderNodes.Transformer + ); +}; + +module.exports = VideoWebGLRenderer; + + +/***/ }, + +/***/ 41481 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var BlendModes = __webpack_require__(10312); +var Circle = __webpack_require__(96503); +var CircleContains = __webpack_require__(87902); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var Rectangle = __webpack_require__(87841); +var RectangleContains = __webpack_require__(37303); + +/** + * @classdesc + * A Zone is a non-rendering rectangular Game Object that has a position and size but no texture. + * It never displays visually, but it does live on the display list and can be moved, scaled, + * and rotated like any other Game Object. + * + * Its primary use is for creating Drop Zones and Input Hit Areas. It provides helper methods for + * both circular and rectangular drop zones, and can also accept custom geometry shapes. Zones are + * also useful for object overlap checks, or as a base class for your own non-displaying Game Objects. + * + * The default origin is 0.5, placing it at the center of the Zone, consistent with other Game Objects. + * + * @class Zone + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=1] - The width of the Game Object. + * @param {number} [height=1] - The height of the Game Object. + */ +var Zone = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.GetBounds, + Components.Origin, + Components.Transform, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function Zone (scene, x, y, width, height) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = width; } + + GameObject.call(this, scene, 'Zone'); + + this.setPosition(x, y); + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Zone#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Zone#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. + * + * @name Phaser.GameObjects.Zone#blendMode + * @type {number} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + + this.updateDisplayOrigin(); + }, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the native (un-scaled) width and height of this Zone. Also updates the display origin + * and, by default, resizes any non-custom input hit area associated with this Zone. + * + * @method Phaser.GameObjects.Zone#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. + * + * @return {this} This Game Object. + */ + setSize: function (width, height, resizeInput) + { + if (resizeInput === undefined) { resizeInput = true; } + + this.width = width; + this.height = height; + + this.updateDisplayOrigin(); + + var input = this.input; + + if (resizeInput && input && !input.customHitArea) + { + input.hitArea.width = width; + input.hitArea.height = height; + } + + return this; + }, + + /** + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Zone#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zone's `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setCircleDropZone + * @since 3.0.0 + * + * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * + * @return {this} This Game Object. + */ + setCircleDropZone: function (radius) + { + return this.setDropZone(new Circle(0, 0, radius), CircleContains); + }, + + /** + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zone's `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setRectangleDropZone + * @since 3.0.0 + * + * @param {number} width - The width of the rectangle drop zone. + * @param {number} height - The height of the rectangle drop zone. + * + * @return {this} This Game Object. + */ + setRectangleDropZone: function (width, height) + { + return this.setDropZone(new Rectangle(0, 0, width, height), RectangleContains); + }, + + /** + * Enables this Zone as an interactive Drop Zone by calling `setInteractive` with the given + * hit area shape and callback. You can pass any Phaser geometry shape, or a custom shape with + * a matching hit-test callback. If no arguments are provided, a Rectangle matching the size of + * this Zone will be used automatically. Has no effect if this Zone is already interactive. + * + * @method Phaser.GameObjects.Zone#setDropZone + * @since 3.0.0 + * + * @param {object} [hitArea] - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. If not given it will try to create a Rectangle based on the size of this zone. + * @param {Phaser.Types.Input.HitAreaCallback} [hitAreaCallback] - A function that will return `true` if the given x/y coords it is sent are within the shape. If you provide a shape you must also provide a callback. + * + * @return {this} This Game Object. + */ + setDropZone: function (hitArea, hitAreaCallback) + { + if (!this.input) + { + this.setInteractive(hitArea, hitAreaCallback, true); + } + + return this; + }, + + /** + * A NOOP method so you can pass a Zone to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Zone#setAlpha + * @private + * @since 3.11.0 + */ + setAlpha: function () + { + }, + + /** + * A NOOP method so you can pass a Zone to a Container in Canvas. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Zone#setBlendMode + * @private + * @since 3.16.2 + */ + setBlendMode: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderCanvas + * @private + * @since 3.53.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ + renderCanvas: function (renderer, src, camera) + { + camera.addToRenderList(src); + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderWebGL + * @private + * @since 3.53.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context. + */ + renderWebGL: function (renderer, src, drawingContext) + { + drawingContext.camera.addToRenderList(src); + } + +}); + +module.exports = Zone; + + +/***/ }, + +/***/ 95261 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Zone = __webpack_require__(41481); + +/** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#zone + * @since 3.0.0 + * + * @param {Phaser.Types.GameObjects.Zone.ZoneConfig} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectCreator.register('zone', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 1); + var height = GetAdvancedValue(config, 'height', width); + + return new Zone(this.scene, x, y, width, height); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }, + +/***/ 84175 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Zone = __webpack_require__(41481); +var GameObjectFactory = __webpack_require__(39429); + +/** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#zone + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectFactory.register('zone', function (x, y, width, height) +{ + return this.displayList.add(new Zone(this.scene, x, y, width, height)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }, + +/***/ 95166 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates the area of the circle. + * + * @function Phaser.Geom.Circle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. + * + * @return {number} The area of the Circle. + */ +var Area = function (circle) +{ + return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; +}; + +module.exports = Area; + + +/***/ }, + +/***/ 96503 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(87902); +var GetPoint = __webpack_require__(26241); +var GetPoints = __webpack_require__(79124); +var GEOM_CONST = __webpack_require__(23777); +var Random = __webpack_require__(28176); + +/** + * @classdesc + * A Circle geometry object defined by a center position and radius. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Circle you should look at the capabilities of the Graphics class. + * + * Circle objects are commonly used for hit-testing, overlap checks, masking, and defining circular + * regions of interest within a Scene. They can be used directly with Phaser's geometry intersection + * methods, such as `Phaser.Geom.Intersects.CircleToCircle` or `Phaser.Geom.Intersects.CircleToRectangle`, + * making them useful for simple spatial queries without requiring a physics body. + * + * @class Circle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + */ +var Circle = new Class({ + + initialize: + + function Circle (x, y, radius) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 0; } + + /** + * The geometry constant type of this object: `GEOM_CONST.CIRCLE`. + * Used for fast type comparisons. + * + * @name Phaser.Geom.Circle#type + * @type {number} + * @readonly + * @since 3.19.0 + */ + this.type = GEOM_CONST.CIRCLE; + + /** + * The x position of the center of the circle. + * + * @name Phaser.Geom.Circle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the circle. + * + * @name Phaser.Geom.Circle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The internal radius of the circle. + * + * @name Phaser.Geom.Circle#_radius + * @type {number} + * @private + * @since 3.0.0 + */ + this._radius = radius; + + /** + * The internal diameter of the circle. + * + * @name Phaser.Geom.Circle#_diameter + * @type {number} + * @private + * @since 3.0.0 + */ + this._diameter = radius * 2; + }, + + /** + * Check to see if the Circle contains the given x / y coordinates. + * + * @method Phaser.Geom.Circle#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @method Phaser.Geom.Circle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {Phaser.Math.Vector2} [out] - A Vector2 to store the return values in. If not given a Vector2 object will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 containing the coordinates of the point around the circle. + */ + getPoint: function (position, out) + { + return GetPoint(this, position, out); + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Circle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [output,$return] + * + * @param {number} quantity - The amount of points to return. If a falsy value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {Phaser.Math.Vector2[]} [output] - An array to insert the Vector2s in to. If not provided a new array will be created. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects pertaining to the points around the circumference of the circle. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the Circle. + * + * @method Phaser.Geom.Circle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [point,$return] + * + * @param {Phaser.Math.Vector2} [vec] - A Vector2 object to set the random `x` and `y` values in. + * + * @return {Phaser.Math.Vector2} A Vector2 object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (vec) + { + return Random(this, vec); + }, + + /** + * Sets the x, y and radius of this circle. + * + * @method Phaser.Geom.Circle#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + * + * @return {this} This Circle object. + */ + setTo: function (x, y, radius) + { + this.x = x; + this.y = y; + this._radius = radius; + this._diameter = radius * 2; + + return this; + }, + + /** + * Sets this Circle to be empty with a radius of zero. + * Does not change its position. + * + * @method Phaser.Geom.Circle#setEmpty + * @since 3.0.0 + * + * @return {this} This Circle object. + */ + setEmpty: function () + { + this._radius = 0; + this._diameter = 0; + + return this; + }, + + /** + * Sets the position of this Circle. If the `y` argument is omitted, both the x and y + * positions will be set to the value of `x`. + * + * @method Phaser.Geom.Circle#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * + * @return {this} This Circle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Checks to see if the Circle is empty: has a radius of zero. + * + * @method Phaser.Geom.Circle#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Circle is empty, otherwise false. + */ + isEmpty: function () + { + return (this._radius <= 0); + }, + + /** + * The radius of the Circle. Setting this value also updates the diameter accordingly. + * + * @name Phaser.Geom.Circle#radius + * @type {number} + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this._radius; + }, + + set: function (value) + { + this._radius = value; + this._diameter = value * 2; + } + + }, + + /** + * The diameter of the Circle, which is twice the radius. Setting this value also updates the radius accordingly. + * + * @name Phaser.Geom.Circle#diameter + * @type {number} + * @since 3.0.0 + */ + diameter: { + + get: function () + { + return this._diameter; + }, + + set: function (value) + { + this._diameter = value; + this._radius = value * 0.5; + } + + }, + + /** + * The leftmost point of the Circle, equal to `x - radius`. Setting this value adjusts the + * x position of the circle's center while keeping the radius unchanged. + * + * @name Phaser.Geom.Circle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - this._radius; + }, + + set: function (value) + { + this.x = value + this._radius; + } + + }, + + /** + * The rightmost point of the Circle, equal to `x + radius`. Setting this value adjusts the + * x position of the circle's center while keeping the radius unchanged. + * + * @name Phaser.Geom.Circle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this._radius; + }, + + set: function (value) + { + this.x = value - this._radius; + } + + }, + + /** + * The topmost point of the Circle, equal to `y - radius`. Setting this value adjusts the + * y position of the circle's center while keeping the radius unchanged. + * + * @name Phaser.Geom.Circle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - this._radius; + }, + + set: function (value) + { + this.y = value + this._radius; + } + + }, + + /** + * The bottommost point of the Circle, equal to `y + radius`. Setting this value adjusts the + * y position of the circle's center while keeping the radius unchanged. + * + * @name Phaser.Geom.Circle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this._radius; + }, + + set: function (value) + { + this.y = value - this._radius; + } + + } + +}); + +module.exports = Circle; + + +/***/ }, + +/***/ 71562 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the circumference of the given Circle. + * + * @function Phaser.Geom.Circle.Circumference + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of. + * + * @return {number} The circumference of the Circle. + */ +var Circumference = function (circle) +{ + return 2 * (Math.PI * circle.radius); +}; + +module.exports = Circumference; + + +/***/ }, + +/***/ 92110 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns a Vector2 object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @function Phaser.Geom.Circle.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param {Phaser.Math.Vector2} [out] - A Vector2 to store the results in. If not given a Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (circle, angle, out) +{ + if (out === undefined) { out = new Vector2(); } + + out.x = circle.x + (circle.radius * Math.cos(angle)); + out.y = circle.y + (circle.radius * Math.sin(angle)); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }, + +/***/ 42250 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circle = __webpack_require__(96503); + +/** + * Creates a new Circle instance based on the values contained in the given source. + * + * @function Phaser.Geom.Circle.Clone + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. + * + * @return {Phaser.Geom.Circle} A clone of the source Circle. + */ +var Clone = function (source) +{ + return new Circle(source.x, source.y, source.radius); +}; + +module.exports = Clone; + + +/***/ }, + +/***/ 87902 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Check to see if the Circle contains the given x / y coordinates. + * + * @function Phaser.Geom.Circle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ +var Contains = function (circle, x, y) +{ + // Check if x/y are within the bounds first + if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) + { + var dx = (circle.x - x) * (circle.x - x); + var dy = (circle.y - y) * (circle.y - y); + + return (dx + dy) <= (circle.radius * circle.radius); + } + else + { + return false; + } +}; + +module.exports = Contains; + + +/***/ }, + +/***/ 5698 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(87902); + +/** + * Check to see if the Circle contains the given x and y coordinates as stored in the Vector2. + * + * @function Phaser.Geom.Circle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {Phaser.Math.Vector2} vec - The Vector2 object to check if its coordinates are within the Circle or not. + * + * @return {boolean} True if the Vector2 coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (circle, vec) +{ + return Contains(circle, vec.x, vec.y); +}; + +module.exports = ContainsPoint; + + +/***/ }, + +/***/ 70588 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(87902); + +/** + * Check to see if the Circle contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Circle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. + */ +var ContainsRect = function (circle, rect) +{ + return ( + Contains(circle, rect.x, rect.y) && + Contains(circle, rect.right, rect.y) && + Contains(circle, rect.x, rect.bottom) && + Contains(circle, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }, + +/***/ 26394 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * + * @function Phaser.Geom.Circle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [dest,$return] + * + * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. + * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. + * + * @return {Phaser.Geom.Circle} The destination Circle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.radius); +}; + +module.exports = CopyFrom; + + +/***/ }, + +/***/ 76278 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Circle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The first Circle to compare. + * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. + * + * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. + */ +var Equals = function (circle, toCompare) +{ + return ( + circle.x === toCompare.x && + circle.y === toCompare.y && + circle.radius === toCompare.radius + ); +}; + +module.exports = Equals; + + +/***/ }, + +/***/ 2074 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +/** + * Returns the bounds of the Circle object. + * + * @function Phaser.Geom.Circle.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circle's bounds. + */ +var GetBounds = function (circle, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = circle.left; + out.y = circle.top; + out.width = circle.diameter; + out.height = circle.diameter; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }, + +/***/ 26241 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CircumferencePoint = __webpack_require__(92110); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); +var Vector2 = __webpack_require__(26099); + +/** + * Returns a Vector2 object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @function Phaser.Geom.Circle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {Phaser.Math.Vector2} [out] - A Vector2 instance to store the return values in. If not given a new Vector2 object will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 containing the coordinates of the point around the circle. + */ +var GetPoint = function (circle, position, out) +{ + if (out === undefined) { out = new Vector2(); } + + var angle = FromPercent(position, 0, MATH_CONST.TAU); + + return CircumferencePoint(circle, angle, out); +}; + +module.exports = GetPoint; + + +/***/ }, + +/***/ 79124 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circumference = __webpack_require__(71562); +var CircumferencePoint = __webpack_require__(92110); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); + +/** + * Returns an array of Vector2 objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Circle.GetPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the points from. + * @param {number} quantity - The amount of points to return. If a falsy value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {array} [out] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects pertaining to the points around the circumference of the circle. + */ +var GetPoints = function (circle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity && stepRate > 0) + { + quantity = Circumference(circle) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var angle = FromPercent(i / quantity, 0, MATH_CONST.TAU); + + out.push(CircumferencePoint(circle, angle)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }, + +/***/ 50884 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Offsets the Circle by the values given. + * + * @function Phaser.Geom.Circle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Circle by. + * @param {number} y - The amount to vertically offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var Offset = function (circle, x, y) +{ + circle.x += x; + circle.y += y; + + return circle; +}; + +module.exports = Offset; + + +/***/ }, + +/***/ 39212 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Offsets the Circle by the values given in the `x` and `y` properties of the Vector2 object. + * + * @function Phaser.Geom.Circle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {Phaser.Math.Vector2} vec - The Vector2 object containing the values to offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var OffsetPoint = function (circle, vec) +{ + circle.x += vec.x; + circle.y += vec.y; + + return circle; +}; + +module.exports = OffsetPoint; + + +/***/ }, + +/***/ 28176 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns a uniformly distributed random point from anywhere within the given Circle. + * + * @function Phaser.Geom.Circle.Random + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get a random point from. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to set the random `x` and `y` values in. + * + * @return {Phaser.Math.Vector2} A Vector2 object with the random values set in the `x` and `y` properties. + */ +var Random = function (circle, out) +{ + if (out === undefined) { out = new Vector2(); } + + var t = 2 * Math.PI * Math.random(); + var u = Math.random() + Math.random(); + var r = (u > 1) ? 2 - u : u; + var x = r * Math.cos(t); + var y = r * Math.sin(t); + + out.x = circle.x + (x * circle.radius); + out.y = circle.y + (y * circle.radius); + + return out; +}; + +module.exports = Random; + + +/***/ }, + +/***/ 88911 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circle = __webpack_require__(96503); + +Circle.Area = __webpack_require__(95166); +Circle.Circumference = __webpack_require__(71562); +Circle.CircumferencePoint = __webpack_require__(92110); +Circle.Clone = __webpack_require__(42250); +Circle.Contains = __webpack_require__(87902); +Circle.ContainsPoint = __webpack_require__(5698); +Circle.ContainsRect = __webpack_require__(70588); +Circle.CopyFrom = __webpack_require__(26394); +Circle.Equals = __webpack_require__(76278); +Circle.GetBounds = __webpack_require__(2074); +Circle.GetPoint = __webpack_require__(26241); +Circle.GetPoints = __webpack_require__(79124); +Circle.Offset = __webpack_require__(50884); +Circle.OffsetPoint = __webpack_require__(39212); +Circle.Random = __webpack_require__(28176); + +module.exports = Circle; + + +/***/ }, + +/***/ 23777 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GEOM_CONST = { + + /** + * A Circle Geometry object type. + * + * @name Phaser.Geom.CIRCLE + * @type {number} + * @since 3.19.0 + */ + CIRCLE: 0, + + /** + * An Ellipse Geometry object type. + * + * @name Phaser.Geom.ELLIPSE + * @type {number} + * @since 3.19.0 + */ + ELLIPSE: 1, + + /** + * A Line Geometry object type. + * + * @name Phaser.Geom.LINE + * @type {number} + * @since 3.19.0 + */ + LINE: 2, + + /** + * A Point Geometry object type. + * This object type was removed in 4.0.0. Use Vector2 instead. + * + * @name Phaser.Geom.POINT + * @type {number} + * @since 3.19.0 + */ + POINT: 3, + + /** + * A Polygon Geometry object type. + * + * @name Phaser.Geom.POLYGON + * @type {number} + * @since 3.19.0 + */ + POLYGON: 4, + + /** + * A Rectangle Geometry object type. + * + * @name Phaser.Geom.RECTANGLE + * @type {number} + * @since 3.19.0 + */ + RECTANGLE: 5, + + /** + * A Triangle Geometry object type. + * + * @name Phaser.Geom.TRIANGLE + * @type {number} + * @since 3.19.0 + */ + TRIANGLE: 6 + +}; + +module.exports = GEOM_CONST; + + +/***/ }, + +/***/ 78874 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates the area of the given Ellipse using the formula: π × majorRadius × minorRadius. + * Returns 0 if the Ellipse is empty (i.e. has no width or height). + * + * @function Phaser.Geom.Ellipse.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * + * @return {number} The area of the Ellipse, or 0 if the Ellipse is empty. + */ +var Area = function (ellipse) +{ + if (ellipse.isEmpty()) + { + return 0; + } + + // units squared + return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); +}; + +module.exports = Area; + + +/***/ }, + +/***/ 92990 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns the circumference of the given Ellipse. + * + * @function Phaser.Geom.Ellipse.Circumference + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference of. + * + * @return {number} The circumference of the Ellipse. + */ +var Circumference = function (ellipse) +{ + var rx = ellipse.width / 2; + var ry = ellipse.height / 2; + var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); + + return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); +}; + +module.exports = Circumference; + + +/***/ }, + +/***/ 79522 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns a Vector2 containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * + * @function Phaser.Geom.Ellipse.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param {Phaser.Math.Vector2} [out] - A Vector2 to store the results in. If not given a Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (ellipse, angle, out) +{ + if (out === undefined) { out = new Vector2(); } + + var halfWidth = ellipse.width / 2; + var halfHeight = ellipse.height / 2; + + out.x = ellipse.x + halfWidth * Math.cos(angle); + out.y = ellipse.y + halfHeight * Math.sin(angle); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }, + +/***/ 58102 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Ellipse = __webpack_require__(8497); + +/** + * Creates a new Ellipse instance based on the values contained in the given source. + * + * @function Phaser.Geom.Ellipse.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or an ellipse-like object, with x, y, width and height properties. + * + * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. + */ +var Clone = function (source) +{ + return new Ellipse(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }, + +/***/ 81154 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @function Phaser.Geom.Ellipse.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ +var Contains = function (ellipse, x, y) +{ + if (ellipse.width <= 0 || ellipse.height <= 0) + { + return false; + } + + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 + var normx = ((x - ellipse.x) / ellipse.width); + var normy = ((y - ellipse.y) / ellipse.height); + + normx *= normx; + normy *= normy; + + return (normx + normy < 0.25); +}; + +module.exports = Contains; + + +/***/ }, + +/***/ 46662 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(81154); + +/** + * Check to see if the Ellipse contains the given x and y coordinates as stored in the Vector2. + * + * @function Phaser.Geom.Ellipse.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {Phaser.Math.Vector2} vec - The Vector2 object to check if its coordinates are within the Ellipse or not. + * + * @return {boolean} True if the Vector2 coordinates are within the ellipse, otherwise false. + */ +var ContainsPoint = function (ellipse, vec) +{ + return Contains(ellipse, vec.x, vec.y); +}; + +module.exports = ContainsPoint; + + +/***/ }, + +/***/ 1632 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(81154); + +/** + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Ellipse.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. + */ +var ContainsRect = function (ellipse, rect) +{ + return ( + Contains(ellipse, rect.x, rect.y) && + Contains(ellipse, rect.right, rect.y) && + Contains(ellipse, rect.x, rect.bottom) && + Contains(ellipse, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }, + +/***/ 65534 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * + * @function Phaser.Geom.Ellipse.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [dest,$return] + * + * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. + * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. + * + * @return {Phaser.Geom.Ellipse} The destination Ellipse. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }, + +/***/ 8497 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(81154); +var GetPoint = __webpack_require__(90549); +var GetPoints = __webpack_require__(48320); +var GEOM_CONST = __webpack_require__(23777); +var Random = __webpack_require__(24820); + +/** + * @classdesc + * An Ellipse object. + * + * An Ellipse is defined by its center position (x, y), a total width, and a total height. It can be + * used for geometric intersection tests (point-in-ellipse containment), sampling evenly-spaced or random + * points on its circumference or interior, and as a lightweight shape descriptor for collision or + * hit-area purposes. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render an Ellipse you should look at the capabilities of the Graphics class. + * + * @class Ellipse + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the ellipse. + * @param {number} [y=0] - The y position of the center of the ellipse. + * @param {number} [width=0] - The width of the ellipse. + * @param {number} [height=0] - The height of the ellipse. + */ +var Ellipse = new Class({ + + initialize: + + function Ellipse (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The geometry constant type of this object: `GEOM_CONST.ELLIPSE`. + * Used for fast type comparisons. + * + * @name Phaser.Geom.Ellipse#type + * @type {number} + * @readonly + * @since 3.19.0 + */ + this.type = GEOM_CONST.ELLIPSE; + + /** + * The x position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the ellipse. + * + * @name Phaser.Geom.Ellipse#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the ellipse. + * + * @name Phaser.Geom.Ellipse#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @method Phaser.Geom.Ellipse#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Vector2 object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the ellipse. + * + * @method Phaser.Geom.Ellipse#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the return values in. If not given a Vector2 object will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 instance containing the coordinates of the point around the ellipse. + */ + getPoint: function (position, point) + { + return GetPoint(this, position, point); + }, + + /** + * Returns an array of Vector2 objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Ellipse#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [output,$return] + * + * @param {number} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {Phaser.Math.Vector2[]} [output] - An array to insert the Vector2s in. If not provided a new array will be created. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects pertaining to the points around the circumference of the ellipse. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * + * @method Phaser.Geom.Ellipse#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [point,$return] + * + * @param {Phaser.Math.Vector2} [vec] - A Vector2 object to set the random `x` and `y` values in. + * + * @return {Phaser.Math.Vector2} A Vector2 object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (vec) + { + return Random(this, vec); + }, + + /** + * Sets the x, y, width and height of this ellipse. + * + * @method Phaser.Geom.Ellipse#setTo + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {this} This Ellipse object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets this Ellipse to be empty with a width and height of zero. + * Does not change its position. + * + * @method Phaser.Geom.Ellipse#setEmpty + * @since 3.0.0 + * + * @return {this} This Ellipse object. + */ + setEmpty: function () + { + this.width = 0; + this.height = 0; + + return this; + }, + + /** + * Sets the position of this Ellipse. If the `y` argument is omitted, both the x and y positions + * will be set to the value of `x`. + * + * @method Phaser.Geom.Ellipse#setPosition + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * + * @return {this} This Ellipse object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the size of this Ellipse. Does not change its position. + * If the `height` argument is omitted it will be set equal to `width`, producing a circle. + * + * @method Phaser.Geom.Ellipse#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} [height=width] - The height of the ellipse. + * + * @return {this} This Ellipse object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Checks to see if the Ellipse is empty: has a width or height of zero or less. + * + * @method Phaser.Geom.Ellipse#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Ellipse is empty, otherwise false. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. + * + * @method Phaser.Geom.Ellipse#getMinorRadius + * @since 3.0.0 + * + * @return {number} The minor radius. + */ + getMinorRadius: function () + { + return Math.min(this.width, this.height) / 2; + }, + + /** + * Returns the major radius of the ellipse. Also known as the Semi Major Axis. + * + * @method Phaser.Geom.Ellipse#getMajorRadius + * @since 3.0.0 + * + * @return {number} The major radius. + */ + getMajorRadius: function () + { + return Math.max(this.width, this.height) / 2; + }, + + /** + * The left position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - (this.width / 2); + }, + + set: function (value) + { + this.x = value + (this.width / 2); + } + + }, + + /** + * The right position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The top position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - (this.height / 2); + }, + + set: function (value) + { + this.y = value + (this.height / 2); + } + + }, + + /** + * The bottom position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Ellipse; + + +/***/ }, + +/***/ 36146 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Ellipse.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. + * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. + * + * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. + */ +var Equals = function (ellipse, toCompare) +{ + return ( + ellipse.x === toCompare.x && + ellipse.y === toCompare.y && + ellipse.width === toCompare.width && + ellipse.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }, + +/***/ 23694 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +/** + * Returns the bounds of the Ellipse object. + * + * @function Phaser.Geom.Ellipse.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. + */ +var GetBounds = function (ellipse, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = ellipse.left; + out.y = ellipse.top; + out.width = ellipse.width; + out.height = ellipse.height; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }, + +/***/ 90549 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CircumferencePoint = __webpack_require__(79522); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); +var Vector2 = __webpack_require__(26099); + +/** + * Returns a Vector2 object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. i.e. a value of 0.5 will give the point + * at 180 degrees around the ellipse. + * + * @function Phaser.Geom.Ellipse.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 degrees around the ellipse. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the return values in. If not given a new Vector2 object will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object, containing the coordinates of the point around the ellipse. + */ +var GetPoint = function (ellipse, position, out) +{ + if (out === undefined) { out = new Vector2(); } + + var angle = FromPercent(position, 0, MATH_CONST.TAU); + + return CircumferencePoint(ellipse, angle, out); +}; + +module.exports = GetPoint; + + +/***/ }, + +/***/ 48320 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circumference = __webpack_require__(92990); +var CircumferencePoint = __webpack_require__(79522); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); + +/** + * Returns an array of Vector2 objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Ellipse.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the points from. + * @param {number} quantity - The amount of points to return. If a falsy value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {Phaser.Math.Vector2[]} [out] - An array to insert the Vector2 objects into. If not provided a new array will be created. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects pertaining to the points around the circumference of the ellipse. + */ +var GetPoints = function (ellipse, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity && stepRate > 0) + { + quantity = Circumference(ellipse) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var angle = FromPercent(i / quantity, 0, MATH_CONST.TAU); + + out.push(CircumferencePoint(ellipse, angle)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }, + +/***/ 73424 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Offsets the Ellipse by the values given. + * + * @function Phaser.Geom.Ellipse.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated). + * @param {number} x - The amount to horizontally offset the Ellipse by. + * @param {number} y - The amount to vertically offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + */ +var Offset = function (ellipse, x, y) +{ + ellipse.x += x; + ellipse.y += y; + + return ellipse; +}; + +module.exports = Offset; + + +/***/ }, + +/***/ 44808 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Vector2 object. + * + * @function Phaser.Geom.Ellipse.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {Phaser.Math.Vector2} vec - The Vector2 object containing the values to offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + */ +var OffsetPoint = function (ellipse, vec) +{ + ellipse.x += vec.x; + ellipse.y += vec.y; + + return ellipse; +}; + +module.exports = OffsetPoint; + + +/***/ }, + +/***/ 24820 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * + * @function Phaser.Geom.Ellipse.Random + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get a random point from. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to set the random `x` and `y` values in. + * + * @return {Phaser.Math.Vector2} A Vector2 object with the random values set in the `x` and `y` properties. + */ +var Random = function (ellipse, out) +{ + if (out === undefined) { out = new Vector2(); } + + var p = Math.random() * Math.PI * 2; + var s = Math.sqrt(Math.random()); + + out.x = ellipse.x + ((s * Math.cos(p)) * ellipse.width / 2); + out.y = ellipse.y + ((s * Math.sin(p)) * ellipse.height / 2); + + return out; +}; + +module.exports = Random; + + +/***/ }, + +/***/ 49203 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Ellipse = __webpack_require__(8497); + +Ellipse.Area = __webpack_require__(78874); +Ellipse.Circumference = __webpack_require__(92990); +Ellipse.CircumferencePoint = __webpack_require__(79522); +Ellipse.Clone = __webpack_require__(58102); +Ellipse.Contains = __webpack_require__(81154); +Ellipse.ContainsPoint = __webpack_require__(46662); +Ellipse.ContainsRect = __webpack_require__(1632); +Ellipse.CopyFrom = __webpack_require__(65534); +Ellipse.Equals = __webpack_require__(36146); +Ellipse.GetBounds = __webpack_require__(23694); +Ellipse.GetPoint = __webpack_require__(90549); +Ellipse.GetPoints = __webpack_require__(48320); +Ellipse.Offset = __webpack_require__(73424); +Ellipse.OffsetPoint = __webpack_require__(44808); +Ellipse.Random = __webpack_require__(24820); + +module.exports = Ellipse; + + +/***/ }, + +/***/ 55738 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(23777); +var Extend = __webpack_require__(79291); + +/** + * @namespace Phaser.Geom + */ + +var Geom = { + + Circle: __webpack_require__(88911), + Ellipse: __webpack_require__(49203), + Intersects: __webpack_require__(91865), + Line: __webpack_require__(2529), + Polygon: __webpack_require__(58423), + Rectangle: __webpack_require__(93232), + Triangle: __webpack_require__(84435) + +}; + +// Merge in the consts +Geom = Extend(false, Geom, CONST); + +module.exports = Geom; + + +/***/ }, + +/***/ 2044 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DistanceBetween = __webpack_require__(20339); + +/** + * Checks if two Circles intersect. + * + * @function Phaser.Geom.Intersects.CircleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circleA - The first Circle to check for intersection. + * @param {Phaser.Geom.Circle} circleB - The second Circle to check for intersection. + * + * @return {boolean} `true` if the two Circles intersect, otherwise `false`. + */ +var CircleToCircle = function (circleA, circleB) +{ + return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); +}; + +module.exports = CircleToCircle; + + +/***/ }, + +/***/ 81491 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Checks for intersection between a circle and a rectangle. + * + * @function Phaser.Geom.Intersects.CircleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The circle to be checked. + * @param {Phaser.Geom.Rectangle} rect - The rectangle to be checked. + * + * @return {boolean} `true` if the two objects intersect, otherwise `false`. + */ +var CircleToRectangle = function (circle, rect) +{ + var halfWidth = rect.width / 2; + var halfHeight = rect.height / 2; + + var cx = Math.abs(circle.x - rect.x - halfWidth); + var cy = Math.abs(circle.y - rect.y - halfHeight); + var xDist = halfWidth + circle.radius; + var yDist = halfHeight + circle.radius; + + if (cx > xDist || cy > yDist) + { + return false; + } + else if (cx <= halfWidth || cy <= halfHeight) + { + return true; + } + else + { + var xCornerDist = cx - halfWidth; + var yCornerDist = cy - halfHeight; + var xCornerDistSq = xCornerDist * xCornerDist; + var yCornerDistSq = yCornerDist * yCornerDist; + var maxCornerDistSq = circle.radius * circle.radius; + + return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); + } +}; + +module.exports = CircleToRectangle; + + +/***/ }, + +/***/ 63376 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); +var CircleToCircle = __webpack_require__(2044); + +/** + * Checks if two Circles intersect and returns the intersection points as a Point object array. + * + * @function Phaser.Geom.Intersects.GetCircleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circleA - The first Circle to check for intersection. + * @param {Phaser.Geom.Circle} circleB - The second Circle to check for intersection. + * @param {Phaser.Math.Vector2[]} [out] - An optional array of Vector2 objects in which to store the points of intersection. + * + * @return {Phaser.Math.Vector2[]} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetCircleToCircle = function (circleA, circleB, out) +{ + if (out === undefined) { out = []; } + + if (CircleToCircle(circleA, circleB)) + { + var x0 = circleA.x; + var y0 = circleA.y; + var r0 = circleA.radius; + + var x1 = circleB.x; + var y1 = circleB.y; + var r1 = circleB.radius; + + var coefficientA, coefficientB, coefficientC, lambda, x; + + if (y0 === y1) + { + x = ((r1 * r1) - (r0 * r0) - (x1 * x1) + (x0 * x0)) / (2 * (x0 - x1)); + + coefficientA = 1; + coefficientB = -2 * y1; + coefficientC = (x1 * x1) + (x * x) - (2 * x1 * x) + (y1 * y1) - (r1 * r1); + + lambda = (coefficientB * coefficientB) - (4 * coefficientA * coefficientC); + + if (lambda === 0) + { + out.push(new Vector2(x, (-coefficientB / (2 * coefficientA)))); + } + else if (lambda > 0) + { + out.push(new Vector2(x, (-coefficientB + Math.sqrt(lambda)) / (2 * coefficientA))); + out.push(new Vector2(x, (-coefficientB - Math.sqrt(lambda)) / (2 * coefficientA))); + } + } + else + { + var v1 = (x0 - x1) / (y0 - y1); + var n = (r1 * r1 - r0 * r0 - x1 * x1 + x0 * x0 - y1 * y1 + y0 * y0) / (2 * (y0 - y1)); + + coefficientA = (v1 * v1) + 1; + coefficientB = (2 * y0 * v1) - (2 * n * v1) - (2 * x0); + coefficientC = (x0 * x0) + (y0 * y0) + (n * n) - (r0 * r0) - (2 * y0 * n); + + lambda = (coefficientB * coefficientB) - (4 * coefficientA * coefficientC); + + if (lambda === 0) + { + x = (-coefficientB / (2 * coefficientA)); + out.push(new Vector2(x, (n - (x * v1)))); + } + else if (lambda > 0) + { + x = (-coefficientB + Math.sqrt(lambda)) / (2 * coefficientA); + out.push(new Vector2(x, (n - (x * v1)))); + x = (-coefficientB - Math.sqrt(lambda)) / (2 * coefficientA); + out.push(new Vector2(x, (n - (x * v1)))); + } + } + } + + return out; +}; + +module.exports = GetCircleToCircle; + + +/***/ }, + +/***/ 97439 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetLineToCircle = __webpack_require__(4042); +var CircleToRectangle = __webpack_require__(81491); + +/** + * Checks for intersection between a circle and a rectangle, and returns the + * intersection points as an array of Point objects. If the shapes do not intersect, + * an empty array is returned. If they do intersect, each of the rectangle's four + * edges is tested against the circle and any intersection points found are added to + * the output array. + * + * @function Phaser.Geom.Intersects.GetCircleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The circle to be checked. + * @param {Phaser.Geom.Rectangle} rect - The rectangle to be checked. + * @param {array} [out] - An optional array in which to store the points of intersection. + * + * @return {array} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetCircleToRectangle = function (circle, rect, out) +{ + if (out === undefined) { out = []; } + + if (CircleToRectangle(circle, rect)) + { + var lineA = rect.getLineA(); + var lineB = rect.getLineB(); + var lineC = rect.getLineC(); + var lineD = rect.getLineD(); + + GetLineToCircle(lineA, circle, out); + GetLineToCircle(lineB, circle, out); + GetLineToCircle(lineC, circle, out); + GetLineToCircle(lineD, circle, out); + } + + return out; +}; + +module.exports = GetCircleToRectangle; + + +/***/ }, + +/***/ 4042 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); +var LineToCircle = __webpack_require__(80462); + +/** + * Checks for intersection between the line segment and circle, + * and returns the intersection points as a Vector2 object array. + * + * @function Phaser.Geom.Intersects.GetLineToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line segment to check. + * @param {Phaser.Geom.Circle} circle - The circle to check against the line. + * @param {Phaser.Math.Vector2[]} [out] - An optional array of Vector2 objects in which to store the points of intersection. + * + * @return {Phaser.Math.Vector2[]} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetLineToCircle = function (line, circle, out) +{ + if (out === undefined) { out = []; } + + if (LineToCircle(line, circle)) + { + var lx1 = line.x1; + var ly1 = line.y1; + + var lx2 = line.x2; + var ly2 = line.y2; + + var cx = circle.x; + var cy = circle.y; + var cr = circle.radius; + + var lDirX = lx2 - lx1; + var lDirY = ly2 - ly1; + var oDirX = lx1 - cx; + var oDirY = ly1 - cy; + + var coefficientA = lDirX * lDirX + lDirY * lDirY; + var coefficientB = 2 * (lDirX * oDirX + lDirY * oDirY); + var coefficientC = oDirX * oDirX + oDirY * oDirY - cr * cr; + + var lambda = (coefficientB * coefficientB) - (4 * coefficientA * coefficientC); + + var x, y; + + if (lambda === 0) + { + var root = -coefficientB / (2 * coefficientA); + + x = lx1 + root * lDirX; + y = ly1 + root * lDirY; + + if (root >= 0 && root <= 1) + { + out.push(new Vector2(x, y)); + } + } + else if (lambda > 0) + { + var root1 = (-coefficientB - Math.sqrt(lambda)) / (2 * coefficientA); + + x = lx1 + root1 * lDirX; + y = ly1 + root1 * lDirY; + + if (root1 >= 0 && root1 <= 1) + { + out.push(new Vector2(x, y)); + } + + var root2 = (-coefficientB + Math.sqrt(lambda)) / (2 * coefficientA); + + x = lx1 + root2 * lDirX; + y = ly1 + root2 * lDirY; + + if (root2 >= 0 && root2 <= 1) + { + out.push(new Vector2(x, y)); + } + } + } + + return out; +}; + +module.exports = GetLineToCircle; + + +/***/ }, + +/***/ 36100 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector3 = __webpack_require__(25836); + +/** + * Checks for intersection between the two line segments, or a ray and a line segment, + * and returns the intersection point as a Vector3, or `null` if the lines are parallel, or do not intersect. + * + * The `z` property of the Vector3 contains the parametric `t` value (a scalar between 0 and 1) + * representing how far along `line1` the intersection occurs. This can be used to sort or compare + * multiple intersection results to find the closest intersecting point from a group of line segments. + * + * @function Phaser.Geom.Intersects.GetLineToLine + * @since 3.50.0 + * + * @param {Phaser.Geom.Line} line1 - The first line segment, or a ray, to check. + * @param {Phaser.Geom.Line} line2 - The second line segment to check. + * @param {boolean} [isRay=false] - Is `line1` a ray or a line segment? + * @param {Phaser.Math.Vector3} [out] - A Vector3 to store the intersection results in. + * + * @return {Phaser.Math.Vector3} A Vector3 where `x` and `y` are the intersection point coordinates and `z` is the parametric `t` value along `line1`, or `null` if the lines do not intersect. + */ +var GetLineToLine = function (line1, line2, isRay, out) +{ + if (isRay === undefined) { isRay = false; } + + var x1 = line1.x1; + var y1 = line1.y1; + var x2 = line1.x2; + var y2 = line1.y2; + + var x3 = line2.x1; + var y3 = line2.y1; + var x4 = line2.x2; + var y4 = line2.y2; + + var dx1 = x2 - x1; + var dy1 = y2 - y1; + + var dx2 = x4 - x3; + var dy2 = y4 - y3; + + var denom = (dx1 * dy2 - dy1 * dx2); + + // Add co-linear check + + // Make sure there is not a division by zero - this also indicates that the lines are parallel. + // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). + // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). + + if (denom === 0) + { + return null; + } + + var t; + var u; + var s; + + if (isRay) + { + t = (dx1 * (y3 - y1) + dy1 * (x1 - x3)) / (dx2 * dy1 - dy2 * dx1); + + if (dx1 !== 0) + { + u = (x3 + dx2 * t - x1) / dx1; + } + else if (dy1 !== 0) + { + u = (y3 + dy2 * t - y1) / dy1; + } + else + { + return null; // degenerate line segment + } + + // Intersects? + if (u < 0 || t < 0 || t > 1) + { + return null; + } + + s = u; + } + else + { + t = ((x3 - x1) * dy2 - (y3 - y1) * dx2) / denom; + u = ((y1 - y3) * dx1 - (x1 - x3) * dy1) / denom; + + // Intersects? + if (t < 0 || t > 1 || u < 0 || u > 1) + { + return null; + } + + s = t; + } + + if (out === undefined) + { + out = new Vector3(); + } + + return out.set( + x1 + dx1 * s, + y1 + dy1 * s, + s + ); +}; + +module.exports = GetLineToLine; + + +/***/ }, + +/***/ 3073 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetLineToLine = __webpack_require__(36100); +var Line = __webpack_require__(23031); +var Vector3 = __webpack_require__(25836); + +// Temp calculation segment +var segment = new Line(); + +// Temp vec3 +var tempIntersect = new Vector3(); + +/** + * Checks for the closest point of intersection between a line segment and an array of points, where each consecutive pair + * of points is converted to a line segment for the intersection tests. The array is treated as a closed shape, meaning + * the last point is connected back to the first point. + * + * If no intersection is found, this function returns `null`. + * + * If intersection was found, a Vector3 is returned with the following properties: + * + * The `x` and `y` components contain the point of the intersection. + * The `z` component contains the closest distance. + * + * @function Phaser.Geom.Intersects.GetLineToPoints + * @since 3.50.0 + * + * @param {Phaser.Geom.Line} line - The line segment, or ray, to check. If a ray, set the `isRay` parameter to `true`. + * @param {Phaser.Math.Vector2[] | Phaser.Math.Vector2[]} points - An array of points to check. + * @param {boolean} [isRay=false] - Is `line` a ray or a line segment? + * @param {Phaser.Math.Vector3} [out] - A Vector3 to store the intersection results in. + * + * @return {Phaser.Math.Vector3} A Vector3 containing the intersection results, or `null`. + */ +var GetLineToPoints = function (line, points, isRay, out) +{ + if (isRay === undefined) { isRay = false; } + if (out === undefined) { out = new Vector3(); } + + var closestIntersect = false; + + // Reset our vec3s + out.set(); + tempIntersect.set(); + + var prev = points[points.length - 1]; + + for (var i = 0; i < points.length; i++) + { + var current = points[i]; + + segment.setTo(prev.x, prev.y, current.x, current.y); + + prev = current; + + if (GetLineToLine(line, segment, isRay, tempIntersect)) + { + if (!closestIntersect || tempIntersect.z < out.z) + { + out.copy(tempIntersect); + + closestIntersect = true; + } + } + } + + return (closestIntersect) ? out : null; +}; + +module.exports = GetLineToPoints; + + +/***/ }, + +/***/ 56362 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector3 = __webpack_require__(25836); +var Vector4 = __webpack_require__(61369); +var GetLineToPoints = __webpack_require__(3073); + +// Temp vec3 +var tempIntersect = new Vector3(); + +/** + * Checks for the closest point of intersection between a line segment and an array of polygons. + * + * If no intersection is found, this function returns `null`. + * + * If intersection was found, a Vector4 is returned with the following properties: + * + * The `x` and `y` components contain the point of the intersection. + * The `z` component contains the closest distance. + * The `w` component contains the index of the polygon, in the given array, that triggered the intersection. + * + * @function Phaser.Geom.Intersects.GetLineToPolygon + * @since 3.50.0 + * + * @param {Phaser.Geom.Line} line - The line segment, or ray, to check. If a ray, set the `isRay` parameter to `true`. + * @param {Phaser.Geom.Polygon | Phaser.Geom.Polygon[]} polygons - A single polygon, or array of polygons, to check. + * @param {boolean} [isRay=false] - Is `line` a ray or a line segment? + * @param {Phaser.Math.Vector4} [out] - A Vector4 to store the intersection results in. + * + * @return {Phaser.Math.Vector4} A Vector4 containing the intersection results, or `null`. + */ +var GetLineToPolygon = function (line, polygons, isRay, out) +{ + if (out === undefined) { out = new Vector4(); } + + if (!Array.isArray(polygons)) + { + polygons = [ polygons ]; + } + + var closestIntersect = false; + + // Reset our vec4s + out.set(); + tempIntersect.set(); + + for (var i = 0; i < polygons.length; i++) + { + if (GetLineToPoints(line, polygons[i].points, isRay, tempIntersect)) + { + if (!closestIntersect || tempIntersect.z < out.z) + { + out.set(tempIntersect.x, tempIntersect.y, tempIntersect.z, i); + + closestIntersect = true; + } + } + } + + return (closestIntersect) ? out : null; +}; + +module.exports = GetLineToPolygon; + + +/***/ }, + +/***/ 60646 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); +var LineToLine = __webpack_require__(76112); +var LineToRectangle = __webpack_require__(92773); + +/** + * Checks for intersection between the Line and a Rectangle shape, + * and returns the intersection points as a Vector2 array. + * + * @function Phaser.Geom.Intersects.GetLineToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The Line to check for intersection. + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to check for intersection. + * @param {Phaser.Math.Vector2[]} [out] - An optional array of Vector2 objects in which to store the points of intersection. + * + * @return {Phaser.Math.Vector2[]} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetLineToRectangle = function (line, rect, out) +{ + if (out === undefined) { out = []; } + + if (LineToRectangle(line, rect)) + { + var lineA = rect.getLineA(); + var lineB = rect.getLineB(); + var lineC = rect.getLineC(); + var lineD = rect.getLineD(); + + var output = [ new Vector2(), new Vector2(), new Vector2(), new Vector2() ]; + + var result = [ + LineToLine(lineA, line, output[0]), + LineToLine(lineB, line, output[1]), + LineToLine(lineC, line, output[2]), + LineToLine(lineD, line, output[3]) + ]; + + for (var i = 0; i < 4; i++) + { + if (result[i]) + { + out.push(output[i]); + } + } + } + + return out; +}; + +module.exports = GetLineToRectangle; + + +/***/ }, + +/***/ 71147 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector4 = __webpack_require__(61369); +var GetLineToPolygon = __webpack_require__(56362); +var Line = __webpack_require__(23031); + +// Temp calculation segment +var segment = new Line(); + +/** + * @ignore + */ +function CheckIntersects (angle, x, y, polygons, intersects) +{ + var dx = Math.cos(angle); + var dy = Math.sin(angle); + + segment.setTo(x, y, x + dx, y + dy); + + var closestIntersect = GetLineToPolygon(segment, polygons, true); + + if (closestIntersect) + { + intersects.push(new Vector4(closestIntersect.x, closestIntersect.y, angle, closestIntersect.w)); + } +} + +/** + * @ignore + */ +function SortIntersects (a, b) +{ + return a.z - b.z; +} + +/** + * Projects rays out from the given point to each vertex of the polygons. + * + * If the rays intersect with the polygons, the points of intersection are returned in an array. + * + * If no intersections are found, the returned array will be empty. + * + * Each Vector4 intersection result has the following properties: + * + * The `x` and `y` components contain the point of the intersection. + * The `z` component contains the angle of the projected ray, in radians. + * The `w` component contains the index of the polygon, in the given array, that triggered the intersection. + * + * @function Phaser.Geom.Intersects.GetRaysFromPointToPolygon + * @since 3.50.0 + * + * @param {number} x - The x coordinate to project the rays from. + * @param {number} y - The y coordinate to project the rays from. + * @param {Phaser.Geom.Polygon | Phaser.Geom.Polygon[]} polygons - A single polygon, or array of polygons, to check against the rays. + * + * @return {Phaser.Math.Vector4[]} An array containing all intersections in Vector4s. + */ +var GetRaysFromPointToPolygon = function (x, y, polygons) +{ + if (!Array.isArray(polygons)) + { + polygons = [ polygons ]; + } + + var intersects = []; + var angles = []; + + for (var i = 0; i < polygons.length; i++) + { + var points = polygons[i].points; + + for (var p = 0; p < points.length; p++) + { + var angle = Math.atan2(points[p].y - y, points[p].x - x); + + if (angles.indexOf(angle) === -1) + { + // +- 0.00001 rads to catch lines behind segment corners + + CheckIntersects(angle, x, y, polygons, intersects); + CheckIntersects(angle - 0.00001, x, y, polygons, intersects); + CheckIntersects(angle + 0.00001, x, y, polygons, intersects); + + angles.push(angle); + } + } + } + + return intersects.sort(SortIntersects); +}; + +module.exports = GetRaysFromPointToPolygon; + + +/***/ }, + +/***/ 68389 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); +var RectangleToRectangle = __webpack_require__(59996); + +/** + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it will be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersection, it will be returned without any change. + * + * @function Phaser.Geom.Intersects.GetRectangleIntersection + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [output,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle object. + * @param {Phaser.Geom.Rectangle} [output] - Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. + * + * @return {Phaser.Geom.Rectangle} A rectangle object with intersection data. + */ +var GetRectangleIntersection = function (rectA, rectB, output) +{ + if (output === undefined) { output = new Rectangle(); } + + if (RectangleToRectangle(rectA, rectB)) + { + output.x = Math.max(rectA.x, rectB.x); + output.y = Math.max(rectA.y, rectB.y); + output.width = Math.min(rectA.right, rectB.right) - output.x; + output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; + } + + return output; +}; + +module.exports = GetRectangleIntersection; + + +/***/ }, + +/***/ 52784 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetLineToRectangle = __webpack_require__(60646); +var RectangleToRectangle = __webpack_require__(59996); + +/** + * Checks if two Rectangles intersect and returns the intersection points as a Point object array. + * + * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. + * + * @function Phaser.Geom.Intersects.GetRectangleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to check for intersection. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to check for intersection. + * @param {array} [out] - An optional array in which to store the points of intersection. + * + * @return {array} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetRectangleToRectangle = function (rectA, rectB, out) +{ + if (out === undefined) { out = []; } + + if (RectangleToRectangle(rectA, rectB)) + { + var lineA = rectA.getLineA(); + var lineB = rectA.getLineB(); + var lineC = rectA.getLineC(); + var lineD = rectA.getLineD(); + + GetLineToRectangle(lineA, rectB, out); + GetLineToRectangle(lineB, rectB, out); + GetLineToRectangle(lineC, rectB, out); + GetLineToRectangle(lineD, rectB, out); + } + + return out; +}; + +module.exports = GetRectangleToRectangle; + + +/***/ }, + +/***/ 26341 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RectangleToTriangle = __webpack_require__(89265); +var GetLineToRectangle = __webpack_require__(60646); + +/** + * Checks for intersection between Rectangle shape and Triangle shape, + * and returns the intersection points as a Point object array. + * + * @function Phaser.Geom.Intersects.GetRectangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - Rectangle object to test. + * @param {Phaser.Geom.Triangle} triangle - Triangle object to test. + * @param {array} [out] - An optional array in which to store the points of intersection. + * + * @return {array} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetRectangleToTriangle = function (rect, triangle, out) +{ + if (out === undefined) { out = []; } + + if (RectangleToTriangle(rect, triangle)) + { + var lineA = triangle.getLineA(); + var lineB = triangle.getLineB(); + var lineC = triangle.getLineC(); + + GetLineToRectangle(lineA, rect, out); + GetLineToRectangle(lineB, rect, out); + GetLineToRectangle(lineC, rect, out); + } + + return out; +}; + +module.exports = GetRectangleToTriangle; + + +/***/ }, + +/***/ 38720 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetLineToCircle = __webpack_require__(4042); +var TriangleToCircle = __webpack_require__(67636); + +/** + * Checks if a Triangle and a Circle intersect, and returns the intersection points as a Point object array. + * + * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. + * + * @function Phaser.Geom.Intersects.GetTriangleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check for intersection. + * @param {Phaser.Geom.Circle} circle - The Circle to check for intersection. + * @param {array} [out] - An optional array in which to store the points of intersection. + * + * @return {array} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetTriangleToCircle = function (triangle, circle, out) +{ + if (out === undefined) { out = []; } + + if (TriangleToCircle(triangle, circle)) + { + var lineA = triangle.getLineA(); + var lineB = triangle.getLineB(); + var lineC = triangle.getLineC(); + + GetLineToCircle(lineA, circle, out); + GetLineToCircle(lineB, circle, out); + GetLineToCircle(lineC, circle, out); + } + + return out; +}; + +module.exports = GetTriangleToCircle; + + +/***/ }, + +/***/ 13882 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); +var TriangleToLine = __webpack_require__(2822); +var LineToLine = __webpack_require__(76112); + +/** + * Checks if a Triangle and a Line intersect, and returns the intersection points as a Point object array. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * + * @function Phaser.Geom.Intersects.GetTriangleToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check with. + * @param {Phaser.Geom.Line} line - The Line to check with. + * @param {Phaser.Math.Vector2[]} [out] - An optional array of Vector2 objects in which to store the points of intersection. + * + * @return {Phaser.Math.Vector2[]} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetTriangleToLine = function (triangle, line, out) +{ + if (out === undefined) { out = []; } + + if (TriangleToLine(triangle, line)) + { + var lineA = triangle.getLineA(); + var lineB = triangle.getLineB(); + var lineC = triangle.getLineC(); + + var output = [ new Vector2(), new Vector2(), new Vector2() ]; + + var result = [ + LineToLine(lineA, line, output[0]), + LineToLine(lineB, line, output[1]), + LineToLine(lineC, line, output[2]) + ]; + + for (var i = 0; i < 3; i++) + { + if (result[i]) + { + out.push(output[i]); + } + } + } + + return out; +}; + +module.exports = GetTriangleToLine; + + +/***/ }, + +/***/ 75636 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Florian Vazelle + * @author Geoffrey Glaive + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var TriangleToTriangle = __webpack_require__(82944); +var GetTriangleToLine = __webpack_require__(13882); + +/** + * Checks if two Triangles intersect, and returns the intersection points as a Point object array. + * + * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". + * + * @function Phaser.Geom.Intersects.GetTriangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangleA - The first Triangle to check for intersection. + * @param {Phaser.Geom.Triangle} triangleB - The second Triangle to check for intersection. + * @param {array} [out] - An optional array in which to store the points of intersection. + * + * @return {array} An array with the points of intersection if objects intersect, otherwise an empty array. + */ +var GetTriangleToTriangle = function (triangleA, triangleB, out) +{ + if (out === undefined) { out = []; } + + if (TriangleToTriangle(triangleA, triangleB)) + { + var lineA = triangleB.getLineA(); + var lineB = triangleB.getLineB(); + var lineC = triangleB.getLineC(); + + GetTriangleToLine(triangleA, lineA, out); + GetTriangleToLine(triangleA, lineB, out); + GetTriangleToLine(triangleA, lineC, out); + } + + return out; +}; + +module.exports = GetTriangleToTriangle; + + +/***/ }, + +/***/ 80462 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(87902); +var Vector2 = __webpack_require__(26099); + +var tmp = new Vector2(); + +/** + * Checks for intersection between the line segment and circle. + * + * Based on code by [Matt DesLauriers](https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md). + * + * @function Phaser.Geom.Intersects.LineToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line segment to check. + * @param {Phaser.Geom.Circle} circle - The circle to check against the line. + * @param {Phaser.Math.Vector2} [nearest] - An optional Vector2 object. If given the closest point on the Line where the circle intersects will be stored in this object. + * + * @return {boolean} `true` if the two objects intersect, otherwise `false`. + */ +var LineToCircle = function (line, circle, nearest) +{ + if (nearest === undefined) { nearest = tmp; } + + if (Contains(circle, line.x1, line.y1)) + { + nearest.x = line.x1; + nearest.y = line.y1; + + return true; + } + + if (Contains(circle, line.x2, line.y2)) + { + nearest.x = line.x2; + nearest.y = line.y2; + + return true; + } + + var dx = line.x2 - line.x1; + var dy = line.y2 - line.y1; + + var lcx = circle.x - line.x1; + var lcy = circle.y - line.y1; + + // project lc onto d, resulting in vector p + var dLen2 = (dx * dx) + (dy * dy); + var px = dx; + var py = dy; + + if (dLen2 > 0) + { + var dp = ((lcx * dx) + (lcy * dy)) / dLen2; + + px *= dp; + py *= dp; + } + + nearest.x = line.x1 + px; + nearest.y = line.y1 + py; + + // len2 of p + var pLen2 = (px * px) + (py * py); + + return ( + pLen2 <= dLen2 && + ((px * dx) + (py * dy)) >= 0 && + Contains(circle, nearest.x, nearest.y) + ); +}; + +module.exports = LineToCircle; + + +/***/ }, + +/***/ 76112 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// This is based off an explanation and expanded math presented by Paul Bourke: +// See http://paulbourke.net/geometry/pointlineplane/ + +/** + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. + * + * @function Phaser.Geom.Intersects.LineToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line1 - The first Line to check. + * @param {Phaser.Geom.Line} line2 - The second Line to check. + * @param {Phaser.Types.Math.Vector2Like} [out] - An optional point-like object in which to store the coordinates of intersection, if needed. + * + * @return {boolean} `true` if the two Lines intersect, and the `out` object will be populated, if given. Otherwise, `false`. + */ +var LineToLine = function (line1, line2, out) +{ + var x1 = line1.x1; + var y1 = line1.y1; + var x2 = line1.x2; + var y2 = line1.y2; + + var x3 = line2.x1; + var y3 = line2.y1; + var x4 = line2.x2; + var y4 = line2.y2; + + // Check that none of the lines are length zero + if ((x1 === x2 && y1 === y2) || (x3 === x4 && y3 === y4)) + { + return false; + } + + var denom = ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1)); + + // Make sure there is not a division by zero - this also indicates that the lines are parallel. + // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). + // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). + + if (denom === 0) + { + // Lines are parallel + return false; + } + + // Calculate the intermediate fractional point that the lines potentially intersect. + + var ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denom; + var ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denom; + + // The fractional point will be between 0 and 1 inclusive if the lines intersect. + // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. + + if (ua < 0 || ua > 1 || ub < 0 || ub > 1) + { + return false; + } + else + { + if (out) + { + out.x = x1 + ua * (x2 - x1); + out.y = y1 + ua * (y2 - y1); + } + + return true; + } +}; + +module.exports = LineToLine; + + +/***/ }, + +/***/ 92773 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * For the purposes of this function rectangles are considered 'solid'. + * + * @function Phaser.Geom.Intersects.LineToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The Line to check for intersection. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle to check for intersection. + * + * @return {boolean} `true` if the Line and the Rectangle intersect, `false` otherwise. + */ +var LineToRectangle = function (line, rect) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var bx1 = rect.x; + var by1 = rect.y; + var bx2 = rect.right; + var by2 = rect.bottom; + + var t = 0; + + // If the start or end of the line is inside the rect then we assume + // collision, as rects are solid for our use-case. + + if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || + (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) + { + return true; + } + + if (x1 < bx1 && x2 >= bx1) + { + // Left edge + t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); + + if (t > by1 && t <= by2) + { + return true; + } + } + else if (x1 > bx2 && x2 <= bx2) + { + // Right edge + t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); + + if (t >= by1 && t <= by2) + { + return true; + } + } + + if (y1 < by1 && y2 >= by1) + { + // Top edge + t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + else if (y1 > by2 && y2 <= by2) + { + // Bottom edge + t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + + return false; +}; + +module.exports = LineToRectangle; + + +/***/ }, + +/***/ 16204 +(module) { + +/** + * @author Richard Davey + * @author Florian Mertens + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Checks if a Point falls between the two end-points of a Line, based on the given line thickness. + * + * Assumes that the line end points are circular, not square. + * + * @function Phaser.Geom.Intersects.PointToLine + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|any)} point - The point, or point-like object to check. + * @param {Phaser.Geom.Line} line - The line segment to test for intersection on. + * @param {number} [lineThickness=1] - The line thickness. Assumes that the line end points are circular. + * + * @return {boolean} `true` if the Point falls on the Line, otherwise `false`. + */ +var PointToLine = function (point, line, lineThickness) +{ + if (lineThickness === undefined) { lineThickness = 1; } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var px = point.x; + var py = point.y; + + var L2 = (((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); + + if (L2 === 0) + { + return false; + } + + var r = (((px - x1) * (x2 - x1)) + ((py - y1) * (y2 - y1))) / L2; + + // Assume line thickness is circular + if (r < 0) + { + // Outside line1 + return (Math.sqrt(((x1 - px) * (x1 - px)) + ((y1 - py) * (y1 - py))) <= lineThickness); + } + else if ((r >= 0) && (r <= 1)) + { + // On the line segment + var s = (((y1 - py) * (x2 - x1)) - ((x1 - px) * (y2 - y1))) / L2; + + return (Math.abs(s) * Math.sqrt(L2) <= lineThickness); + } + else + { + // Outside line2 + return (Math.sqrt(((x2 - px) * (x2 - px)) + ((y2 - py) * (y2 - py))) <= lineThickness); + } +}; + +module.exports = PointToLine; + + +/***/ }, + +/***/ 14199 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var PointToLine = __webpack_require__(16204); + +/** + * Checks if a Point is located on the given line segment. + * + * @function Phaser.Geom.Intersects.PointToLineSegment + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} point - The Point to check for intersection. + * @param {Phaser.Geom.Line} line - The line segment to check for intersection. + * + * @return {boolean} `true` if the Point is on the given line segment, otherwise `false`. + */ +var PointToLineSegment = function (point, line) +{ + if (!PointToLine(point, line)) + { + return false; + } + + var xMin = Math.min(line.x1, line.x2); + var xMax = Math.max(line.x1, line.x2); + var yMin = Math.min(line.y1, line.y2); + var yMax = Math.max(line.y1, line.y2); + + return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); +}; + +module.exports = PointToLineSegment; + + +/***/ }, + +/***/ 59996 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Checks if two Rectangles intersect. + * + * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. + * As such, the two Rectangles are considered "solid". + * A Rectangle with no width or no height will never intersect another Rectangle. + * + * @function Phaser.Geom.Intersects.RectangleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to check for intersection. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to check for intersection. + * + * @return {boolean} `true` if the two Rectangles intersect, otherwise `false`. + */ +var RectangleToRectangle = function (rectA, rectB) +{ + if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + { + return false; + } + + return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); +}; + +module.exports = RectangleToRectangle; + + +/***/ }, + +/***/ 89265 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var LineToLine = __webpack_require__(76112); +var Contains = __webpack_require__(37303); +var ContainsArray = __webpack_require__(48653); +var Decompose = __webpack_require__(77493); + +/** + * Checks for intersection between a Rectangle and a Triangle shape. + * + * The test is performed in multiple stages of increasing cost. First, the bounding + * boxes of the two shapes are compared for a quick early-out. If they overlap, the + * test checks whether any triangle vertex lies inside the rectangle, then whether any + * edge of the triangle intersects any edge of the rectangle, and finally whether any + * corner of the rectangle lies inside the triangle. + * + * @function Phaser.Geom.Intersects.RectangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to test. + * @param {Phaser.Geom.Triangle} triangle - The Triangle to test. + * + * @return {boolean} A value of `true` if objects intersect; otherwise `false`. + */ +var RectangleToTriangle = function (rect, triangle) +{ + // First the cheapest ones: + + if ( + triangle.left > rect.right || + triangle.right < rect.left || + triangle.top > rect.bottom || + triangle.bottom < rect.top) + { + return false; + } + + var triA = triangle.getLineA(); + var triB = triangle.getLineB(); + var triC = triangle.getLineC(); + + // Are any of the triangle points within the rectangle? + + if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) + { + return true; + } + + if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) + { + return true; + } + + if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) + { + return true; + } + + // Cheap tests over, now to see if any of the lines intersect ... + + var rectA = rect.getLineA(); + var rectB = rect.getLineB(); + var rectC = rect.getLineC(); + var rectD = rect.getLineD(); + + if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) + { + return true; + } + + if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) + { + return true; + } + + if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) + { + return true; + } + + // None of the lines intersect, so are any rectangle points within the triangle? + + var points = Decompose(rect); + var within = ContainsArray(triangle, points, true); + + return (within.length > 0); +}; + +module.exports = RectangleToTriangle; + + +/***/ }, + +/***/ 84411 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Checks if a Rectangle intersects with a region defined by explicit left, right, top, and bottom boundary values. + * + * @function Phaser.Geom.Intersects.RectangleToValues + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to check for intersection. + * @param {number} left - The x coordinate of the left edge of the region to check against. + * @param {number} right - The x coordinate of the right edge of the region to check against. + * @param {number} top - The y coordinate of the top edge of the region to check against. + * @param {number} bottom - The y coordinate of the bottom edge of the region to check against. + * @param {number} [tolerance=0] - Tolerance allowed in the calculation, expressed in pixels. + * + * @return {boolean} Returns true if there is an intersection. + */ +var RectangleToValues = function (rect, left, right, top, bottom, tolerance) +{ + if (tolerance === undefined) { tolerance = 0; } + + return !( + left > rect.right + tolerance || + right < rect.left - tolerance || + top > rect.bottom + tolerance || + bottom < rect.top - tolerance + ); +}; + +module.exports = RectangleToValues; + + +/***/ }, + +/***/ 67636 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var LineToCircle = __webpack_require__(80462); +var Contains = __webpack_require__(10690); + +/** + * Checks if a Triangle and a Circle intersect. + * + * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. + * + * @function Phaser.Geom.Intersects.TriangleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check for intersection. + * @param {Phaser.Geom.Circle} circle - The Circle to check for intersection. + * + * @return {boolean} `true` if the Triangle and the `Circle` intersect, otherwise `false`. + */ +var TriangleToCircle = function (triangle, circle) +{ + // First the cheapest ones: + + if ( + triangle.left > circle.right || + triangle.right < circle.left || + triangle.top > circle.bottom || + triangle.bottom < circle.top) + { + return false; + } + + if (Contains(triangle, circle.x, circle.y)) + { + return true; + } + + if (LineToCircle(triangle.getLineA(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineB(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineC(), circle)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToCircle; + + +/***/ }, + +/***/ 2822 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var LineToLine = __webpack_require__(76112); + +/** + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * + * @function Phaser.Geom.Intersects.TriangleToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check with. + * @param {Phaser.Geom.Line} line - The Line to check with. + * + * @return {boolean} `true` if the Triangle and the Line intersect, otherwise `false`. + */ +var TriangleToLine = function (triangle, line) +{ + // If the Triangle contains either the start or end point of the line, it intersects + if (triangle.contains(line.x1, line.y1) || triangle.contains(line.x2, line.y2)) + { + return true; + } + + // Now check the line against each line of the Triangle + if (LineToLine(triangle.getLineA(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineB(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineC(), line)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToLine; + + +/***/ }, + +/***/ 82944 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ContainsArray = __webpack_require__(48653); +var Decompose = __webpack_require__(71694); +var LineToLine = __webpack_require__(76112); + +/** + * Checks if two Triangles intersect. + * + * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". + * + * @function Phaser.Geom.Intersects.TriangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangleA - The first Triangle to check for intersection. + * @param {Phaser.Geom.Triangle} triangleB - The second Triangle to check for intersection. + * + * @return {boolean} `true` if the Triangles intersect, otherwise `false`. + */ +var TriangleToTriangle = function (triangleA, triangleB) +{ + // First the cheapest ones: + + if ( + triangleA.left > triangleB.right || + triangleA.right < triangleB.left || + triangleA.top > triangleB.bottom || + triangleA.bottom < triangleB.top) + { + return false; + } + + var lineAA = triangleA.getLineA(); + var lineAB = triangleA.getLineB(); + var lineAC = triangleA.getLineC(); + + var lineBA = triangleB.getLineA(); + var lineBB = triangleB.getLineB(); + var lineBC = triangleB.getLineC(); + + // Now check the lines against each line of TriangleB + if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) + { + return true; + } + + if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) + { + return true; + } + + if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) + { + return true; + } + + // Nope, so check to see if any of the points of triangleA are within triangleB + + var points = Decompose(triangleA); + var within = ContainsArray(triangleB, points, true); + + if (within.length > 0) + { + return true; + } + + // Finally check to see if any of the points of triangleB are within triangleA + + points = Decompose(triangleB); + within = ContainsArray(triangleA, points, true); + + if (within.length > 0) + { + return true; + } + + return false; +}; + +module.exports = TriangleToTriangle; + + +/***/ }, + +/***/ 91865 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Geom.Intersects + */ + +module.exports = { + + CircleToCircle: __webpack_require__(2044), + CircleToRectangle: __webpack_require__(81491), + GetCircleToCircle: __webpack_require__(63376), + GetCircleToRectangle: __webpack_require__(97439), + GetLineToCircle: __webpack_require__(4042), + GetLineToLine: __webpack_require__(36100), + GetLineToPoints: __webpack_require__(3073), + GetLineToPolygon: __webpack_require__(56362), + GetLineToRectangle: __webpack_require__(60646), + GetRaysFromPointToPolygon: __webpack_require__(71147), + GetRectangleIntersection: __webpack_require__(68389), + GetRectangleToRectangle: __webpack_require__(52784), + GetRectangleToTriangle: __webpack_require__(26341), + GetTriangleToCircle: __webpack_require__(38720), + GetTriangleToLine: __webpack_require__(13882), + GetTriangleToTriangle: __webpack_require__(75636), + LineToCircle: __webpack_require__(80462), + LineToLine: __webpack_require__(76112), + LineToRectangle: __webpack_require__(92773), + PointToLine: __webpack_require__(16204), + PointToLineSegment: __webpack_require__(14199), + RectangleToRectangle: __webpack_require__(59996), + RectangleToTriangle: __webpack_require__(89265), + RectangleToValues: __webpack_require__(84411), + TriangleToCircle: __webpack_require__(67636), + TriangleToLine: __webpack_require__(2822), + TriangleToTriangle: __webpack_require__(82944) + +}; + + +/***/ }, + +/***/ 91938 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculate the angle of the line in radians. + * + * @function Phaser.Geom.Line.Angle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the angle of. + * + * @return {number} The angle of the line, in radians. + */ +var Angle = function (line) +{ + return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); +}; + +module.exports = Angle; + + +/***/ }, + +/***/ 84993 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Using Bresenham's line algorithm this will return an array of all coordinates on the given line. + * + * The `start` and `end` points are rounded before this runs as the algorithm works on integers. + * + * @function Phaser.Geom.Line.BresenhamPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line. + * @param {number} [stepRate=1] - Controls how densely the points are sampled along the line. A value of 1 returns every integer coordinate; a value of 2 returns every other coordinate, and so on. + * @param {Phaser.Types.Math.Vector2Like[]} [results] - An optional array to push the resulting coordinates into. + * + * @return {Phaser.Types.Math.Vector2Like[]} The array of coordinates on the line. + */ +var BresenhamPoints = function (line, stepRate, results) +{ + if (stepRate === undefined) { stepRate = 1; } + if (results === undefined) { results = []; } + + var x1 = Math.round(line.x1); + var y1 = Math.round(line.y1); + var x2 = Math.round(line.x2); + var y2 = Math.round(line.y2); + + var dx = Math.abs(x2 - x1); + var dy = Math.abs(y2 - y1); + var sx = (x1 < x2) ? 1 : -1; + var sy = (y1 < y2) ? 1 : -1; + var err = dx - dy; + + results.push({ x: x1, y: y1 }); + + var i = 1; + + while (!((x1 === x2) && (y1 === y2))) + { + var e2 = err << 1; + + if (e2 > -dy) + { + err -= dy; + x1 += sx; + } + + if (e2 < dx) + { + err += dx; + y1 += sy; + } + + if (i % stepRate === 0) + { + results.push({ x: x1, y: y1 }); + } + + i++; + } + + return results; +}; + +module.exports = BresenhamPoints; + + +/***/ }, + +/***/ 36469 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + + +/** + * Center a line on the given coordinates. + * + * @function Phaser.Geom.Line.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to center. + * @param {number} x - The horizontal coordinate to center the line on. + * @param {number} y - The vertical coordinate to center the line on. + * + * @return {Phaser.Geom.Line} The centered line. + */ +var CenterOn = function (line, x, y) +{ + var tx = x - ((line.x1 + line.x2) / 2); + var ty = y - ((line.y1 + line.y2) / 2); + + line.x1 += tx; + line.y1 += ty; + + line.x2 += tx; + line.y2 += ty; + + return line; +}; + +module.exports = CenterOn; + + +/***/ }, + +/***/ 31116 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Line = __webpack_require__(23031); + +/** + * Clone the given line. + * + * @function Phaser.Geom.Line.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - The source line to clone. + * + * @return {Phaser.Geom.Line} The cloned line. + */ +var Clone = function (source) +{ + return new Line(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = Clone; + + +/***/ }, + +/***/ 59944 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Copy the values of one line to a destination line. + * + * @function Phaser.Geom.Line.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [dest,$return] + * + * @param {Phaser.Geom.Line} source - The source line to copy the values from. + * @param {Phaser.Geom.Line} dest - The destination line to copy the values to. + * + * @return {Phaser.Geom.Line} The destination line. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = CopyFrom; + + +/***/ }, + +/***/ 59220 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Compares two lines for strict equality. Two lines are considered equal if their start + * and end point coordinates all match exactly: `x1`, `y1`, `x2`, and `y2`. + * + * @function Phaser.Geom.Line.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The first line to compare. + * @param {Phaser.Geom.Line} toCompare - The second line to compare. + * + * @return {boolean} `true` if the two lines have identical start and end point coordinates, otherwise `false`. + */ +var Equals = function (line, toCompare) +{ + return ( + line.x1 === toCompare.x1 && + line.y1 === toCompare.y1 && + line.x2 === toCompare.x2 && + line.y2 === toCompare.y2 + ); +}; + +module.exports = Equals; + + +/***/ }, + +/***/ 78177 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Length = __webpack_require__(35001); + +/** + * Extends the start and end points of a Line by the given amounts. + * + * The amounts can be positive or negative. Positive values will increase the length of the line, + * while negative ones will decrease it. + * + * If no `right` value is provided it will extend the length of the line equally in both directions. + * + * Pass a value of zero to leave the start or end point unchanged. + * + * The `left` value extends outward from the start point (x1, y1) along the line's direction, and the `right` value extends outward from the end point (x2, y2). + * + * @function Phaser.Geom.Line.Extend + * @since 3.16.0 + * + * @param {Phaser.Geom.Line} line - The line instance to extend. + * @param {number} left - The amount to extend the start of the line by. + * @param {number} [right] - The amount to extend the end of the line by. If not given it will be set to the `left` value. + * + * @return {Phaser.Geom.Line} The modified Line instance. + */ +var Extend = function (line, left, right) +{ + if (right === undefined) { right = left; } + + var length = Length(line); + + var slopX = line.x2 - line.x1; + var slopY = line.y2 - line.y1; + + if (left) + { + line.x1 = line.x1 - slopX / length * left; + line.y1 = line.y1 - slopY / length * left; + } + + if (right) + { + line.x2 = line.x2 + slopX / length * right; + line.y2 = line.y2 + slopY / length * right; + } + + return line; +}; + +module.exports = Extend; + + +/***/ }, + +/***/ 26708 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var DistanceBetweenPoints = __webpack_require__(52816); +var GetEaseFunction = __webpack_require__(6113); +var Vector2 = __webpack_require__(26099); + +/** + * Returns an array of `quantity` Points where each point is taken from the given Line, + * spaced out according to the ease function specified. + * + * ```javascript + * const line = new Phaser.Geom.Line(100, 300, 700, 300); + * const points = Phaser.Geom.Line.GetEasedPoints(line, 'sine.out', 32) + * ``` + * + * In the above example, the `points` array will contain 32 points spread-out across + * the length of `line`, where the position of each point is determined by the `Sine.out` + * ease function. + * + * You can optionally provide a collinear threshold. In this case, the resulting points + * are checked against each other, and if they are `< collinearThreshold` distance apart, + * they are dropped from the results. This can help avoid lots of clustered points at + * far ends of the line with tightly-packed eases such as Quartic. Leave the value set + * to zero to skip this check. + * + * Note that if you provide a collinear threshold, the resulting array may not always + * contain `quantity` points. + * + * @function Phaser.Geom.Line.GetEasedPoints + * @since 3.23.0 + * + * @generic {Phaser.Math.Vector2[]} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The Line object. + * @param {(string|function)} ease - The ease to use. This can be either a string from the EaseMap, or a custom function. + * @param {number} quantity - The number of points to return. Note that if you provide a `collinearThreshold`, the resulting array may not always contain this number of points. + * @param {number} [collinearThreshold=0] - An optional threshold. The final array is reduced so that each point is spaced out at least this distance apart. This helps reduce clustering in noisy eases. + * @param {number[]} [easeParams] - An optional array of ease parameters to go with the ease. + * + * @return {Phaser.Math.Vector2[]} An array of Math.Vector2s containing the coordinates of the points on the line. + */ +var GetEasedPoints = function (line, ease, quantity, collinearThreshold, easeParams) +{ + if (collinearThreshold === undefined) { collinearThreshold = 0; } + if (easeParams === undefined) { easeParams = []; } + + var results = []; + + var x1 = line.x1; + var y1 = line.y1; + + var spaceX = line.x2 - x1; + var spaceY = line.y2 - y1; + + var easeFunc = GetEaseFunction(ease, easeParams); + + var i; + var v; + var q = quantity - 1; + + for (i = 0; i < q; i++) + { + v = easeFunc(i / q); + + results.push(new Vector2(x1 + (spaceX * v), y1 + (spaceY * v))); + } + + // Always include the end of the line + v = easeFunc(1); + + results.push(new Vector2(x1 + (spaceX * v), y1 + (spaceY * v))); + + // Remove collinear parts + if (collinearThreshold > 0) + { + var prevPoint = results[0]; + + // Store the new results here + var sortedResults = [ prevPoint ]; + + for (i = 1; i < results.length - 1; i++) + { + var point = results[i]; + + if (DistanceBetweenPoints(prevPoint, point) >= collinearThreshold) + { + sortedResults.push(point); + prevPoint = point; + } + } + + // Top and tail + var endPoint = results[results.length - 1]; + + if (DistanceBetweenPoints(prevPoint, endPoint) < collinearThreshold) + { + sortedResults.pop(); + } + + sortedResults.push(endPoint); + + return sortedResults; + } + else + { + return results; + } +}; + +module.exports = GetEasedPoints; + + +/***/ }, + +/***/ 32125 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Get the midpoint of the given line. + * + * @function Phaser.Geom.Line.GetMidPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to get the midpoint of. + * @param {Phaser.Math.Vector2} [out] - An optional Vector2 object to store the midpoint in. + * + * @return {Phaser.Math.Vector2} The midpoint of the Line. + */ +var GetMidPoint = function (line, out) +{ + if (out === undefined) { out = new Vector2(); } + + out.x = (line.x1 + line.x2) / 2; + out.y = (line.y1 + line.y2) / 2; + + return out; +}; + +module.exports = GetMidPoint; + + +/***/ }, + +/***/ 99569 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Florian Mertens + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Gets the nearest point on the infinite line defined by the given Line segment to the specified point. + * Note that the returned point is projected onto the full line, not clamped to the segment endpoints. + * + * @function Phaser.Geom.Line.GetNearestPoint + * @since 3.16.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to get the nearest point on. + * @param {Phaser.Math.Vector2} vec - The Vector2 to get the nearest point to. + * @param {Phaser.Math.Vector2} [out] - An optional Vector2 object, to store the coordinates of the nearest point on the line. + * + * @return {Phaser.Math.Vector2} The nearest point on the line. + */ +var GetNearestPoint = function (line, vec, out) +{ + if (out === undefined) { out = new Vector2(); } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var L2 = (((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); + + if (L2 === 0) + { + return out; + } + + var r = (((vec.x - x1) * (x2 - x1)) + ((vec.y - y1) * (y2 - y1))) / L2; + + out.x = x1 + (r * (x2 - x1)); + out.y = y1 + (r * (y2 - y1)); + + return out; +}; + +module.exports = GetNearestPoint; + + +/***/ }, + +/***/ 34638 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MATH_CONST = __webpack_require__(36383); +var Angle = __webpack_require__(91938); +var Vector2 = __webpack_require__(26099); + +/** + * Calculate the normal of the given line. + * + * The normal of a line is a vector that points perpendicular from it. + * + * @function Phaser.Geom.Line.GetNormal + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to calculate the normal of. + * @param {Phaser.Math.Vector2} [out] - An optional Vector2 object to store the normal in. + * + * @return {Phaser.Math.Vector2} The normal of the Line. + */ +var GetNormal = function (line, out) +{ + if (out === undefined) { out = new Vector2(); } + + var a = Angle(line) - MATH_CONST.PI_OVER_2; + + out.x = Math.cos(a); + out.y = Math.sin(a); + + return out; +}; + +module.exports = GetNormal; + + +/***/ }, + +/***/ 13151 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Get a point on a line that's a given percentage along its length. + * + * @function Phaser.Geom.Line.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {Phaser.Math.Vector2} [out] - An optional Vector2 object to store the coordinates of the point on the line. + * + * @return {Phaser.Math.Vector2} The point on the line. + */ +var GetPoint = function (line, position, out) +{ + if (out === undefined) { out = new Vector2(); } + + out.x = line.x1 + (line.x2 - line.x1) * position; + out.y = line.y1 + (line.y2 - line.y1) * position; + + return out; +}; + +module.exports = GetPoint; + + +/***/ }, + +/***/ 15258 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Length = __webpack_require__(35001); +var Vector2 = __webpack_require__(26099); + +/** + * Get a number of evenly-spaced points along a line, starting from the first endpoint (x1, y1). + * The last endpoint (x2, y2) is not included in the returned points. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * See also `GetEasedPoints` for a way to distribute the points across the line according to an ease type or input function. + * + * @function Phaser.Geom.Line.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {number} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {number} [stepRate] - The distance between each point on the line. When set, `quantity` is calculated as the line length divided by this value; `quantity` should be set to `0`. + * @param {Phaser.Math.Vector2[]} [out] - An optional array of Vector2 objects to store the coordinates of the points on the line. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects containing the coordinates of the points on the line. + */ +var GetPoints = function (line, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity && stepRate > 0) + { + quantity = Length(line) / stepRate; + } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + var x = x1 + (x2 - x1) * position; + var y = y1 + (y2 - y1) * position; + + out.push(new Vector2(x, y)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }, + +/***/ 26408 +(module) { + +/** + * @author Richard Davey + * @author Florian Mertens + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates the shortest (perpendicular) distance from an infinite line, defined by the two + * endpoints of the given Line object, to the given Point. If the line has zero length (both + * endpoints are identical), this function returns `false`. + * + * @function Phaser.Geom.Line.GetShortestDistance + * @since 3.16.0 + * + * @param {Phaser.Geom.Line} line - The line to get the distance from. + * @param {Phaser.Types.Math.Vector2Like} point - The point to get the shortest distance to. + * + * @return {(boolean|number)} The shortest perpendicular distance from the line to the point, or `false` if the line has zero length. + */ +var GetShortestDistance = function (line, point) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var L2 = (((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); + + if (L2 === 0) + { + return false; + } + + var s = (((y1 - point.y) * (x2 - x1)) - ((x1 - point.x) * (y2 - y1))) / L2; + + return Math.abs(s) * Math.sqrt(L2); +}; + +module.exports = GetShortestDistance; + + +/***/ }, + +/***/ 98770 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculate the height of the given line. + * + * @function Phaser.Geom.Line.Height + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the height of. + * + * @return {number} The height of the line. + */ +var Height = function (line) +{ + return Math.abs(line.y1 - line.y2); +}; + +module.exports = Height; + + +/***/ }, + +/***/ 35001 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculate the length of the given line. + * + * @function Phaser.Geom.Line.Length + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the length of. + * + * @return {number} The length of the line. + */ +var Length = function (line) +{ + return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); +}; + +module.exports = Length; + + +/***/ }, + +/***/ 23031 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var GetPoint = __webpack_require__(13151); +var GetPoints = __webpack_require__(15258); +var GEOM_CONST = __webpack_require__(23777); +var Random = __webpack_require__(65822); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * Defines a Line segment: a finite portion of a line described by a start point (`x1`, `y1`) + * and an end point (`x2`, `y2`). Unlike an infinite mathematical line, a Line segment has a + * fixed length and direction. + * + * Line segments are used throughout Phaser for collision detection, geometry calculations, + * path and boundary definitions, and placement utilities. You can retrieve a point at any + * percentage along the line via `getPoint`, get an array of evenly-spaced points via + * `getPoints`, or query the bounding extents through the `left`, `right`, `top`, and `bottom` + * accessors. + * + * @class Line + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the line's starting point. + * @param {number} [y1=0] - The y coordinate of the line's starting point. + * @param {number} [x2=0] - The x coordinate of the line's ending point. + * @param {number} [y2=0] - The y coordinate of the line's ending point. + */ +var Line = new Class({ + + initialize: + + function Line (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + /** + * The geometry constant type of this object: `GEOM_CONST.LINE`. + * Used for fast type comparisons. + * + * @name Phaser.Geom.Line#type + * @type {number} + * @readonly + * @since 3.19.0 + */ + this.type = GEOM_CONST.LINE; + + /** + * The x coordinate of the line's starting point. + * + * @name Phaser.Geom.Line#x1 + * @type {number} + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * The y coordinate of the line's starting point. + * + * @name Phaser.Geom.Line#y1 + * @type {number} + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * The x coordinate of the line's ending point. + * + * @name Phaser.Geom.Line#x2 + * @type {number} + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * The y coordinate of the line's ending point. + * + * @name Phaser.Geom.Line#y2 + * @type {number} + * @since 3.0.0 + */ + this.y2 = y2; + }, + + /** + * Get a point on a line that's a given percentage along its length. + * + * @method Phaser.Geom.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {Phaser.Math.Vector2} [output] - An optional Vector2 object to store the coordinates of the point on the line. + * + * @return {Phaser.Math.Vector2} A Vector2 object containing the coordinates of the point on the line. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @method Phaser.Geom.Line#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [output,$return] + * + * @param {number} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {number} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {Phaser.Math.Vector2[]} [output] - An optional array of Vector2 objects to store the coordinates of the points on the line. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects containing the coordinates of the points on the line. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a randomly chosen point on this Line, selected with uniform distribution along its length. + * If a Vector2 is provided it will be populated with the result and returned; otherwise a new Vector2 is created. + * + * @method Phaser.Geom.Line#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [point,$return] + * + * @param {Phaser.Math.Vector2} [point] - An instance of a Vector2 to be modified. + * + * @return {Phaser.Math.Vector2} A random point on the Line. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Set new coordinates for the line endpoints. + * + * @method Phaser.Geom.Line#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the line's starting point. + * @param {number} [y1=0] - The y coordinate of the line's starting point. + * @param {number} [x2=0] - The x coordinate of the line's ending point. + * @param {number} [y2=0] - The y coordinate of the line's ending point. + * + * @return {this} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + return this; + }, + + /** + * Sets this Line to match the x/y coordinates of the two given Vector2Like objects. + * + * @method Phaser.Geom.Line#setFromObjects + * @since 3.70.0 + * + * @param {Phaser.Types.Math.Vector2Like} start - Any object with public `x` and `y` properties, whose values will be assigned to the x1/y1 components of this Line. + * @param {Phaser.Types.Math.Vector2Like} end - Any object with public `x` and `y` properties, whose values will be assigned to the x2/y2 components of this Line. + * + * @return {this} This Line object. + */ + setFromObjects: function (start, end) + { + this.x1 = start.x; + this.y1 = start.y; + + this.x2 = end.x; + this.y2 = end.y; + + return this; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointA + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointA: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x1, this.y1); + + return vec2; + }, + + /** + * Returns a Vector2 object that corresponds to the end of this Line. + * + * @method Phaser.Geom.Line#getPointB + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the end of this Line. + */ + getPointB: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x2, this.y2); + + return vec2; + }, + + /** + * The left-most x coordinate of this Line, i.e. the lesser of `x1` and `x2`. + * When set, the endpoint that currently holds the smaller x value is moved to the new position. + * + * @name Phaser.Geom.Line#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 <= this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The right-most x coordinate of this Line, i.e. the greater of `x1` and `x2`. + * When set, the endpoint that currently holds the larger x value is moved to the new position. + * + * @name Phaser.Geom.Line#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 > this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The top-most y coordinate of this Line, i.e. the lesser of `y1` and `y2`. + * When set, the endpoint that currently holds the smaller y value is moved to the new position. + * + * @name Phaser.Geom.Line#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 <= this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + }, + + /** + * The bottom-most y coordinate of this Line, i.e. the greater of `y1` and `y2`. + * When set, the endpoint that currently holds the larger y value is moved to the new position. + * + * @name Phaser.Geom.Line#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 > this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + } + +}); + +module.exports = Line; + + +/***/ }, + +/***/ 64795 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MATH_CONST = __webpack_require__(36383); +var Wrap = __webpack_require__(15994); +var Angle = __webpack_require__(91938); + +/** + * Get the angle of the normal of the given line in radians. + * + * @function Phaser.Geom.Line.NormalAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the angle of the normal of. + * + * @return {number} The angle of the normal of the line in radians. + */ +var NormalAngle = function (line) +{ + var angle = Angle(line) - MATH_CONST.PI_OVER_2; + + return Wrap(angle, -Math.PI, Math.PI); +}; + +module.exports = NormalAngle; + + +/***/ }, + +/***/ 52616 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MATH_CONST = __webpack_require__(36383); +var Angle = __webpack_require__(91938); + +/** + * Returns the x component of the normal vector of the given line. + * + * @function Phaser.Geom.Line.NormalX + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The Line object to get the normal value from. + * + * @return {number} The x component of the normal vector of the line. + */ +var NormalX = function (line) +{ + return Math.cos(Angle(line) - MATH_CONST.PI_OVER_2); +}; + +module.exports = NormalX; + + +/***/ }, + +/***/ 87231 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MATH_CONST = __webpack_require__(36383); +var Angle = __webpack_require__(91938); + +/** + * The Y value of the normal of the given line. + * The normal of a line is a vector that points perpendicular from it. + * + * @function Phaser.Geom.Line.NormalY + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the normal of. + * + * @return {number} The Y value of the normal of the Line. + */ +var NormalY = function (line) +{ + return Math.sin(Angle(line) - MATH_CONST.PI_OVER_2); +}; + +module.exports = NormalY; + + +/***/ }, + +/***/ 89662 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Translates both endpoints of the given Line by the specified horizontal and vertical amounts, effectively moving the line to a new position in 2D space while preserving its length and angle. + * + * @function Phaser.Geom.Line.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to offset. + * @param {number} x - The horizontal offset to add to the line. + * @param {number} y - The vertical offset to add to the line. + * + * @return {Phaser.Geom.Line} The modified Line object, with both endpoints moved by the given offset. + */ +var Offset = function (line, x, y) +{ + line.x1 += x; + line.y1 += y; + + line.x2 += x; + line.y2 += y; + + return line; +}; + +module.exports = Offset; + + +/***/ }, + +/***/ 71165 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculate the perpendicular slope of the given line. + * + * @function Phaser.Geom.Line.PerpSlope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the perpendicular slope of. + * + * @return {number} The perpendicular slope of the line. + */ +var PerpSlope = function (line) +{ + return -((line.x2 - line.x1) / (line.y2 - line.y1)); +}; + +module.exports = PerpSlope; + + +/***/ }, + +/***/ 65822 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns a random point on a given Line. + * + * @function Phaser.Geom.Line.Random + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The Line to calculate the random point on. + * @param {Phaser.Math.Vector2} [out] - An instance of a Vector2 to be modified. + * + * @return {Phaser.Math.Vector2} A random point on the Line stored in a Vector2. + */ +var Random = function (line, out) +{ + if (out === undefined) { out = new Vector2(); } + + var t = Math.random(); + + out.x = line.x1 + t * (line.x2 - line.x1); + out.y = line.y1 + t * (line.y2 - line.y1); + + return out; +}; + +module.exports = Random; + + +/***/ }, + +/***/ 69777 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Angle = __webpack_require__(91938); +var NormalAngle = __webpack_require__(64795); + +/** + * Calculates the reflected angle of Line A off the surface represented by Line B. This is the outgoing angle based on the angle of incidence (Line A) and the surface normal of Line B. The result is in radians. + * + * @function Phaser.Geom.Line.ReflectAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} lineA - The incident line whose angle of incidence is used. + * @param {Phaser.Geom.Line} lineB - The surface line, used to calculate the normal angle of reflection. + * + * @return {number} The reflected angle of Line A off the surface of Line B, in radians. + */ +var ReflectAngle = function (lineA, lineB) +{ + return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); +}; + +module.exports = ReflectAngle; + + +/***/ }, + +/***/ 39706 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RotateAroundXY = __webpack_require__(64400); + +/** + * Rotate a line around its midpoint by the given angle in radians. + * + * @function Phaser.Geom.Line.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var Rotate = function (line, angle) +{ + var x = (line.x1 + line.x2) / 2; + var y = (line.y1 + line.y2) / 2; + + return RotateAroundXY(line, x, y, angle); +}; + +module.exports = Rotate; + + +/***/ }, + +/***/ 82585 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RotateAroundXY = __webpack_require__(64400); + +/** + * Rotate a line around a point by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {Phaser.Math.Vector2} point - The point to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundPoint = function (line, point, angle) +{ + return RotateAroundXY(line, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }, + +/***/ 64400 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Rotate a line around the given coordinates by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} x - The horizontal coordinate to rotate the line around. + * @param {number} y - The vertical coordinate to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundXY = function (line, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = line.x1 - x; + var ty = line.y1 - y; + + line.x1 = tx * c - ty * s + x; + line.y1 = tx * s + ty * c + y; + + tx = line.x2 - x; + ty = line.y2 - y; + + line.x2 = tx * c - ty * s + x; + line.y2 = tx * s + ty * c + y; + + return line; +}; + +module.exports = RotateAroundXY; + + +/***/ }, + +/***/ 62377 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Set a line to a given position, angle and length. + * + * @function Phaser.Geom.Line.SetToAngle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to set. + * @param {number} x - The horizontal start position of the line. + * @param {number} y - The vertical start position of the line. + * @param {number} angle - The angle of the line in radians. + * @param {number} length - The length of the line. + * + * @return {Phaser.Geom.Line} The updated line. + */ +var SetToAngle = function (line, x, y, angle, length) +{ + line.x1 = x; + line.y1 = y; + + line.x2 = x + (Math.cos(angle) * length); + line.y2 = y + (Math.sin(angle) * length); + + return line; +}; + +module.exports = SetToAngle; + + +/***/ }, + +/***/ 71366 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculate the slope of the given line. + * + * @function Phaser.Geom.Line.Slope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the slope of. + * + * @return {number} The slope of the line. + */ +var Slope = function (line) +{ + return (line.y2 - line.y1) / (line.x2 - line.x1); +}; + +module.exports = Slope; + + +/***/ }, + +/***/ 10809 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates the width of the given line, defined as the absolute difference between + * the x-coordinates of its two endpoints (`x1` and `x2`). This represents the + * horizontal extent of the line, not its geometric length. To get the true length + * of the line, use `Phaser.Geom.Line.Length` instead. + * + * @function Phaser.Geom.Line.Width + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the width of. + * + * @return {number} The width of the line, i.e. the absolute difference between its x1 and x2 coordinates. + */ +var Width = function (line) +{ + return Math.abs(line.x1 - line.x2); +}; + +module.exports = Width; + + +/***/ }, + +/***/ 2529 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Line = __webpack_require__(23031); + +Line.Angle = __webpack_require__(91938); +Line.BresenhamPoints = __webpack_require__(84993); +Line.CenterOn = __webpack_require__(36469); +Line.Clone = __webpack_require__(31116); +Line.CopyFrom = __webpack_require__(59944); +Line.Equals = __webpack_require__(59220); +Line.Extend = __webpack_require__(78177); +Line.GetEasedPoints = __webpack_require__(26708); +Line.GetMidPoint = __webpack_require__(32125); +Line.GetNearestPoint = __webpack_require__(99569); +Line.GetNormal = __webpack_require__(34638); +Line.GetPoint = __webpack_require__(13151); +Line.GetPoints = __webpack_require__(15258); +Line.GetShortestDistance = __webpack_require__(26408); +Line.Height = __webpack_require__(98770); +Line.Length = __webpack_require__(35001); +Line.NormalAngle = __webpack_require__(64795); +Line.NormalX = __webpack_require__(52616); +Line.NormalY = __webpack_require__(87231); +Line.Offset = __webpack_require__(89662); +Line.PerpSlope = __webpack_require__(71165); +Line.Random = __webpack_require__(65822); +Line.ReflectAngle = __webpack_require__(69777); +Line.Rotate = __webpack_require__(39706); +Line.RotateAroundPoint = __webpack_require__(82585); +Line.RotateAroundXY = __webpack_require__(64400); +Line.SetToAngle = __webpack_require__(62377); +Line.Slope = __webpack_require__(71366); +Line.Width = __webpack_require__(10809); + +module.exports = Line; + + +/***/ }, + +/***/ 12306 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Polygon = __webpack_require__(25717); + +/** + * Create a new polygon which is a copy of the specified polygon + * + * @function Phaser.Geom.Polygon.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - The polygon to create a clone of + * + * @return {Phaser.Geom.Polygon} A new separate Polygon cloned from the specified polygon, based on the same points. + */ +var Clone = function (polygon) +{ + return new Polygon(polygon.points); +}; + +module.exports = Clone; + + +/***/ }, + +/***/ 63814 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Checks whether the x and y coordinates are contained within this polygon. +// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva + +/** + * Checks if a point is within the bounds of a Polygon. + * + * @function Phaser.Geom.Polygon.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to check against. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the bounds of the Polygon, otherwise `false`. + */ +var Contains = function (polygon, x, y) +{ + var inside = false; + + for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) + { + var ix = polygon.points[i].x; + var iy = polygon.points[i].y; + + var jx = polygon.points[j].x; + var jy = polygon.points[j].y; + + if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) + { + inside = !inside; + } + } + + return inside; +}; + +module.exports = Contains; + + +/***/ }, + +/***/ 99338 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(63814); + +/** + * Checks the given Point against the Polygon to see if the Point lays within its vertices. + * + * @function Phaser.Geom.Polygon.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to check. + * @param {Phaser.Math.Vector2} vec - The Vector2 point to check if it's within the Polygon. + * + * @return {boolean} `true` if the point is within the Polygon, otherwise `false`. + */ +var ContainsPoint = function (polygon, vec) +{ + return Contains(polygon, vec.x, vec.y); +}; + +module.exports = ContainsPoint; + + +/***/ }, + +/***/ 94811 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * This module implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to + * handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn't guarantee correctness + * of triangulation, but attempts to always produce acceptable results for practical data. + * + * Example: + * + * ```javascript + * const triangles = Phaser.Geom.Polygon.Earcut([10,0, 0,50, 60,60, 70,10]); // returns [1,0,3, 3,2,1] + * ``` + * + * Each group of three vertex indices in the resulting array forms a triangle. + * + * ```javascript + * // triangulating a polygon with a hole + * earcut([0,0, 100,0, 100,100, 0,100, 20,20, 80,20, 80,80, 20,80], [4]); + * // [3,0,4, 5,4,0, 3,4,7, 5,0,1, 2,3,7, 6,5,1, 2,7,6, 6,1,2] + * + * // triangulating a polygon with 3d coords + * earcut([10,0,1, 0,50,2, 60,60,3, 70,10,4], null, 3); + * // [1,0,3, 3,2,1] + * ``` + * + * If you pass a single vertex as a hole, Earcut treats it as a Steiner point. + * + * If your input is a multi-dimensional array (e.g. GeoJSON Polygon), you can convert it to the format + * expected by Earcut with `Phaser.Geom.Polygon.Earcut.flatten`: + * + * ```javascript + * var data = earcut.flatten(geojson.geometry.coordinates); + * var triangles = earcut(data.vertices, data.holes, data.dimensions); + * ``` + * + * After getting a triangulation, you can verify its correctness with `Phaser.Geom.Polygon.Earcut.deviation`: + * + * ```javascript + * var deviation = earcut.deviation(vertices, holes, dimensions, triangles); + * ``` + * Returns the relative difference between the total area of triangles and the area of the input polygon. + * 0 means the triangulation is fully correct. + * + * For more information see https://github.com/mapbox/earcut + * + * @function Phaser.Geom.Polygon.Earcut + * @since 3.50.0 + * + * @param {number[]} data - A flat array of vertex coordinates, like [x0,y0, x1,y1, x2,y2, ...] + * @param {number[]} [holeIndices] - An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). + * @param {number} [dimensions=2] - The number of coordinates per vertex in the input array (2 by default). + * + * @return {number[]} An array of triangulated data. + */ + + // Earcut 2.2.4 (July 5th 2022) + +/* + * ISC License + * + * Copyright (c) 2016, Mapbox + * + * Permission to use, copy, modify, and/or distribute this software for any purpose + * with or without fee is hereby granted, provided that the above copyright notice + * and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + * THIS SOFTWARE. + */ + + + +function earcut(data, holeIndices, dim) { + + dim = dim || 2; + + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; + + if (!outerNode || outerNode.next === outerNode.prev) return triangles; + + var minX, minY, maxX, maxY, x, y, invSize; + + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + } + + // minX, minY and invSize are later used to transform coords into integers for z-order calculation + invSize = Math.max(maxX - minX, maxY - minY); + invSize = invSize !== 0 ? 32767 / invSize : 0; + } + + earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0); + + return triangles; +} + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) break; + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && invSize) indexCurve(ear, minX, minY, invSize); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim | 0); + triangles.push(ear.i / dim | 0); + triangles.push(next.i / dim | 0); + + removeNode(ear); + + // skipping the next vertex leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(filterPoints(ear), triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, invSize, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, invSize); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y; + + // triangle bbox; min & max are calculated like this for speed + var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx), + y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy), + x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx), + y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy); + + var p = c.next; + while (p !== a) { + if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && + pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, invSize) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y; + + // triangle bbox; min & max are calculated like this for speed + var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx), + y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy), + x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx), + y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy); + + // z-order range for the current triangle bbox; + var minZ = zOrder(x0, y0, minX, minY, invSize), + maxZ = zOrder(x1, y1, minX, minY, invSize); + + var p = ear.prevZ, + n = ear.nextZ; + + // look for points inside the triangle in both directions + while (p && p.z >= minZ && n && n.z <= maxZ) { + if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + + if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; + } + + // look for remaining points in decreasing z-order + while (p && p.z >= minZ) { + if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + // look for remaining points in increasing z-order + while (n && n.z <= maxZ) { + if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && + pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim | 0); + triangles.push(p.i / dim | 0); + triangles.push(b.i / dim | 0); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return filterPoints(p); +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, invSize) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, invSize, 0); + earcutLinked(c, triangles, dim, minX, minY, invSize, 0); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + outerNode = eliminateHole(queue[i], outerNode); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + var bridge = findHoleBridge(hole, outerNode); + if (!bridge) { + return outerNode; + } + + var bridgeReverse = splitPolygon(bridge, hole); + + // filter collinear points around the cuts + filterPoints(bridgeReverse, bridgeReverse.next); + return filterPoints(bridge, bridge.next); +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + m = p.x < p.next.x ? p : p.next; + if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m; + + do { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if (locallyInside(p, hole) && + (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } while (p !== stop); + + return m; +} + +// whether sector in vertex m contains sector in vertex p in the same coordinates +function sectorContainsSector(m, p) { + return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, invSize) { + var p = start; + do { + if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and inverse of the longer side of data bbox +function zOrder(x, y, minX, minY, invSize) { + // coords are transformed into non-negative 15-bit integer range + x = (x - minX) * invSize | 0; + y = (y - minY) * invSize | 0; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && + (ax - px) * (by - py) >= (bx - px) * (ay - py) && + (bx - px) * (cy - py) >= (cx - px) * (by - py); +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // doesn't intersect other edges + (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible + (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors + equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + var o1 = sign(area(p1, q1, p2)); + var o2 = sign(area(p1, q1, q2)); + var o3 = sign(area(p2, q2, p1)); + var o4 = sign(area(p2, q2, q1)); + + if (o1 !== o2 && o3 !== o4) return true; // general case + + if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1 + if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1 + if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2 + if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; +} + +// for collinear points p, q, r, check if point q lies on segment pr +function onSegment(p, q, r) { + return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y); +} + +function sign(num) { + return num > 0 ? 1 : num < 0 ? -1 : 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertex index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertex nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = 0; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +// return a percentage difference between the polygon area and its triangulation area; +// used to verify correctness of triangulation +earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); +}; + +function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; +} + +// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts +earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; +}; + +module.exports = earcut; + + +/***/ }, + +/***/ 13829 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +/** + * Calculates the bounding AABB rectangle of a polygon. + * + * @function Phaser.Geom.Polygon.GetAABB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The polygon that should be calculated. + * @param {(Phaser.Geom.Rectangle|object)} [out] - The rectangle or object that has x, y, width, and height properties to store the result. Optional. + * + * @return {(Phaser.Geom.Rectangle|object)} The resulting rectangle or object that is passed in with position and dimensions of the polygon's AABB. + */ +var GetAABB = function (polygon, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var minX = Infinity; + var minY = Infinity; + var maxX = -minX; + var maxY = -minY; + var p; + + for (var i = 0; i < polygon.points.length; i++) + { + p = polygon.points[i]; + + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = GetAABB; + + +/***/ }, + +/***/ 26173 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] + +/** + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. + * + * @function Phaser.Geom.Polygon.GetNumberArray + * @since 3.0.0 + * + * @generic {number[]} O - [output,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon whose points to export. + * @param {(array|number[])} [output] - An array to which the points' coordinates should be appended. + * + * @return {(array|number[])} The modified `output` array, or a new array if none was given. + */ +var GetNumberArray = function (polygon, output) +{ + if (output === undefined) { output = []; } + + for (var i = 0; i < polygon.points.length; i++) + { + output.push(polygon.points[i].x); + output.push(polygon.points[i].y); + } + + return output; +}; + +module.exports = GetNumberArray; + + +/***/ }, + +/***/ 9564 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Length = __webpack_require__(35001); +var Line = __webpack_require__(23031); +var Perimeter = __webpack_require__(30052); + +/** + * Returns an array of Vector2 objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Polygon.GetPoints + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the points from. + * @param {number} quantity - The amount of points to return. If a falsy value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects pertaining to the points around the perimeter of the Polygon. + */ +var GetPoints = function (polygon, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var points = polygon.points; + var perimeter = Perimeter(polygon); + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity && stepRate > 0) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = perimeter * (i / quantity); + var accumulatedPerimeter = 0; + + for (var j = 0; j < points.length; j++) + { + var pointA = points[j]; + var pointB = points[(j + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + var length = Length(line); + + if (position < accumulatedPerimeter || position > accumulatedPerimeter + length) + { + accumulatedPerimeter += length; + continue; + } + + var point = line.getPoint((position - accumulatedPerimeter) / length); + out.push(point); + + break; + } + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }, + +/***/ 30052 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Length = __webpack_require__(35001); +var Line = __webpack_require__(23031); + +/** + * Returns the perimeter of the given Polygon by summing the lengths of all its edges. + * The polygon is treated as closed, so the edge between the last point and the first + * point is included in the total. + * + * @function Phaser.Geom.Polygon.Perimeter + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the perimeter of. + * + * @return {number} The perimeter of the Polygon. + */ +var Perimeter = function (polygon) +{ + var points = polygon.points; + var perimeter = 0; + + for (var i = 0; i < points.length; i++) + { + var pointA = points[i]; + var pointB = points[(i + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + + perimeter += Length(line); + } + + return perimeter; +}; + +module.exports = Perimeter; + + +/***/ }, + +/***/ 25717 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(63814); +var GetPoints = __webpack_require__(9564); +var GEOM_CONST = __webpack_require__(23777); + +/** + * @classdesc + * A Polygon object + * + * The polygon is a closed shape consisting of a series of connected straight lines defined by a list of ordered points. + * Several formats are supported to define the list of points, check the setTo method for details. + * This is a geometry object allowing you to define and inspect the shape. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Polygon you should look at the capabilities of the Graphics class. + * + * @class Polygon + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {(string|number[]|Phaser.Types.Math.Vector2Like[])} [points] - List of points defining the perimeter of this Polygon. Several formats are supported: + * - A string containing paired x y values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + */ +var Polygon = new Class({ + + initialize: + + function Polygon (points) + { + /** + * The geometry constant type of this object: `GEOM_CONST.POLYGON`. + * Used for fast type comparisons. + * + * @name Phaser.Geom.Polygon#type + * @type {number} + * @readonly + * @since 3.19.0 + */ + this.type = GEOM_CONST.POLYGON; + + /** + * The area of this Polygon. + * + * @name Phaser.Geom.Polygon#area + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.area = 0; + + /** + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + * + * @name Phaser.Geom.Polygon#points + * @type {Phaser.Math.Vector2[]} + * @since 3.0.0 + */ + this.points = []; + + if (points) + { + this.setTo(points); + } + }, + + /** + * Check to see if the Polygon contains the given x / y coordinates. + * + * @method Phaser.Geom.Polygon#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the polygon. + * @param {number} y - The y coordinate to check within the polygon. + * + * @return {boolean} `true` if the coordinates are within the polygon, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @method Phaser.Geom.Polygon#setTo + * @since 3.0.0 + * + * @param {(string|number[]|Phaser.Types.Math.Vector2Like[])} [points] - Points defining the perimeter of this polygon. Please check function description above for the different supported formats. + * + * @return {this} This Polygon object. + */ + setTo: function (points) + { + this.area = 0; + this.points = []; + + if (typeof points === 'string') + { + points = points.split(' '); + } + + if (!Array.isArray(points)) + { + return this; + } + + var p; + + // The points argument is an array, so iterate through it + for (var i = 0; i < points.length; i++) + { + p = { x: 0, y: 0 }; + + if (typeof points[i] === 'number' || typeof points[i] === 'string') + { + p.x = parseFloat(points[i]); + p.y = parseFloat(points[i + 1]); + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + } + + this.calculateArea(); + + return this; + }, + + /** + * Calculates the area of the Polygon using the Shoelace formula. The result is stored in the `area` property. + * + * @method Phaser.Geom.Polygon#calculateArea + * @since 3.0.0 + * + * @return {number} The area of the polygon. + */ + calculateArea: function () + { + if (this.points.length < 3) + { + this.area = 0; + + return this.area; + } + + var sum = 0; + var p1; + var p2; + + for (var i = 0; i < this.points.length - 1; i++) + { + p1 = this.points[i]; + p2 = this.points[i + 1]; + + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + + p1 = this.points[0]; + p2 = this.points[this.points.length - 1]; + + sum += (p1.x - p2.x) * (p2.y + p1.y); + + this.area = -sum * 0.5; + + return this.area; + }, + + /** + * Returns an array of Vector2 objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Polygon#getPoints + * @since 3.12.0 + * + * @generic {Phaser.Math.Vector2[]} O - [output,$return] + * + * @param {number} quantity - The amount of points to return. If a falsy value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {Phaser.Math.Vector2[]} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects pertaining to the points around the perimeter of the Polygon. + */ + getPoints: function (quantity, step, output) + { + return GetPoints(this, quantity, step, output); + } + +}); + +module.exports = Polygon; + + +/***/ }, + +/***/ 8133 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Reverses the order of the points of a Polygon. + * + * @function Phaser.Geom.Polygon.Reverse + * @since 3.0.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to modify. + * + * @return {Phaser.Geom.Polygon} The modified Polygon. + */ +var Reverse = function (polygon) +{ + polygon.points.reverse(); + + return polygon; +}; + +module.exports = Reverse; + + +/***/ }, + +/***/ 29524 +(module) { + +/** + * @author Richard Davey + * @author Vladimir Agafonkin + * @see Based on Simplify.js mourner.github.io/simplify-js + */ + +/** + * Copyright (c) 2017, Vladimir Agafonkin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @ignore + */ +function getSqDist (p1, p2) +{ + var dx = p1.x - p2.x, + dy = p1.y - p2.y; + + return dx * dx + dy * dy; +} + +/** + * Square distance from a point to a segment + * + * @ignore + */ +function getSqSegDist (p, p1, p2) +{ + var x = p1.x, + y = p1.y, + dx = p2.x - x, + dy = p2.y - y; + + if (dx !== 0 || dy !== 0) + { + var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy); + + if (t > 1) + { + x = p2.x; + y = p2.y; + } + else if (t > 0) + { + x += dx * t; + y += dy * t; + } + } + + dx = p.x - x; + dy = p.y - y; + + return dx * dx + dy * dy; +} + +/** + * Basic distance-based simplification + * + * @ignore + */ +function simplifyRadialDist (points, sqTolerance) +{ + var prevPoint = points[0], + newPoints = [ prevPoint ], + point; + + for (var i = 1, len = points.length; i < len; i++) + { + point = points[i]; + + if (getSqDist(point, prevPoint) > sqTolerance) + { + newPoints.push(point); + prevPoint = point; + } + } + + if (prevPoint !== point) + { + newPoints.push(point); + } + + return newPoints; +} + +/** + * @ignore + */ +function simplifyDPStep (points, first, last, sqTolerance, simplified) +{ + var maxSqDist = sqTolerance, + index; + + for (var i = first + 1; i < last; i++) + { + var sqDist = getSqSegDist(points[i], points[first], points[last]); + + if (sqDist > maxSqDist) + { + index = i; + maxSqDist = sqDist; + } + } + + if (maxSqDist > sqTolerance) + { + if (index - first > 1) + { + simplifyDPStep(points, first, index, sqTolerance, simplified); + } + + simplified.push(points[index]); + + if (last - index > 1) + { + simplifyDPStep(points, index, last, sqTolerance, simplified); + } + } +} + +/** + * Simplification using Ramer-Douglas-Peucker algorithm + * + * @ignore + */ +function simplifyDouglasPeucker (points, sqTolerance) +{ + var last = points.length - 1; + + var simplified = [ points[0] ]; + + simplifyDPStep(points, 0, last, sqTolerance, simplified); + + simplified.push(points[last]); + + return simplified; +} + +/** + * Takes a Polygon object and simplifies the points by running them through a combination of + * Douglas-Peucker and Radial Distance algorithms. Simplification dramatically reduces the number of + * points in a polygon while retaining its shape, giving a huge performance boost when processing + * it and also reducing visual noise. + * + * @function Phaser.Geom.Polygon.Simplify + * @since 3.50.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The polygon to be simplified. The polygon will be modified in-place and returned. + * @param {number} [tolerance=1] - Affects the amount of simplification (in the same metric as the point coordinates). + * @param {boolean} [highestQuality=false] - Excludes distance-based preprocessing step which leads to highest quality simplification but runs ~10-20 times slower. + * + * @return {Phaser.Geom.Polygon} The input polygon. + */ +var Simplify = function (polygon, tolerance, highestQuality) +{ + if (tolerance === undefined) { tolerance = 1; } + if (highestQuality === undefined) { highestQuality = false; } + + var points = polygon.points; + + if (points.length > 2) + { + var sqTolerance = tolerance * tolerance; + + if (!highestQuality) + { + points = simplifyRadialDist(points, sqTolerance); + } + + polygon.setTo(simplifyDouglasPeucker(points, sqTolerance)); + } + + return polygon; +}; + +module.exports = Simplify; + + +/***/ }, + +/***/ 5469 +(module) { + +/** + * @author Richard Davey + * @author Igor Ognichenko + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @ignore + */ +var copy = function (out, a) +{ + out[0] = a[0]; + out[1] = a[1]; + + return out; +}; + +/** + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * + * Chaikin's algorithm is a corner-cutting technique that replaces each edge between + * two consecutive points with two new points positioned along that edge, resulting in + * a smoother curve. Each iteration of the algorithm increases the total number of points + * in the polygon. The original first and last points are preserved, while all intermediate + * points are replaced by pairs of new points at 85% and 15% along each edge. + * + * The polygon is modified in-place and the same polygon object is returned. + * + * @function Phaser.Geom.Polygon.Smooth + * @since 3.13.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The polygon to be smoothed. The polygon will be modified in-place and returned. + * + * @return {Phaser.Geom.Polygon} The input polygon. + */ +var Smooth = function (polygon) +{ + var i; + var points = []; + var data = polygon.points; + + for (i = 0; i < data.length; i++) + { + points.push([ data[i].x, data[i].y ]); + } + + var output = []; + + if (points.length > 0) + { + output.push(copy([ 0, 0 ], points[0])); + } + + for (i = 0; i < points.length - 1; i++) + { + var p0 = points[i]; + var p1 = points[i + 1]; + var p0x = p0[0]; + var p0y = p0[1]; + var p1x = p1[0]; + var p1y = p1[1]; + + output.push([ 0.85 * p0x + 0.15 * p1x, 0.85 * p0y + 0.15 * p1y ]); + output.push([ 0.15 * p0x + 0.85 * p1x, 0.15 * p0y + 0.85 * p1y ]); + } + + if (points.length > 1) + { + output.push(copy([ 0, 0 ], points[points.length - 1])); + } + + return polygon.setTo(output); +}; + +module.exports = Smooth; + + +/***/ }, + +/***/ 24709 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Translates the points of the given Polygon. + * + * @function Phaser.Geom.Polygon.Translate + * @since 3.50.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to modify. + * @param {number} x - The amount to horizontally translate the points by. + * @param {number} y - The amount to vertically translate the points by. + * + * @return {Phaser.Geom.Polygon} The modified Polygon. + */ +var Translate = function (polygon, x, y) +{ + var points = polygon.points; + + for (var i = 0; i < points.length; i++) + { + points[i].x += x; + points[i].y += y; + } + + return polygon; +}; + +module.exports = Translate; + + +/***/ }, + +/***/ 58423 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Polygon = __webpack_require__(25717); + +Polygon.Clone = __webpack_require__(12306); +Polygon.Contains = __webpack_require__(63814); +Polygon.ContainsPoint = __webpack_require__(99338); +Polygon.Earcut = __webpack_require__(94811); +Polygon.GetAABB = __webpack_require__(13829); +Polygon.GetNumberArray = __webpack_require__(26173); +Polygon.GetPoints = __webpack_require__(9564); +Polygon.Perimeter = __webpack_require__(30052); +Polygon.Reverse = __webpack_require__(8133); +Polygon.Simplify = __webpack_require__(29524); +Polygon.Smooth = __webpack_require__(5469); +Polygon.Translate = __webpack_require__(24709); + +module.exports = Polygon; + + +/***/ }, + +/***/ 39843 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates the area of the given Rectangle object. + * + * @function Phaser.Geom.Rectangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The rectangle to calculate the area of. + * + * @return {number} The area of the Rectangle object. + */ +var Area = function (rect) +{ + return rect.width * rect.height; +}; + +module.exports = Area; + + +/***/ }, + +/***/ 98615 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. + * + * @function Phaser.Geom.Rectangle.Ceil + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Ceil = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + + return rect; +}; + +module.exports = Ceil; + + +/***/ }, + +/***/ 31688 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value. + * + * @function Phaser.Geom.Rectangle.CeilAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to modify. + * + * @return {Phaser.Geom.Rectangle} The modified Rectangle. + */ +var CeilAll = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + rect.width = Math.ceil(rect.width); + rect.height = Math.ceil(rect.height); + + return rect; +}; + +module.exports = CeilAll; + + +/***/ }, + +/***/ 67502 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. + * + * @function Phaser.Geom.Rectangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to be centered. + * @param {number} x - The X coordinate of the Rectangle's center. + * @param {number} y - The Y coordinate of the Rectangle's center. + * + * @return {Phaser.Geom.Rectangle} The centered rectangle. + */ +var CenterOn = function (rect, x, y) +{ + rect.x = x - (rect.width / 2); + rect.y = y - (rect.height / 2); + + return rect; +}; + +module.exports = CenterOn; + + +/***/ }, + +/***/ 65085 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +/** + * Creates a new Rectangle which is identical to the given one. + * + * @function Phaser.Geom.Rectangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} source - The Rectangle to clone. + * + * @return {Phaser.Geom.Rectangle} The newly created Rectangle, which is separate from the given one. + */ +var Clone = function (source) +{ + return new Rectangle(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }, + +/***/ 37303 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Checks if a given point is inside a Rectangle's bounds. + * + * @function Phaser.Geom.Rectangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to check. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`. + */ +var Contains = function (rect, x, y) +{ + if (rect.width <= 0 || rect.height <= 0) + { + return false; + } + + return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); +}; + +module.exports = Contains; + + +/***/ }, + +/***/ 96553 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(37303); + +/** + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. + * + * @function Phaser.Geom.Rectangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object. + * @param {Phaser.Math.Vector2} vec - The Vector2 object to check the coordinates of. + * + * @return {boolean} A value of true if the Rectangle object contains the specified point, otherwise false. + */ +var ContainsPoint = function (rect, vec) +{ + return Contains(rect, vec.x, vec.y); +}; + +module.exports = ContainsPoint; + + +/***/ }, + +/***/ 70273 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Tests if one rectangle fully contains another. A rectangle is considered fully contained + * if all four of its edges (left, right, top, and bottom) lie strictly within the bounds + * of the outer rectangle. Rectangles that merely touch or overlap are not considered contained. + * + * @function Phaser.Geom.Rectangle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - The outer rectangle to test as the container. + * @param {Phaser.Geom.Rectangle} rectB - The inner rectangle to test for full containment within rectA. + * + * @return {boolean} True only if rectA fully contains rectB. + */ +var ContainsRect = function (rectA, rectB) +{ + // Volume check (if rectB volume > rectA then rectA cannot contain it) + if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) + { + return false; + } + + return ( + (rectB.x > rectA.x && rectB.x < rectA.right) && + (rectB.right > rectA.x && rectB.right < rectA.right) && + (rectB.y > rectA.y && rectB.y < rectA.bottom) && + (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }, + +/***/ 43459 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Copy the values of one Rectangle to a destination Rectangle. + * + * @function Phaser.Geom.Rectangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [dest,$return] + * + * @param {Phaser.Geom.Rectangle} source - The source Rectangle to copy the values from. + * @param {Phaser.Geom.Rectangle} dest - The destination Rectangle to copy the values to. + * + * @return {Phaser.Geom.Rectangle} The destination Rectangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }, + +/***/ 77493 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Creates an array of plain `{x, y}` point objects for each of the four corners of a Rectangle, in the order: top-left, top-right, bottom-right, bottom-left. + * If an output array is provided, each point object will be pushed to the end of it, otherwise a new array will be created and returned. + * + * @function Phaser.Geom.Rectangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object to be decomposed. + * @param {array} [out] - If provided, each point will be added to this array. + * + * @return {array} Will return the array you specified or a new array containing the points of the Rectangle. + */ +var Decompose = function (rect, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: rect.x, y: rect.y }); + out.push({ x: rect.right, y: rect.y }); + out.push({ x: rect.right, y: rect.bottom }); + out.push({ x: rect.x, y: rect.bottom }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }, + +/***/ 9219 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Compares the `x`, `y`, `width` and `height` properties of two rectangles. + * Returns `true` only if all four values match exactly using strict equality. + * This function does not consider rectangles with the same area but different + * positions or dimensions to be equal. + * + * @function Phaser.Geom.Rectangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The first rectangle to compare. + * @param {Phaser.Geom.Rectangle} toCompare - The second rectangle to compare against. + * + * @return {boolean} `true` if the rectangles' properties are an exact match, otherwise `false`. + */ +var Equals = function (rect, toCompare) +{ + return ( + rect.x === toCompare.x && + rect.y === toCompare.y && + rect.width === toCompare.width && + rect.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }, + +/***/ 53751 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetAspectRatio = __webpack_require__(8249); + +/** + * Adjusts the target rectangle, changing its width, height and position, + * so that it fits inside the area of the source rectangle, while maintaining its original + * aspect ratio. + * + * Unlike the `FitOutside` function, there may be some space inside the source area not covered. + * + * @function Phaser.Geom.Rectangle.FitInside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The target rectangle to adjust. + * @param {Phaser.Geom.Rectangle} source - The source rectangle to envelop the target in. + * + * @return {Phaser.Geom.Rectangle} The modified target rectangle instance. + */ +var FitInside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio < GetAspectRatio(source)) + { + // Taller than Wide + target.setSize(source.height * ratio, source.height); + } + else + { + // Wider than Tall + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - (target.width / 2), + source.centerY - (target.height / 2) + ); +}; + +module.exports = FitInside; + + +/***/ }, + +/***/ 16088 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetAspectRatio = __webpack_require__(8249); + +/** + * Adjusts the target rectangle, changing its width, height and position, + * so that it fully covers the area of the source rectangle, while maintaining its original + * aspect ratio. + * + * Unlike the `FitInside` function, the target rectangle may extend further out than the source. + * + * @function Phaser.Geom.Rectangle.FitOutside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The target rectangle to adjust. + * @param {Phaser.Geom.Rectangle} source - The source rectangle to envelope the target in. + * + * @return {Phaser.Geom.Rectangle} The modified target rectangle instance. + */ +var FitOutside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio > GetAspectRatio(source)) + { + // Wider than Tall + target.setSize(source.height * ratio, source.height); + } + else + { + // Taller than Wide + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - target.width / 2, + source.centerY - target.height / 2 + ); +}; + +module.exports = FitOutside; + + +/***/ }, + +/***/ 80774 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Rounds down (floors) the top left X and Y coordinates of the given Rectangle to the largest integer less than or equal to them + * + * @function Phaser.Geom.Rectangle.Floor + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The rectangle to floor the top left X and Y coordinates of + * + * @return {Phaser.Geom.Rectangle} The rectangle that was passed to this function with its coordinates floored. + */ +var Floor = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + + return rect; +}; + +module.exports = Floor; + + +/***/ }, + +/***/ 83859 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. + * + * @function Phaser.Geom.Rectangle.FloorAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var FloorAll = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + rect.width = Math.floor(rect.width); + rect.height = Math.floor(rect.height); + + return rect; +}; + +module.exports = FloorAll; + + +/***/ }, + +/***/ 19217 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); +var MATH_CONST = __webpack_require__(36383); + +/** + * Constructs a new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. + * + * The `points` parameter is an array of Point-like objects: + * + * ```js + * const points = [ + * [100, 200], + * [200, 400], + * { x: 30, y: 60 } + * ] + * ``` + * + * @function Phaser.Geom.Rectangle.FromPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {array} points - An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param {Phaser.Geom.Rectangle} [out] - Optional Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted `out` Rectangle, or a new Rectangle if none was provided. + */ +var FromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (points.length === 0) + { + return out; + } + + var minX = Number.MAX_VALUE; + var minY = Number.MAX_VALUE; + + var maxX = MATH_CONST.MIN_SAFE_INTEGER; + var maxY = MATH_CONST.MIN_SAFE_INTEGER; + + var p; + var px; + var py; + + for (var i = 0; i < points.length; i++) + { + p = points[i]; + + if (Array.isArray(p)) + { + px = p[0]; + py = p[1]; + } + else + { + px = p.x; + py = p.y; + } + + minX = Math.min(minX, px); + minY = Math.min(minY, py); + + maxX = Math.max(maxX, px); + maxY = Math.max(maxY, py); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = FromPoints; + + +/***/ }, + +/***/ 9477 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author samme + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +/** + * Create the smallest Rectangle containing two coordinate pairs. + * + * @function Phaser.Geom.Rectangle.FromXY + * @since 3.23.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {number} x1 - The X coordinate of the first point. + * @param {number} y1 - The Y coordinate of the first point. + * @param {number} x2 - The X coordinate of the second point. + * @param {number} y2 - The Y coordinate of the second point. + * @param {Phaser.Geom.Rectangle} [out] - Optional Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted `out` Rectangle, or a new Rectangle if none was provided. + */ +var FromXY = function (x1, y1, x2, y2, out) +{ + if (out === undefined) { out = new Rectangle(); } + + return out.setTo( + Math.min(x1, x2), + Math.min(y1, y2), + Math.abs(x1 - x2), + Math.abs(y1 - y2) + ); +}; + +module.exports = FromXY; + + +/***/ }, + +/***/ 8249 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates the width/height ratio of a rectangle. + * + * @function Phaser.Geom.Rectangle.GetAspectRatio + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The rectangle. + * + * @return {number} The width/height ratio of the rectangle. + */ +var GetAspectRatio = function (rect) +{ + return (rect.height === 0) ? NaN : rect.width / rect.height; +}; + +module.exports = GetAspectRatio; + + +/***/ }, + +/***/ 27165 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns the center of a Rectangle as a Point. + * + * @function Phaser.Geom.Rectangle.GetCenter + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the center of. + * @param {Phaser.Math.Vector2} [out] - Optional Vector2 object to update with the center coordinates. + * + * @return {Phaser.Math.Vector2} The modified `out` object, or a new Vector2 if none was provided. + */ +var GetCenter = function (rect, out) +{ + if (out === undefined) { out = new Vector2(); } + + out.x = rect.centerX; + out.y = rect.centerY; + + return out; +}; + +module.exports = GetCenter; + + +/***/ }, + +/***/ 20812 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Perimeter = __webpack_require__(13019); +var Vector2 = __webpack_require__(26099); + +/** + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * + * @function Phaser.Geom.Rectangle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from. + * @param {number} position - The normalized distance into the Rectangle's perimeter to return. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to update with the `x` and `y` coordinates of the point. + * + * @return {Phaser.Math.Vector2} The updated `out` object, or a new Vector2 if no `out` object was given. + */ +var GetPoint = function (rectangle, position, out) +{ + if (out === undefined) { out = new Vector2(); } + + if (position <= 0 || position >= 1) + { + out.x = rectangle.x; + out.y = rectangle.y; + + return out; + } + + var p = Perimeter(rectangle) * position; + + if (position > 0.5) + { + p -= (rectangle.width + rectangle.height); + + if (p <= rectangle.width) + { + // Face 3 + out.x = rectangle.right - p; + out.y = rectangle.bottom; + } + else + { + // Face 4 + out.x = rectangle.x; + out.y = rectangle.bottom - (p - rectangle.width); + } + } + else if (p <= rectangle.width) + { + // Face 1 + out.x = rectangle.x + p; + out.y = rectangle.y; + } + else + { + // Face 2 + out.x = rectangle.right; + out.y = rectangle.y + (p - rectangle.width); + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }, + +/***/ 34819 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetPoint = __webpack_require__(20812); +var Perimeter = __webpack_require__(13019); + +/** + * Return an array of Vector2 points from the perimeter of the rectangle, each spaced out based on the quantity or step required. + * + * @function Phaser.Geom.Rectangle.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle object to get the points from. + * @param {number} quantity - The number of evenly spaced points from the rectangle's perimeter to return. If falsey, stepRate param will be used to calculate the number of points. + * @param {number} stepRate - Step between points. Used to calculate the number of points to return when quantity is falsey. Ignored if quantity is positive. + * @param {Phaser.Math.Vector2[]} [out] - An optional array to store the points in. + * + * @return {Phaser.Math.Vector2[]} An array of Vector2 points from the perimeter of the rectangle. + */ +var GetPoints = function (rectangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity && stepRate > 0) + { + quantity = Perimeter(rectangle) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + out.push(GetPoint(rectangle, position)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }, + +/***/ 51313 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns the size of the Rectangle, expressed as a Vector2 object. + * With the value of the `width` as the `x` property and the `height` as the `y` property. + * + * @function Phaser.Geom.Rectangle.GetSize + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the size from. + * @param {Phaser.Math.Vector2} [out] - The Vector2 object to store the size in. If not given, a new Vector2 instance is created. + * + * @return {Phaser.Math.Vector2} A Vector2 object where `x` holds the width and `y` holds the height of the Rectangle. + */ +var GetSize = function (rect, out) +{ + if (out === undefined) { out = new Vector2(); } + + out.x = rect.width; + out.y = rect.height; + + return out; +}; + +module.exports = GetSize; + + +/***/ }, + +/***/ 86091 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CenterOn = __webpack_require__(67502); + +/** + * Increases the size of a Rectangle by a specified amount. + * + * The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument. + * + * @function Phaser.Geom.Rectangle.Inflate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to inflate. + * @param {number} x - How many pixels the left and the right side should be moved by horizontally. + * @param {number} y - How many pixels the top and the bottom side should be moved by vertically. + * + * @return {Phaser.Geom.Rectangle} The inflated Rectangle. + */ +var Inflate = function (rect, x, y) +{ + var cx = rect.centerX; + var cy = rect.centerY; + + rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); + + return CenterOn(rect, cx, cy); +}; + +module.exports = Inflate; + + +/***/ }, + +/***/ 53951 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); +var Intersects = __webpack_require__(59996); + +/** + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * + * @function Phaser.Geom.Rectangle.Intersection + * @since 3.11.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle to store the intersection results in. + * + * @return {Phaser.Geom.Rectangle} The intersection result. If the width and height are zero, no intersection occurred. + */ +var Intersection = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (Intersects(rectA, rectB)) + { + out.x = Math.max(rectA.x, rectB.x); + out.y = Math.max(rectA.y, rectB.y); + out.width = Math.min(rectA.right, rectB.right) - out.x; + out.height = Math.min(rectA.bottom, rectB.bottom) - out.y; + } + else + { + out.setEmpty(); + } + + return out; +}; + +module.exports = Intersection; + + +/***/ }, + +/***/ 14649 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Perimeter = __webpack_require__(13019); +var Vector2 = __webpack_require__(26099); + +/** + * Returns an array of Vector2 points evenly distributed around the perimeter of the Rectangle. This is + * commonly used to create a "marching ants" selection effect, where the returned points are used to + * animate a dashed outline that appears to march around the border of the rectangle. + * + * You can control the spacing of the points either by providing a pixel `step` distance between each + * point, or by specifying the total `quantity` of points to distribute evenly around the full perimeter. + * If both are omitted, an empty array is returned. If `step` is provided, `quantity` is derived from + * the perimeter length divided by the step. If only `quantity` is provided, the step is derived instead. + * + * @function Phaser.Geom.Rectangle.MarchingAnts + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the perimeter points from. + * @param {number} [step] - The distance between each point of the perimeter. Set to `null` if you wish to use the `quantity` parameter instead. + * @param {number} [quantity] - The total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value. + * @param {Phaser.Math.Vector2[]} [out] - An array in which the perimeter points will be stored. If not given, a new array instance is created. + * + * @return {Phaser.Math.Vector2[]} An array containing the perimeter points from the Rectangle. + */ +var MarchingAnts = function (rect, step, quantity, out) +{ + if (out === undefined) { out = []; } + + if (!step && !quantity) + { + // Bail out + return out; + } + + // If step is a falsey value (false, null, 0, undefined, etc) then we calculate + // it based on the quantity instead, otherwise we always use the step value + if (!step) + { + step = Perimeter(rect) / quantity; + } + else + { + quantity = Math.round(Perimeter(rect) / step); + } + + var x = rect.x; + var y = rect.y; + var face = 0; + + // Loop across each face of the rectangle + + for (var i = 0; i < quantity; i++) + { + out.push(new Vector2(x, y)); + + switch (face) + { + + // Top face + case 0: + x += step; + + if (x >= rect.right) + { + face = 1; + y += (x - rect.right); + x = rect.right; + } + break; + + // Right face + case 1: + y += step; + + if (y >= rect.bottom) + { + face = 2; + x -= (y - rect.bottom); + y = rect.bottom; + } + break; + + // Bottom face + case 2: + x -= step; + + if (x <= rect.left) + { + face = 3; + y -= (rect.left - x); + x = rect.left; + } + break; + + // Left face + case 3: + y -= step; + + if (y <= rect.top) + { + face = 0; + y = rect.top; + } + break; + } + } + + return out; +}; + +module.exports = MarchingAnts; + + +/***/ }, + +/***/ 33595 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergePoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged. + * @param {Phaser.Math.Vector2[]} points - An array of Vector2 objects which should be merged with the Rectangle. + * + * @return {Phaser.Geom.Rectangle} The modified Rectangle. + */ +var MergePoints = function (target, points) +{ + var minX = target.x; + var maxX = target.right; + var minY = target.y; + var maxY = target.bottom; + + for (var i = 0; i < points.length; i++) + { + minX = Math.min(minX, points[i].x); + maxX = Math.max(maxX, points[i].x); + minY = Math.min(minY, points[i].y); + maxY = Math.max(maxY, points[i].y); + } + + target.x = minX; + target.y = minY; + target.width = maxX - minX; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergePoints; + + +/***/ }, + +/***/ 20074 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. + * + * @function Phaser.Geom.Rectangle.MergeRect + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - Target rectangle. Will be modified to include source rectangle. + * @param {Phaser.Geom.Rectangle} source - Rectangle that will be merged into target rectangle. + * + * @return {Phaser.Geom.Rectangle} Modified target rectangle that contains source rectangle. + */ +var MergeRect = function (target, source) +{ + var minX = Math.min(target.x, source.x); + var maxX = Math.max(target.right, source.right); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, source.y); + var maxY = Math.max(target.bottom, source.bottom); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeRect; + + +/***/ }, + +/***/ 92171 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergeXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged and modified. + * @param {number} x - The X coordinate of the point which should be merged. + * @param {number} y - The Y coordinate of the point which should be merged. + * + * @return {Phaser.Geom.Rectangle} The modified `target` Rectangle. + */ +var MergeXY = function (target, x, y) +{ + var minX = Math.min(target.x, x); + var maxX = Math.max(target.right, x); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, y); + var maxY = Math.max(target.bottom, y); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeXY; + + +/***/ }, + +/***/ 42981 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Translates a Rectangle by the given horizontal and vertical amounts, moving its position while preserving its size. + * + * @function Phaser.Geom.Rectangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {number} x - The distance to move the Rectangle horizontally. + * @param {number} y - The distance to move the Rectangle vertically. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Offset = function (rect, x, y) +{ + rect.x += x; + rect.y += y; + + return rect; +}; + +module.exports = Offset; + + +/***/ }, + +/***/ 46907 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Translates the top-left corner of a Rectangle by the coordinates of a translation vector. + * + * @function Phaser.Geom.Rectangle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {Phaser.Math.Vector2} vec - The Vector2 point whose coordinates should be used as an offset. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var OffsetPoint = function (rect, vec) +{ + rect.x += vec.x; + rect.y += vec.y; + + return rect; +}; + +module.exports = OffsetPoint; + + +/***/ }, + +/***/ 60170 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid". + * + * @function Phaser.Geom.Rectangle.Overlaps + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to check. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to check. + * + * @return {boolean} `true` if the two Rectangles overlap, `false` otherwise. + */ +var Overlaps = function (rectA, rectB) +{ + return ( + rectA.x < rectB.right && + rectA.right > rectB.x && + rectA.y < rectB.bottom && + rectA.bottom > rectB.y + ); +}; + +module.exports = Overlaps; + + +/***/ }, + +/***/ 13019 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates the perimeter of a Rectangle. + * + * @function Phaser.Geom.Rectangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to use. + * + * @return {number} The perimeter of the Rectangle, equal to `(width * 2) + (height * 2)`. + */ +var Perimeter = function (rect) +{ + return 2 * (rect.width + rect.height); +}; + +module.exports = Perimeter; + + +/***/ }, + +/***/ 85133 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); +var DegToRad = __webpack_require__(39506); + +/** + * Returns a point from the perimeter of a Rectangle based on the given angle, measured in degrees from the center of the Rectangle. + * + * @function Phaser.Geom.Rectangle.PerimeterPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from. + * @param {number} angle - The angle of the point, in degrees. + * @param {Phaser.Math.Vector2} [out] - The Vector2 object to store the position in. If not given, a new Vector2 instance is created. + * + * @return {Phaser.Math.Vector2} A Vector2 object holding the coordinates of the point on the Rectangle's perimeter. + */ +var PerimeterPoint = function (rectangle, angle, out) +{ + if (out === undefined) { out = new Vector2(); } + + angle = DegToRad(angle); + + var s = Math.sin(angle); + var c = Math.cos(angle); + + var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; + var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; + + if (Math.abs(dx * s) < Math.abs(dy * c)) + { + dy = (dx * s) / c; + } + else + { + dx = (dy * c) / s; + } + + out.x = dx + rectangle.centerX; + out.y = dy + rectangle.centerY; + + return out; +}; + +module.exports = PerimeterPoint; + + +/***/ }, + +/***/ 26597 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns a random point within a Rectangle. + * + * @function Phaser.Geom.Rectangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to return a point from. + * @param {Phaser.Math.Vector2} out - The object to update with the point's coordinates. + * + * @return {Phaser.Math.Vector2} The modified `out` object, or a new Point if none was provided. + */ +var Random = function (rect, out) +{ + if (out === undefined) { out = new Vector2(); } + + out.x = rect.x + (Math.random() * rect.width); + out.y = rect.y + (Math.random() * rect.height); + + return out; +}; + +module.exports = Random; + + +/***/ }, + +/***/ 86470 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Between = __webpack_require__(30976); +var ContainsRect = __webpack_require__(70273); +var Vector2 = __webpack_require__(26099); + +/** + * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. + * The inner Rectangle must be fully contained within the outer rectangle for a point to be generated. + * If `inner` is not fully contained within `outer`, the function returns the `out` vector unchanged. + * + * @function Phaser.Geom.Rectangle.RandomOutside + * @since 3.10.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} outer - The outer Rectangle to get the random point within. + * @param {Phaser.Geom.Rectangle} inner - The inner Rectangle to exclude from the returned point. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not specified, a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object containing the random values in its `x` and `y` properties. + */ +var RandomOutside = function (outer, inner, out) +{ + if (out === undefined) { out = new Vector2(); } + + if (ContainsRect(outer, inner)) + { + // Pick a random quadrant + // + // The quadrants don't extend the full widths / heights of the outer rect to give + // us a better uniformed distribution, otherwise you get clumping in the corners where + // the 4 quads would overlap + + switch (Between(0, 3)) + { + case 0: // Top + out.x = outer.x + (Math.random() * (inner.right - outer.x)); + out.y = outer.y + (Math.random() * (inner.top - outer.y)); + break; + + case 1: // Bottom + out.x = inner.x + (Math.random() * (outer.right - inner.x)); + out.y = inner.bottom + (Math.random() * (outer.bottom - inner.bottom)); + break; + + case 2: // Left + out.x = outer.x + (Math.random() * (inner.x - outer.x)); + out.y = inner.y + (Math.random() * (outer.bottom - inner.y)); + break; + + case 3: // Right + out.x = inner.right + (Math.random() * (outer.right - inner.right)); + out.y = outer.y + (Math.random() * (inner.bottom - outer.y)); + break; + } + } + + return out; +}; + +module.exports = RandomOutside; + + +/***/ }, + +/***/ 87841 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(37303); +var GetPoint = __webpack_require__(20812); +var GetPoints = __webpack_require__(34819); +var GEOM_CONST = __webpack_require__(23777); +var Line = __webpack_require__(23031); +var Random = __webpack_require__(26597); + +/** + * @classdesc + * A Rectangle is an axis-aligned region of 2D space defined by its top-left corner position (`x`, `y`) and its + * dimensions (`width`, `height`). It is one of the core geometric primitives in Phaser and is used extensively + * throughout the framework for bounds checking, camera viewports, hit areas, culling regions, and UI layout. + * + * Rectangles support containment tests, perimeter point sampling, and many other geometric operations available + * via the `Phaser.Geom.Rectangle` static methods. The `left`, `right`, `top`, `bottom`, `centerX`, and `centerY` + * properties provide convenient access to derived positional values and can be set directly to reposition or + * resize the Rectangle. + * + * @class Rectangle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=0] - The Y coordinate of the top left corner of the Rectangle. + * @param {number} [width=0] - The width of the Rectangle. + * @param {number} [height=0] - The height of the Rectangle. + */ +var Rectangle = new Class({ + + initialize: + + function Rectangle (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The geometry constant type of this object: `GEOM_CONST.RECTANGLE`. + * Used for fast type comparisons. + * + * @name Phaser.Geom.Rectangle#type + * @type {number} + * @readonly + * @since 3.19.0 + */ + this.type = GEOM_CONST.RECTANGLE; + + /** + * The X coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The Y coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. + * + * @name Phaser.Geom.Rectangle#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. + * + * @name Phaser.Geom.Rectangle#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Checks if the given point is inside the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#contains + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * + * @method Phaser.Geom.Rectangle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} position - The normalized distance into the Rectangle's perimeter to return. + * @param {Phaser.Math.Vector2} [output] - A Vector2 instance to update with the `x` and `y` coordinates of the point. + * + * @return {Phaser.Math.Vector2} The updated `output` object, or a new Vector2 if no `output` object was given. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. + * + * @method Phaser.Geom.Rectangle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [output,$return] + * + * @param {number} quantity - The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param {number} [stepRate] - If `quantity` is 0, determines the normalized distance between each returned point. + * @param {Phaser.Math.Vector2[]} [output] - An array to which to append the points. + * + * @return {Phaser.Math.Vector2[]} The modified `output` array, or a new array if none was provided. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a random point within the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [point,$return] + * + * @param {Phaser.Math.Vector2} [vec] - The object in which to store the `x` and `y` coordinates of the point. + * + * @return {Phaser.Math.Vector2} The updated `vec`, or a new Vector2 if none was provided. + */ + getRandomPoint: function (vec) + { + return Random(this, vec); + }, + + /** + * Sets the position, width, and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setTo + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} y - The Y coordinate of the top left corner of the Rectangle. + * @param {number} width - The width of the Rectangle. + * @param {number} height - The height of the Rectangle. + * + * @return {this} This Rectangle object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Resets the position, width, and height of the Rectangle to 0. + * + * @method Phaser.Geom.Rectangle#setEmpty + * @since 3.0.0 + * + * @return {this} This Rectangle object. + */ + setEmpty: function () + { + return this.setTo(0, 0, 0, 0); + }, + + /** + * Sets the position of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setPosition + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=x] - The Y coordinate of the top left corner of the Rectangle. + * + * @return {this} This Rectangle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the width and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setSize + * @since 3.0.0 + * + * @param {number} width - The width to set the Rectangle to. + * @param {number} [height=width] - The height to set the Rectangle to. + * + * @return {this} This Rectangle object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. + * + * @method Phaser.Geom.Rectangle#isEmpty + * @since 3.0.0 + * + * @return {boolean} `true` if the Rectangle is empty, otherwise `false`. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineA + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.y, this.right, this.y); + + return line; + }, + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.y, this.right, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineC + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.bottom, this.x, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineD + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. + */ + getLineD: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.bottom, this.x, this.y); + + return line; + }, + + /** + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. + * + * @name Phaser.Geom.Rectangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x; + }, + + set: function (value) + { + if (value >= this.right) + { + this.width = 0; + } + else + { + this.width = this.right - value; + } + + this.x = value; + } + + }, + + /** + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. + * + * @name Phaser.Geom.Rectangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this.width; + }, + + set: function (value) + { + if (value <= this.x) + { + this.width = 0; + } + else + { + this.width = value - this.x; + } + } + + }, + + /** + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. + * + * @name Phaser.Geom.Rectangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y; + }, + + set: function (value) + { + if (value >= this.bottom) + { + this.height = 0; + } + else + { + this.height = (this.bottom - value); + } + + this.y = value; + } + + }, + + /** + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. + * + * @name Phaser.Geom.Rectangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this.height; + }, + + set: function (value) + { + if (value <= this.y) + { + this.height = 0; + } + else + { + this.height = value - this.y; + } + } + + }, + + /** + * The x coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerX + * @type {number} + * @since 3.0.0 + */ + centerX: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The y coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerY + * @type {number} + * @since 3.0.0 + */ + centerY: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Rectangle; + + +/***/ }, + +/***/ 94845 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * + * @function Phaser.Geom.Rectangle.SameDimensions + * @since 3.15.0 + * + * @param {Phaser.Geom.Rectangle} rect - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} toCompare - The second Rectangle object. + * + * @return {boolean} `true` if the objects have equivalent values for the `width` and `height` properties, otherwise `false`. + */ +var SameDimensions = function (rect, toCompare) +{ + return (rect.width === toCompare.width && rect.height === toCompare.height); +}; + +module.exports = SameDimensions; + + +/***/ }, + +/***/ 31730 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Scales the width and height of the given Rectangle by the given factors. + * + * @function Phaser.Geom.Rectangle.Scale + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The `Rectangle` object that will be scaled by the specified amount(s). + * @param {number} x - The factor by which to scale the rectangle horizontally. + * @param {number} y - The factor by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions. + * + * @return {Phaser.Geom.Rectangle} The rectangle object with updated `width` and `height` properties as calculated from the scaling factor(s). + */ +var Scale = function (rect, x, y) +{ + if (y === undefined) { y = x; } + + rect.width *= x; + rect.height *= y; + + return rect; +}; + +module.exports = Scale; + + +/***/ }, + +/***/ 36899 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +/** + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. + * + * @function Phaser.Geom.Rectangle.Union + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to use. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to use. + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the union in. + * + * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. + */ +var Union = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + // Cache vars so we can use one of the input rects as the output rect + var x = Math.min(rectA.x, rectB.x); + var y = Math.min(rectA.y, rectB.y); + var w = Math.max(rectA.right, rectB.right) - x; + var h = Math.max(rectA.bottom, rectB.bottom) - y; + + return out.setTo(x, y, w, h); +}; + +module.exports = Union; + + +/***/ }, + +/***/ 93232 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +Rectangle.Area = __webpack_require__(39843); +Rectangle.Ceil = __webpack_require__(98615); +Rectangle.CeilAll = __webpack_require__(31688); +Rectangle.CenterOn = __webpack_require__(67502); +Rectangle.Clone = __webpack_require__(65085); +Rectangle.Contains = __webpack_require__(37303); +Rectangle.ContainsPoint = __webpack_require__(96553); +Rectangle.ContainsRect = __webpack_require__(70273); +Rectangle.CopyFrom = __webpack_require__(43459); +Rectangle.Decompose = __webpack_require__(77493); +Rectangle.Equals = __webpack_require__(9219); +Rectangle.FitInside = __webpack_require__(53751); +Rectangle.FitOutside = __webpack_require__(16088); +Rectangle.Floor = __webpack_require__(80774); +Rectangle.FloorAll = __webpack_require__(83859); +Rectangle.FromPoints = __webpack_require__(19217); +Rectangle.FromXY = __webpack_require__(9477); +Rectangle.GetAspectRatio = __webpack_require__(8249); +Rectangle.GetCenter = __webpack_require__(27165); +Rectangle.GetPoint = __webpack_require__(20812); +Rectangle.GetPoints = __webpack_require__(34819); +Rectangle.GetSize = __webpack_require__(51313); +Rectangle.Inflate = __webpack_require__(86091); +Rectangle.Intersection = __webpack_require__(53951); +Rectangle.MarchingAnts = __webpack_require__(14649); +Rectangle.MergePoints = __webpack_require__(33595); +Rectangle.MergeRect = __webpack_require__(20074); +Rectangle.MergeXY = __webpack_require__(92171); +Rectangle.Offset = __webpack_require__(42981); +Rectangle.OffsetPoint = __webpack_require__(46907); +Rectangle.Overlaps = __webpack_require__(60170); +Rectangle.Perimeter = __webpack_require__(13019); +Rectangle.PerimeterPoint = __webpack_require__(85133); +Rectangle.Random = __webpack_require__(26597); +Rectangle.RandomOutside = __webpack_require__(86470); +Rectangle.SameDimensions = __webpack_require__(94845); +Rectangle.Scale = __webpack_require__(31730); +Rectangle.Union = __webpack_require__(36899); + +module.exports = Rectangle; + + +/***/ }, + +/***/ 41658 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// The 2D area of a triangle. The area value is always non-negative. + +/** + * Returns the area of a Triangle. + * + * @function Phaser.Geom.Triangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to use. + * + * @return {number} The area of the Triangle, always non-negative. + */ +var Area = function (triangle) +{ + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); +}; + +module.exports = Area; + + +/***/ }, + +/***/ 39208 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Triangle = __webpack_require__(16483); + +/** + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. + * + * @function Phaser.Geom.Triangle.BuildEquilateral + * @since 3.0.0 + * + * @param {number} x - x coordinate of the top point of the triangle. + * @param {number} y - y coordinate of the top point of the triangle. + * @param {number} length - Length of each side of the triangle. + * + * @return {Phaser.Geom.Triangle} A new equilateral Triangle with its apex at (`x`, `y`) and all sides of the specified `length`. + */ +var BuildEquilateral = function (x, y, length) +{ + var height = length * (Math.sqrt(3) / 2); + + var x1 = x; + var y1 = y; + + var x2 = x + (length / 2); + var y2 = y + height; + + var x3 = x - (length / 2); + var y3 = y + height; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildEquilateral; + + +/***/ }, + +/***/ 39545 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var EarCut = __webpack_require__(94811); +var Triangle = __webpack_require__(16483); + +/** + * Takes an array of vertex coordinates, and optionally an array of hole indices, then returns an array + * of Triangle instances, where the given vertices have been decomposed into a series of triangles. + * + * @function Phaser.Geom.Triangle.BuildFromPolygon + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle[]} O - [out,$return] + * + * @param {array} data - A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). + * @param {number} [scaleX=1] - Horizontal scale factor to multiply the resulting points by. + * @param {number} [scaleY=1] - Vertical scale factor to multiply the resulting points by. + * @param {(array|Phaser.Geom.Triangle[])} [out] - An array to store the resulting Triangle instances in. If not provided, a new array is created. + * + * @return {(array|Phaser.Geom.Triangle[])} An array of Triangle instances, where each triangle is based on the decomposed vertices data. + */ +var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) +{ + if (holes === undefined) { holes = null; } + if (scaleX === undefined) { scaleX = 1; } + if (scaleY === undefined) { scaleY = 1; } + if (out === undefined) { out = []; } + + var tris = EarCut(data, holes); + + var a; + var b; + var c; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + for (var i = 0; i < tris.length; i += 3) + { + a = tris[i]; + b = tris[i + 1]; + c = tris[i + 2]; + + x1 = data[a * 2] * scaleX; + y1 = data[(a * 2) + 1] * scaleY; + + x2 = data[b * 2] * scaleX; + y2 = data[(b * 2) + 1] * scaleY; + + x3 = data[c * 2] * scaleX; + y3 = data[(c * 2) + 1] * scaleY; + + out.push(new Triangle(x1, y1, x2, y2, x3, y3)); + } + + return out; +}; + +module.exports = BuildFromPolygon; + + +/***/ }, + +/***/ 90301 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Triangle = __webpack_require__(16483); + +// Builds a right triangle, with one 90 degree angle and two acute angles +// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) +// w/h can be positive or negative and represent the length of each side + +/** + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. The `x` and `y` coordinates mark the position of the right-angle vertex, which becomes the first point of the Triangle. The `width` and `height` values determine the lengths of the two sides adjacent to the right angle and may be positive or negative, which controls the direction in which each side extends from the right-angle vertex. + * + * @function Phaser.Geom.Triangle.BuildRight + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param {number} y - The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param {number} width - The length of the side which is to the left or to the right of the right angle. + * @param {number} height - The length of the side which is above or below the right angle. If not given, defaults to the value of `width`. + * + * @return {Phaser.Geom.Triangle} The constructed right Triangle. + */ +var BuildRight = function (x, y, width, height) +{ + if (height === undefined) { height = width; } + + // 90 degree angle + var x1 = x; + var y1 = y; + + var x2 = x; + var y2 = y - height; + + var x3 = x + width; + var y3 = y; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildRight; + + +/***/ }, + +/***/ 23707 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Centroid = __webpack_require__(97523); +var Offset = __webpack_require__(13584); + +/** + * @callback CenterFunction + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to return the center coordinates of. + * + * @return {Phaser.Math.Vector2} The center point of the Triangle according to the function. + */ + +/** + * Positions the Triangle so that it is centered on the given coordinates. + * + * @function Phaser.Geom.Triangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to be positioned. + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {CenterFunction} [centerFunc] - The function used to center the triangle. Defaults to Centroid centering. + * + * @return {Phaser.Geom.Triangle} The Triangle that was centered. + */ +var CenterOn = function (triangle, x, y, centerFunc) +{ + if (centerFunc === undefined) { centerFunc = Centroid; } + + // Get the center of the triangle + var center = centerFunc(triangle); + + // Difference + var diffX = x - center.x; + var diffY = y - center.y; + + return Offset(triangle, diffX, diffY); +}; + +module.exports = CenterOn; + + +/***/ }, + +/***/ 97523 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Calculates the position of a Triangle's centroid, which is also its center of mass (center of gravity). + * + * The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio. + * + * @function Phaser.Geom.Triangle.Centroid + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to use. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the coordinates in. + * + * @return {Phaser.Math.Vector2} The `out` object with modified `x` and `y` properties, or a new Vector2 if none was provided. + */ +var Centroid = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } + + out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; + out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; + + return out; +}; + +module.exports = Centroid; + + +/***/ }, + +/***/ 24951 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. + * + * @function det + * @private + * @since 3.0.0 + * + * @param {number} m00 - The [0,0] entry of the matrix. + * @param {number} m01 - The [0,1] entry of the matrix. + * @param {number} m10 - The [1,0] entry of the matrix. + * @param {number} m11 - The [1,1] entry of the matrix. + * + * @return {number} the determinant. + */ +function det (m00, m01, m10, m11) +{ + return (m00 * m11) - (m01 * m10); +} + +/** + * Computes the circumcenter of a triangle. The circumcenter is the centre of + * the circumcircle, the unique circle that passes through all three vertices of + * the triangle. It is also the common intersection point of the perpendicular + * bisectors of the sides of the triangle, and is the only point which has equal + * distance to all three vertices of the triangle. + * + * Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html + * + * @function Phaser.Geom.Triangle.CircumCenter + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the circumcenter of. + * @param {Phaser.Math.Vector2} [out] - The Vector2 object to store the position in. If not given, a new Vector2 instance is created. + * + * @return {Phaser.Math.Vector2} A Vector2 object holding the coordinates of the circumcenter of the Triangle. + */ +var CircumCenter = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } + + var cx = triangle.x3; + var cy = triangle.y3; + + var ax = triangle.x1 - cx; + var ay = triangle.y1 - cy; + + var bx = triangle.x2 - cx; + var by = triangle.y2 - cy; + + var denom = 2 * det(ax, ay, bx, by); + var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); + var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); + + out.x = cx - numx / denom; + out.y = cy + numy / denom; + + return out; +}; + +module.exports = CircumCenter; + + +/***/ }, + +/***/ 85614 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circle = __webpack_require__(96503); + +/** + * Finds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices. + * + * Adapted from https://gist.github.com/mutoo/5617691 + * + * @function Phaser.Geom.Triangle.CircumCircle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to use as input. + * @param {Phaser.Geom.Circle} [out] - An optional Circle to store the result in. + * + * @return {Phaser.Geom.Circle} The updated `out` Circle, or a new Circle if none was provided. + */ +var CircumCircle = function (triangle, out) +{ + if (out === undefined) { out = new Circle(); } + + // A + var x1 = triangle.x1; + var y1 = triangle.y1; + + // B + var x2 = triangle.x2; + var y2 = triangle.y2; + + // C + var x3 = triangle.x3; + var y3 = triangle.y3; + + var A = x2 - x1; + var B = y2 - y1; + var C = x3 - x1; + var D = y3 - y1; + var E = A * (x1 + x2) + B * (y1 + y2); + var F = C * (x1 + x3) + D * (y1 + y3); + var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); + + var dx; + var dy; + + // If the points of the triangle are collinear, then just find the + // extremes and use the midpoint as the center of the circumcircle. + + if (Math.abs(G) < 0.000001) + { + var minX = Math.min(x1, x2, x3); + var minY = Math.min(y1, y2, y3); + dx = (Math.max(x1, x2, x3) - minX) * 0.5; + dy = (Math.max(y1, y2, y3) - minY) * 0.5; + + out.x = minX + dx; + out.y = minY + dy; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + else + { + out.x = (D * E - B * F) / G; + out.y = (A * F - C * E) / G; + dx = out.x - x1; + dy = out.y - y1; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + + return out; +}; + +module.exports = CircumCircle; + + +/***/ }, + +/***/ 74422 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Triangle = __webpack_require__(16483); + +/** + * Clones a Triangle object. + * + * @function Phaser.Geom.Triangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} source - The Triangle to clone. + * + * @return {Phaser.Geom.Triangle} A new Triangle identical to the given one but separate from it. + */ +var Clone = function (source) +{ + return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = Clone; + + +/***/ }, + +/***/ 10690 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +/** + * Checks if a point (as a pair of coordinates) is inside a Triangle's bounds. + * + * @function Phaser.Geom.Triangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is inside the Triangle, otherwise `false`. + */ +var Contains = function (triangle, x, y) +{ + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var v2x = x - triangle.x1; + var v2y = y - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot02 = (v0x * v2x) + (v0y * v2y); + var dot11 = (v1x * v1x) + (v1y * v1y); + var dot12 = (v1x * v2x) + (v1y * v2y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + return (u >= 0 && v >= 0 && (u + v < 1)); +}; + +module.exports = Contains; + + +/***/ }, + +/***/ 48653 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Filters an array of point-like objects to only those contained within a triangle. + * + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). + * + * @function Phaser.Geom.Triangle.ContainsArray + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle that the points are being checked in. + * @param {Phaser.Math.Vector2[]} points - An array of Vector2 objects to check if they are within the triangle. + * @param {boolean} [returnFirst=false] - If `true`, return an array containing only the first point found that is within the triangle. + * @param {array} [out] - If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. + * + * @return {Phaser.Math.Vector2[]} An array containing all the points from `points` that are within the triangle, if an array was provided as `out`, points will be appended to that array and it will also be returned here. + */ +var ContainsArray = function (triangle, points, returnFirst, out) +{ + if (returnFirst === undefined) { returnFirst = false; } + if (out === undefined) { out = []; } + + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot11 = (v1x * v1x) + (v1y * v1y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + + var u; + var v; + var v2x; + var v2y; + var dot02; + var dot12; + + var x1 = triangle.x1; + var y1 = triangle.y1; + + for (var i = 0; i < points.length; i++) + { + v2x = points[i].x - x1; + v2y = points[i].y - y1; + + dot02 = (v0x * v2x) + (v0y * v2y); + dot12 = (v1x * v2x) + (v1y * v2y); + + u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + if (u >= 0 && v >= 0 && (u + v < 1)) + { + out.push({ x: points[i].x, y: points[i].y }); + + if (returnFirst) + { + break; + } + } + } + + return out; +}; + +module.exports = ContainsArray; + + +/***/ }, + +/***/ 96006 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Contains = __webpack_require__(10690); + +/** + * Tests if a triangle contains a point. + * + * @function Phaser.Geom.Triangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle. + * @param {Phaser.Math.Vector2} vec - The Vector2 point to test if it's within the triangle. + * + * @return {boolean} `true` if the point is within the triangle, otherwise `false`. + */ +var ContainsPoint = function (triangle, vec) +{ + return Contains(triangle, vec.x, vec.y); +}; + +module.exports = ContainsPoint; + + +/***/ }, + +/***/ 71326 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Copy the values of one Triangle to a destination Triangle. + * + * @function Phaser.Geom.Triangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [dest,$return] + * + * @param {Phaser.Geom.Triangle} source - The source Triangle to copy the values from. + * @param {Phaser.Geom.Triangle} dest - The destination Triangle to copy the values to. + * + * @return {Phaser.Geom.Triangle} The destination Triangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = CopyFrom; + + +/***/ }, + +/***/ 71694 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Decomposes a Triangle into an array of its points. + * + * @function Phaser.Geom.Triangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to decompose. + * @param {array} [out] - An array to store the points into. + * + * @return {array} The provided `out` array, or a new array if none was provided, with three objects with `x` and `y` properties representing each point of the Triangle appended to it. + */ +var Decompose = function (triangle, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: triangle.x1, y: triangle.y1 }); + out.push({ x: triangle.x2, y: triangle.y2 }); + out.push({ x: triangle.x3, y: triangle.y3 }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }, + +/***/ 33522 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns true if two triangles have the same coordinates. + * + * @function Phaser.Geom.Triangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The first triangle to check. + * @param {Phaser.Geom.Triangle} toCompare - The second triangle to check. + * + * @return {boolean} `true` if the two given triangles have the exact same coordinates, otherwise `false`. + */ +var Equals = function (triangle, toCompare) +{ + return ( + triangle.x1 === toCompare.x1 && + triangle.y1 === toCompare.y1 && + triangle.x2 === toCompare.x2 && + triangle.y2 === toCompare.y2 && + triangle.x3 === toCompare.x3 && + triangle.y3 === toCompare.y3 + ); +}; + +module.exports = Equals; + + +/***/ }, + +/***/ 20437 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); +var Length = __webpack_require__(35001); + +/** + * Returns a point along the perimeter of a Triangle as a Vector2, based on a normalized position value. + * + * The `position` parameter is a value between 0 and 1, where 0 and 1 both map to the start of + * line A (the first vertex). The point is calculated by traversing the triangle's perimeter in + * order: line A, then line B, then line C. + * + * @function Phaser.Geom.Triangle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the point on its perimeter from. + * @param {number} position - A normalized value between 0 and 1 representing a position along the triangle's perimeter. Both 0 and 1 return the start of line A. + * @param {Phaser.Math.Vector2} [out] - An optional Vector2 point to store the result in. If not given, a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 point containing the coordinates of the position on the triangle's perimeter. + */ +var GetPoint = function (triangle, position, out) +{ + if (out === undefined) { out = new Vector2(); } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + if (position <= 0 || position >= 1) + { + out.x = line1.x1; + out.y = line1.y1; + + return out; + } + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + var p = perimeter * position; + var localPosition = 0; + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }, + +/***/ 80672 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Length = __webpack_require__(35001); +var Vector2 = __webpack_require__(26099); + +/** + * Returns an array of evenly spaced points on the perimeter of a Triangle. + * + * The points are placed along the triangle's three edges in order (A, B, then C), + * with their positions calculated proportionally based on the total perimeter length. + * + * @function Phaser.Geom.Triangle.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the points from. + * @param {number} quantity - The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param {number} stepRate - If `quantity` is 0, the distance in pixels between each returned point along the perimeter. + * @param {Phaser.Math.Vector2[]} [out] - An array to which the points should be appended. + * + * @return {Phaser.Math.Vector2[]} The modified `out` array, or a new array if none was provided. + */ +var GetPoints = function (triangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity && stepRate > 0) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var p = perimeter * (i / quantity); + var localPosition = 0; + + var point = new Vector2(); + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + out.push(point); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }, + +/***/ 39757 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +// The three angle bisectors of a triangle meet in one point called the incenter. +// It is the center of the incircle, the circle inscribed in the triangle. + +function getLength (x1, y1, x2, y2) +{ + var x = x1 - x2; + var y = y1 - y2; + var magnitude = (x * x) + (y * y); + + return Math.sqrt(magnitude); +} + +/** + * Calculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle. + * + * @function Phaser.Geom.Triangle.InCenter + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to find the incenter of. + * @param {Phaser.Math.Vector2} [out] - An optional Vector2 point in which to store the coordinates. + * + * @return {Phaser.Math.Vector2} The incenter of the triangle in a Vector2. + */ +var InCenter = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } + + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + var d1 = getLength(x3, y3, x2, y2); + var d2 = getLength(x1, y1, x3, y3); + var d3 = getLength(x2, y2, x1, y1); + + var p = d1 + d2 + d3; + + out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; + out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; + + return out; +}; + +module.exports = InCenter; + + +/***/ }, + +/***/ 13584 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset. + * + * @function Phaser.Geom.Triangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to move. + * @param {number} x - The horizontal offset (distance) by which to move each point. Can be positive or negative. + * @param {number} y - The vertical offset (distance) by which to move each point. Can be positive or negative. + * + * @return {Phaser.Geom.Triangle} The modified Triangle. + */ +var Offset = function (triangle, x, y) +{ + triangle.x1 += x; + triangle.y1 += y; + + triangle.x2 += x; + triangle.y2 += y; + + triangle.x3 += x; + triangle.y3 += y; + + return triangle; +}; + +module.exports = Offset; + + +/***/ }, + +/***/ 1376 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Length = __webpack_require__(35001); + +/** + * Gets the length of the perimeter of the given triangle. + * Calculated by adding together the length of each of the three sides. + * + * @function Phaser.Geom.Triangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the length from. + * + * @return {number} The length of the Triangle. + */ +var Perimeter = function (triangle) +{ + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + return (Length(line1) + Length(line2) + Length(line3)); +}; + +module.exports = Perimeter; + + +/***/ }, + +/***/ 90260 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Vector2 = __webpack_require__(26099); + +/** + * Returns a random Point from within the area of the given Triangle. + * + * @function Phaser.Geom.Triangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get a random point from. + * @param {Phaser.Math.Vector2} [out] - The Vector2 point object to store the position in. If not given, a new Vector2 instance is created. + * + * @return {Phaser.Math.Vector2} A Vector2 point object holding the coordinates of a random position within the Triangle. + */ +var Random = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } + + // Basis vectors + var ux = triangle.x2 - triangle.x1; + var uy = triangle.y2 - triangle.y1; + + var vx = triangle.x3 - triangle.x1; + var vy = triangle.y3 - triangle.y1; + + // Random point within the unit square + var r = Math.random(); + var s = Math.random(); + + // Point outside the triangle? Remap it. + if (r + s >= 1) + { + r = 1 - r; + s = 1 - s; + } + + out.x = triangle.x1 + ((ux * r) + (vx * s)); + out.y = triangle.y1 + ((uy * r) + (vy * s)); + + return out; +}; + +module.exports = Random; + + +/***/ }, + +/***/ 52172 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RotateAroundXY = __webpack_require__(99614); +var InCenter = __webpack_require__(39757); + +/** + * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. + * + * @function Phaser.Geom.Triangle.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to rotate. + * @param {number} angle - The angle by which to rotate the Triangle, in radians. + * + * @return {Phaser.Geom.Triangle} The rotated Triangle. + */ +var Rotate = function (triangle, angle) +{ + var point = InCenter(triangle); + + return RotateAroundXY(triangle, point.x, point.y, angle); +}; + +module.exports = Rotate; + + +/***/ }, + +/***/ 49907 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var RotateAroundXY = __webpack_require__(99614); + +/** + * Rotates a Triangle at a certain angle about a given Vector2 point. + * + * @function Phaser.Geom.Triangle.RotateAroundPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to rotate. + * @param {Phaser.Math.Vector2} point - The Vector2 point to rotate the Triangle around. + * @param {number} angle - The angle by which to rotate the Triangle, in radians. + * + * @return {Phaser.Geom.Triangle} The rotated Triangle. + */ +var RotateAroundPoint = function (triangle, point, angle) +{ + return RotateAroundXY(triangle, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }, + +/***/ 99614 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Rotates an entire Triangle at a given angle about a specific point. + * + * @function Phaser.Geom.Triangle.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to rotate. + * @param {number} x - The X coordinate of the point to rotate the Triangle about. + * @param {number} y - The Y coordinate of the point to rotate the Triangle about. + * @param {number} angle - The angle by which to rotate the Triangle, in radians. + * + * @return {Phaser.Geom.Triangle} The rotated Triangle. + */ +var RotateAroundXY = function (triangle, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = triangle.x1 - x; + var ty = triangle.y1 - y; + + triangle.x1 = tx * c - ty * s + x; + triangle.y1 = tx * s + ty * c + y; + + tx = triangle.x2 - x; + ty = triangle.y2 - y; + + triangle.x2 = tx * c - ty * s + x; + triangle.y2 = tx * s + ty * c + y; + + tx = triangle.x3 - x; + ty = triangle.y3 - y; + + triangle.x3 = tx * c - ty * s + x; + triangle.y3 = tx * s + ty * c + y; + + return triangle; +}; + +module.exports = RotateAroundXY; + + +/***/ }, + +/***/ 16483 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(10690); +var GetPoint = __webpack_require__(20437); +var GetPoints = __webpack_require__(80672); +var GEOM_CONST = __webpack_require__(23777); +var Line = __webpack_require__(23031); +var Random = __webpack_require__(90260); + +/** + * @classdesc + * A Triangle is a closed polygon defined by three vertices in 2D space, useful for hit testing, + * defining spawn or trigger regions, and geometric calculations. It is a geometry object only — + * not a Game Object — and cannot be rendered directly. To draw a Triangle to the screen, pass it + * to a Graphics Game Object's `strokeTriangleShape` or `fillTriangleShape` method. + * + * The three vertices are stored as coordinate pairs (`x1`,`y1`), (`x2`,`y2`), and (`x3`,`y3`). + * All coordinates default to `0` if not provided. + * + * @class Triangle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. + */ +var Triangle = new Class({ + + initialize: + + function Triangle (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + /** + * The geometry constant type of this object: `GEOM_CONST.TRIANGLE`. + * Used for fast type comparisons. + * + * @name Phaser.Geom.Triangle#type + * @type {number} + * @readonly + * @since 3.19.0 + */ + this.type = GEOM_CONST.TRIANGLE; + + /** + * `x` coordinate of the first point. + * + * @name Phaser.Geom.Triangle#x1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * `y` coordinate of the first point. + * + * @name Phaser.Geom.Triangle#y1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * `x` coordinate of the second point. + * + * @name Phaser.Geom.Triangle#x2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * `y` coordinate of the second point. + * + * @name Phaser.Geom.Triangle#y2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y2 = y2; + + /** + * `x` coordinate of the third point. + * + * @name Phaser.Geom.Triangle#x3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x3 = x3; + + /** + * `y` coordinate of the third point. + * + * @name Phaser.Geom.Triangle#y3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y3 = y3; + }, + + /** + * Checks whether a given point lies within the triangle. + * + * @method Phaser.Geom.Triangle#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to check. + * @param {number} y - The y coordinate of the point to check. + * + * @return {boolean} `true` if the coordinate pair is within the triangle, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a point at a given normalized position along the perimeter of the triangle. + * + * @method Phaser.Geom.Triangle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} position - Position as float within `0` and `1`. `0` equals the first point. + * @param {Phaser.Math.Vector2} [output] - Optional Vector2 point that the calculated point will be written to. + * + * @return {Phaser.Math.Vector2} Calculated Vector2 that represents the requested position. It is the same as `output` when this parameter has been given. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Calculates a list of evenly distributed points along the perimeter of the triangle. Either pass the number of points to generate (`quantity`) or the distance between consecutive points (`stepRate`). + * + * @method Phaser.Geom.Triangle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2[]} O - [output,$return] + * + * @param {number} quantity - Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param {number} [stepRate] - Distance between two points. Will only be used when `quantity` is falsey. + * @param {Phaser.Math.Vector2[]} [output] - Optional array of Vector2 points for writing the calculated points into. Otherwise a new array will be created. + * + * @return {Phaser.Math.Vector2[]} Returns a list of calculated `Vector2` instances or the filled array passed as parameter `output`. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a random point from within the area of the triangle. + * + * @method Phaser.Geom.Triangle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [point,$return] + * + * @param {Phaser.Math.Vector2} [vec] - Optional Vector2 point that will be modified. Otherwise a new one will be created. + * + * @return {Phaser.Math.Vector2} Random Vector2. When parameter `vec` has been provided it will be returned. + */ + getRandomPoint: function (vec) + { + return Random(this, vec); + }, + + /** + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. + * + * @method Phaser.Geom.Triangle#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. + * + * @return {this} This Triangle object. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + this.x3 = x3; + this.y3 = y3; + + return this; + }, + + /** + * Returns a Line object that corresponds to Line A of this Triangle, running from vertex 1 (`x1`, `y1`) to vertex 2 (`x2`, `y2`). + * + * @method Phaser.Geom.Triangle#getLineA + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line A of this Triangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x1, this.y1, this.x2, this.y2); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line B of this Triangle, running from vertex 2 (`x2`, `y2`) to vertex 3 (`x3`, `y3`). + * + * @method Phaser.Geom.Triangle#getLineB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line B of this Triangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x2, this.y2, this.x3, this.y3); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line C of this Triangle, running from vertex 3 (`x3`, `y3`) back to vertex 1 (`x1`, `y1`), closing the shape. + * + * @method Phaser.Geom.Triangle#getLineC + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line C of this Triangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x3, this.y3, this.x1, this.y1); + + return line; + }, + + /** + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + * + * @name Phaser.Geom.Triangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 <= this.x2 && this.x1 <= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 <= this.x1 && this.x2 <= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + * + * @name Phaser.Geom.Triangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 >= this.x2 && this.x1 >= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 >= this.x1 && this.x2 >= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + * + * @name Phaser.Geom.Triangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 <= this.y2 && this.y1 <= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 <= this.y1 && this.y2 <= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + }, + + /** + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + * + * @name Phaser.Geom.Triangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 >= this.y2 && this.y1 >= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 >= this.y1 && this.y2 >= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + } + +}); + +module.exports = Triangle; + + +/***/ }, + +/***/ 84435 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Triangle = __webpack_require__(16483); + +Triangle.Area = __webpack_require__(41658); +Triangle.BuildEquilateral = __webpack_require__(39208); +Triangle.BuildFromPolygon = __webpack_require__(39545); +Triangle.BuildRight = __webpack_require__(90301); +Triangle.CenterOn = __webpack_require__(23707); +Triangle.Centroid = __webpack_require__(97523); +Triangle.CircumCenter = __webpack_require__(24951); +Triangle.CircumCircle = __webpack_require__(85614); +Triangle.Clone = __webpack_require__(74422); +Triangle.Contains = __webpack_require__(10690); +Triangle.ContainsArray = __webpack_require__(48653); +Triangle.ContainsPoint = __webpack_require__(96006); +Triangle.CopyFrom = __webpack_require__(71326); +Triangle.Decompose = __webpack_require__(71694); +Triangle.Equals = __webpack_require__(33522); +Triangle.GetPoint = __webpack_require__(20437); +Triangle.GetPoints = __webpack_require__(80672); +Triangle.InCenter = __webpack_require__(39757); +Triangle.Perimeter = __webpack_require__(1376); +Triangle.Offset = __webpack_require__(13584); +Triangle.Random = __webpack_require__(90260); +Triangle.Rotate = __webpack_require__(52172); +Triangle.RotateAroundPoint = __webpack_require__(49907); +Triangle.RotateAroundXY = __webpack_require__(99614); + +module.exports = Triangle; + + +/***/ }, + +/***/ 74457 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Creates a new Interactive Object. + * + * An Interactive Object is a plain data object that stores all of the input-related state for + * a Game Object. This includes its hit area geometry, drag state, local pointer coordinates, + * and references to the camera and any drop zone target. It is not a class instance, but a + * plain object literal returned by this function. + * + * This is called automatically by the Input Manager when you enable a Game Object for input. + * + * The resulting Interactive Object is mapped to the Game Object's `input` property. + * + * @function Phaser.Input.CreateInteractiveObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound. + * @param {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. + * @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests. + * + * @return {Phaser.Types.Input.InteractiveObject} The new Interactive Object. + */ +var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback) +{ + return { + + gameObject: gameObject, + + enabled: true, + draggable: false, + dropZone: false, + cursor: false, + + target: null, + + camera: null, + + hitArea: hitArea, + hitAreaCallback: hitAreaCallback, + hitAreaDebug: null, + + // Has the dev specified their own shape, or is this bound to the texture size? + customHitArea: false, + + localX: 0, + localY: 0, + + // 0 = Not being dragged + // 1 = Being checked for dragging + // 2 = Being dragged + dragState: 0, + + dragStartX: 0, + dragStartY: 0, + dragStartXGlobal: 0, + dragStartYGlobal: 0, + dragStartCamera: null, + + dragX: 0, + dragY: 0 + + }; +}; + +module.exports = CreateInteractiveObject; + + +/***/ }, + +/***/ 84409 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Creates a new Pixel Perfect Handler function. + * + * Pixel perfect hit detection tests the alpha value of the specific pixel at the point + * of interaction on a Game Object's texture, rather than relying solely on its bounding + * box or hit area geometry. This allows fully transparent regions of a sprite to be + * correctly ignored during pointer and overlap checks, at the cost of a texture lookup + * per test. + * + * Access via `InputPlugin.makePixelPerfect` rather than calling it directly. + * + * @function Phaser.Input.CreatePixelPerfectHandler + * @since 3.10.0 + * + * @param {Phaser.Textures.TextureManager} textureManager - A reference to the Texture Manager. + * @param {number} alphaTolerance - The alpha level that the pixel must be at or above to be counted as a successful interaction. + * + * @return {function} The new Pixel Perfect Handler function. + */ +var CreatePixelPerfectHandler = function (textureManager, alphaTolerance) +{ + return function (hitArea, x, y, gameObject) + { + var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.name); + + return (alpha && alpha >= alphaTolerance); + }; +}; + +module.exports = CreatePixelPerfectHandler; + + +/***/ }, + +/***/ 7003 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(93301); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(8214); +var GameEvents = __webpack_require__(8443); +var Keyboard = __webpack_require__(78970); +var Mouse = __webpack_require__(85098); +var Pointer = __webpack_require__(42515); +var Touch = __webpack_require__(36210); +var TransformMatrix = __webpack_require__(61340); +var TransformXY = __webpack_require__(85955); + +/** + * @classdesc + * The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. + * + * Based on the Game Config it will create handlers for mouse and touch support. + * + * Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. + * + * It then manages the events, pointer creation and general hit test related operations. + * + * You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods + * should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible + * for dealing with all input events for a Scene. + * + * @class InputManager + * @memberof Phaser.Input + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Game instance that owns the Input Manager. + * @param {object} config - The Input Configuration object, as set in the Game Config. + */ +var InputManager = new Class({ + + initialize: + + function InputManager (game, config) + { + /** + * The Game instance that owns the Input Manager. + * A Game only maintains one instance of the Input Manager at any time. + * + * @name Phaser.Input.InputManager#game + * @type {Phaser.Game} + * @readonly + * @since 3.0.0 + */ + this.game = game; + + /** + * A reference to the global Game Scale Manager. + * Used for all bounds checks and pointer scaling. + * + * @name Phaser.Input.InputManager#scaleManager + * @type {Phaser.Scale.ScaleManager} + * @since 3.16.0 + */ + this.scaleManager; + + /** + * The Canvas that is used for all DOM event input listeners. + * + * @name Phaser.Input.InputManager#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas; + + /** + * The Game Configuration object, as set during the game boot. + * + * @name Phaser.Input.InputManager#config + * @type {Phaser.Core.Config} + * @since 3.0.0 + */ + this.config = config; + + /** + * If set, the Input Manager will run its update loop every frame. + * + * @name Phaser.Input.InputManager#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * The Event Emitter instance that the Input Manager uses to emit events from. + * + * @name Phaser.Input.InputManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * Are any mouse or touch pointers currently over the game canvas? + * This is updated automatically by the canvas over and out handlers. + * + * @name Phaser.Input.InputManager#isOver + * @type {boolean} + * @readonly + * @since 3.16.0 + */ + this.isOver = true; + + /** + * The default CSS cursor to be used when interacting with your game. + * + * See the `setDefaultCursor` method for more details. + * + * @name Phaser.Input.InputManager#defaultCursor + * @type {string} + * @since 3.10.0 + */ + this.defaultCursor = ''; + + /** + * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. + * + * @name Phaser.Input.InputManager#keyboard + * @type {?Phaser.Input.Keyboard.KeyboardManager} + * @since 3.16.0 + */ + this.keyboard = (config.inputKeyboard) ? new Keyboard(this) : null; + + /** + * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + * + * @name Phaser.Input.InputManager#mouse + * @type {?Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = (config.inputMouse) ? new Mouse(this) : null; + + /** + * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. + * + * @name Phaser.Input.InputManager#touch + * @type {Phaser.Input.Touch.TouchManager} + * @since 3.0.0 + */ + this.touch = (config.inputTouch) ? new Touch(this) : null; + + /** + * An array of Pointers that have been added to the game. + * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. + * + * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, + * or set the `input.activePointers` property in the Game Config. + * + * @name Phaser.Input.InputManager#pointers + * @type {Phaser.Input.Pointer[]} + * @since 3.10.0 + */ + this.pointers = []; + + /** + * The number of touch objects activated and being processed each update. + * + * You can change this by either calling `addPointer` at run-time, or by + * setting the `input.activePointers` property in the Game Config. + * + * @name Phaser.Input.InputManager#pointersTotal + * @type {number} + * @readonly + * @since 3.10.0 + */ + this.pointersTotal = config.inputActivePointers; + + for (var i = 0; i <= this.pointersTotal; i++) + { + var pointer = new Pointer(this, i); + + pointer.smoothFactor = config.inputSmoothFactor; + + this.pointers.push(pointer); + } + + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + * + * @name Phaser.Input.InputManager#mousePointer + * @type {?Phaser.Input.Pointer} + * @since 3.10.0 + */ + this.mousePointer = (config.inputMouse) ? this.pointers[0] : null; + + /** + * The most recently active Pointer object. + * + * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. + * + * If your game doesn't need to support multi-touch then you can safely use this property in all of your game + * code and it will adapt to be either the mouse or the touch, based on device. + * + * @name Phaser.Input.InputManager#activePointer + * @type {Phaser.Input.Pointer} + * @since 3.0.0 + */ + this.activePointer = this.pointers[0]; + + /** + * If the top-most Scene in the Scene List receives an input it will stop input from + * propagating any lower down the scene list, i.e. if you have a UI Scene at the top + * and click something on it, that click will not then be passed down to any other + * Scene below. Disable this to have input events passed through all Scenes, all the time. + * + * @name Phaser.Input.InputManager#globalTopOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.globalTopOnly = true; + + /** + * The time this Input Manager was last updated. + * This value is populated by the Game Step each frame. + * + * @name Phaser.Input.InputManager#time + * @type {number} + * @readonly + * @since 3.16.2 + */ + this.time = 0; + + /** + * A re-cycled point-like object to store hit test values in. + * + * @name Phaser.Input.InputManager#_tempPoint + * @type {{x:number, y:number}} + * @private + * @since 3.0.0 + */ + this._tempPoint = { x: 0, y: 0 }; + + /** + * A re-cycled array to store hit results in. + * + * @name Phaser.Input.InputManager#_tempHitTest + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempHitTest = []; + + /** + * A re-cycled matrix used in hit test calculations. + * + * @name Phaser.Input.InputManager#_tempMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.4.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * A re-cycled matrix used in hit test calculations. + * + * @name Phaser.Input.InputManager#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * An internal private var that records Scenes aborting event processing. + * + * @name Phaser.Input.InputManager#_tempSkip + * @type {boolean} + * @private + * @since 3.18.0 + */ + this._tempSkip = false; + + /** + * An internal private array that avoids needing to create a new array on every DOM mouse event. + * + * @name Phaser.Input.InputManager#mousePointerContainer + * @type {Phaser.Input.Pointer[]} + * @private + * @since 3.18.0 + */ + this.mousePointerContainer = [ this.mousePointer ]; + + game.events.once(GameEvents.BOOT, this.boot, this); + }, + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now. + * + * @method Phaser.Input.InputManager#boot + * @protected + * @fires Phaser.Input.Events#MANAGER_BOOT + * @since 3.0.0 + */ + boot: function () + { + var game = this.game; + var events = game.events; + + this.canvas = game.canvas; + + this.scaleManager = game.scale; + + this.events.emit(Events.MANAGER_BOOT); + + events.on(GameEvents.PRE_RENDER, this.preRender, this); + + events.once(GameEvents.DESTROY, this.destroy, this); + }, + + /** + * Internal canvas state change, called automatically by the Mouse Manager. + * + * @method Phaser.Input.InputManager#setCanvasOver + * @fires Phaser.Input.Events#GAME_OVER + * @private + * @since 3.16.0 + * + * @param {(MouseEvent|TouchEvent)} event - The DOM Event. + */ + setCanvasOver: function (event) + { + this.isOver = true; + + this.events.emit(Events.GAME_OVER, event); + }, + + /** + * Internal canvas state change, called automatically by the Mouse Manager. + * + * @method Phaser.Input.InputManager#setCanvasOut + * @fires Phaser.Input.Events#GAME_OUT + * @private + * @since 3.16.0 + * + * @param {(MouseEvent|TouchEvent)} event - The DOM Event. + */ + setCanvasOut: function (event) + { + this.isOver = false; + + this.events.emit(Events.GAME_OUT, event); + }, + + /** + * Internal update, called automatically by the Game Step right at the start. + * + * @method Phaser.Input.InputManager#preRender + * @private + * @since 3.18.0 + */ + preRender: function () + { + var time = this.game.loop.now; + var delta = this.game.loop.delta; + var scenes = this.game.scene.getScenes(true, true); + + this.time = time; + + this.events.emit(Events.MANAGER_UPDATE); + + for (var i = 0; i < scenes.length; i++) + { + var scene = scenes[i]; + + if (scene.sys.input && scene.sys.input.updatePoll(time, delta) && this.globalTopOnly) + { + // If the Scene returns true, it means it captured some input that no other Scene should get, so we bail out + return; + } + } + }, + + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * + * @method Phaser.Input.InputManager#setDefaultCursor + * @since 3.10.0 + * + * @param {string} cursor - The CSS to be used when setting the default cursor. + */ + setDefaultCursor: function (cursor) + { + this.defaultCursor = cursor; + + if (this.canvas.style.cursor !== cursor) + { + this.canvas.style.cursor = cursor; + } + }, + + /** + * Called by the InputPlugin when processing over and out events. + * + * Tells the Input Manager to set a custom cursor during its postUpdate step. + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * + * @method Phaser.Input.InputManager#setCursor + * @private + * @since 3.10.0 + * + * @param {Phaser.Types.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method. + */ + setCursor: function (interactiveObject) + { + if (interactiveObject.cursor) + { + this.canvas.style.cursor = interactiveObject.cursor; + } + }, + + /** + * Called by the InputPlugin when processing over and out events. + * + * Tells the Input Manager to clear the hand cursor, if set, during its postUpdate step. + * + * @method Phaser.Input.InputManager#resetCursor + * @private + * @since 3.10.0 + * + * @param {Phaser.Types.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method. Pass `null` if you just want to set the force value. + * @param {boolean} [forceReset=false] - Should the reset happen regardless of the object's cursor state? Default false. + */ + resetCursor: function (interactiveObject, forceReset) + { + if ((forceReset || (interactiveObject && interactiveObject.cursor)) && this.canvas) + { + this.canvas.style.cursor = this.defaultCursor; + } + }, + + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * + * @method Phaser.Input.InputManager#addPointer + * @since 3.10.0 + * + * @param {number} [quantity=1] The number of new Pointers to create. A maximum of 10 is allowed in total. + * + * @return {Phaser.Input.Pointer[]} An array containing all of the new Pointer objects that were created. + */ + addPointer: function (quantity) + { + if (quantity === undefined) { quantity = 1; } + + var output = []; + + if (this.pointersTotal + quantity > 10) + { + quantity = 10 - this.pointersTotal; + } + + for (var i = 0; i < quantity; i++) + { + var id = this.pointers.length; + + var pointer = new Pointer(this, id); + + pointer.smoothFactor = this.config.inputSmoothFactor; + + this.pointers.push(pointer); + + this.pointersTotal++; + + output.push(pointer); + } + + return output; + }, + + /** + * Internal method that gets a list of all the active Input Plugins in the game + * and updates each of them in turn, in reverse order (top to bottom), to allow + * for DOM top-level event handling simulation. + * + * @method Phaser.Input.InputManager#updateInputPlugins + * @since 3.16.0 + * + * @param {number} type - The type of event to process. + * @param {Phaser.Input.Pointer[]} pointers - An array of Pointers on which the event occurred. + */ + updateInputPlugins: function (type, pointers) + { + var scenes = this.game.scene.getScenes(false, true); + + this._tempSkip = false; + + for (var i = 0; i < scenes.length; i++) + { + var scene = scenes[i]; + + if (scene.sys.input) + { + var capture = scene.sys.input.update(type, pointers); + + if ((capture && this.globalTopOnly) || this._tempSkip) + { + // If the Scene returns true, or called stopPropagation, it means it captured some input that no other Scene should get, so we bail out + return; + } + } + } + }, + + // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element) + // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element + // event.changedTouches = the touches that CHANGED in this event, not the total number of them + + /** + * Processes a touch start event, as passed in by the TouchManager. + * + * @method Phaser.Input.InputManager#onTouchStart + * @private + * @since 3.18.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + onTouchStart: function (event) + { + var pointers = this.pointers; + var changed = []; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < pointers.length; i++) + { + var pointer = pointers[i]; + + if (!pointer.active) + { + pointer.touchstart(changedTouch, event); + + this.activePointer = pointer; + + changed.push(pointer); + + break; + } + } + } + + this.updateInputPlugins(CONST.TOUCH_START, changed); + }, + + /** + * Processes a touch move event, as passed in by the TouchManager. + * + * @method Phaser.Input.InputManager#onTouchMove + * @private + * @since 3.18.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + onTouchMove: function (event) + { + var pointers = this.pointers; + var changed = []; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < pointers.length; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + var element = document.elementFromPoint(changedTouch.clientX, changedTouch.clientY); + var overCanvas = element === this.canvas; + + if (!this.isOver && overCanvas) + { + this.setCanvasOver(event); + } + else if (this.isOver && !overCanvas) + { + this.setCanvasOut(event); + } + + if (this.isOver) + { + pointer.touchmove(changedTouch, event); + + this.activePointer = pointer; + + changed.push(pointer); + } + + break; + } + } + } + + this.updateInputPlugins(CONST.TOUCH_MOVE, changed); + }, + + // For touch end its a list of the touch points that have been removed from the surface + // https://developer.mozilla.org/en-US/docs/DOM/TouchList + // event.changedTouches = the touches that CHANGED in this event, not the total number of them + + /** + * Processes a touch end event, as passed in by the TouchManager. + * + * @method Phaser.Input.InputManager#onTouchEnd + * @private + * @since 3.18.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + onTouchEnd: function (event) + { + var pointers = this.pointers; + var changed = []; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < pointers.length; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchend(changedTouch, event); + + changed.push(pointer); + + break; + } + } + } + + this.updateInputPlugins(CONST.TOUCH_END, changed); + }, + + /** + * Processes a touch cancel event, as passed in by the TouchManager. + * + * @method Phaser.Input.InputManager#onTouchCancel + * @private + * @since 3.18.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + onTouchCancel: function (event) + { + var pointers = this.pointers; + var changed = []; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < pointers.length; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchcancel(changedTouch, event); + + changed.push(pointer); + + break; + } + } + } + + this.updateInputPlugins(CONST.TOUCH_CANCEL, changed); + }, + + /** + * Processes a mouse down event, as passed in by the MouseManager. + * + * @method Phaser.Input.InputManager#onMouseDown + * @private + * @since 3.18.0 + * + * @param {MouseEvent} event - The native DOM Mouse event. + */ + onMouseDown: function (event) + { + var mousePointer = this.mousePointer; + + mousePointer.down(event); + + mousePointer.updateMotion(); + + this.activePointer = mousePointer; + + this.updateInputPlugins(CONST.MOUSE_DOWN, this.mousePointerContainer); + }, + + /** + * Processes a mouse move event, as passed in by the MouseManager. + * + * @method Phaser.Input.InputManager#onMouseMove + * @private + * @since 3.18.0 + * + * @param {MouseEvent} event - The native DOM Mouse event. + */ + onMouseMove: function (event) + { + var mousePointer = this.mousePointer; + + mousePointer.move(event); + + mousePointer.updateMotion(); + + this.activePointer = mousePointer; + + this.updateInputPlugins(CONST.MOUSE_MOVE, this.mousePointerContainer); + }, + + /** + * Processes a mouse up event, as passed in by the MouseManager. + * + * @method Phaser.Input.InputManager#onMouseUp + * @private + * @since 3.18.0 + * + * @param {MouseEvent} event - The native DOM Mouse event. + */ + onMouseUp: function (event) + { + var mousePointer = this.mousePointer; + + mousePointer.up(event); + + mousePointer.updateMotion(); + + this.activePointer = mousePointer; + + this.updateInputPlugins(CONST.MOUSE_UP, this.mousePointerContainer); + }, + + /** + * Processes a mouse wheel event, as passed in by the MouseManager. + * + * @method Phaser.Input.InputManager#onMouseWheel + * @private + * @since 3.18.0 + * + * @param {WheelEvent} event - The native DOM Wheel event. + */ + onMouseWheel: function (event) + { + var mousePointer = this.mousePointer; + + mousePointer.wheel(event); + + this.activePointer = mousePointer; + + this.updateInputPlugins(CONST.MOUSE_WHEEL, this.mousePointerContainer); + }, + + /** + * Processes a pointer lock change event, as passed in by the MouseManager. + * + * @method Phaser.Input.InputManager#onPointerLockChange + * @fires Phaser.Input.Events#POINTERLOCK_CHANGE + * @private + * @since 3.19.0 + * + * @param {MouseEvent} event - The native DOM Mouse event. + */ + onPointerLockChange: function (event) + { + var isLocked = this.mouse.locked; + + this.mousePointer.locked = isLocked; + + this.events.emit(Events.POINTERLOCK_CHANGE, event, isLocked); + }, + + /** + * Checks if the given Game Object should be considered as a candidate for input or not. + * + * Checks if the Game Object has an input component that is enabled, that it will render, + * and finally, if it has a parent, that the parent parent, or any ancestor, is visible or not. + * + * @method Phaser.Input.InputManager#inputCandidate + * @private + * @since 3.10.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. + * + * @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`. + */ + inputCandidate: function (gameObject, camera) + { + var input = gameObject.input; + + if (!input || !input.enabled || !gameObject.willRender(camera)) + { + return false; + } + + var visible = true; + var parent = gameObject.parentContainer; + + if (parent) + { + do + { + if (!parent.willRender(camera)) + { + visible = false; + break; + } + + parent = parent.parentContainer; + + } while (parent); + } + + return visible; + }, + + /** + * Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects. + * + * The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space + * and used to determine if they fall within the remaining Game Objects hit areas or not. + * + * If nothing is matched an empty array is returned. + * + * This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly. + * + * @method Phaser.Input.InputManager#hitTest + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to test against. + * @param {array} gameObjects - An array of interactive Game Objects to check. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. + * @param {array} [output] - An array to store the results in. If not given, a new empty array is created. + * + * @return {array} An array of the Game Objects that were hit during this hit test. + */ + hitTest: function (pointer, gameObjects, camera, output) + { + if (output === undefined) { output = this._tempHitTest; } + + var tempPoint = this._tempPoint; + + var csx = camera.scrollX; + var csy = camera.scrollY; + + output.length = 0; + + var x = pointer.x; + var y = pointer.y; + + // Stores the world point inside of tempPoint + camera.getWorldPoint(x, y, tempPoint); + + pointer.worldX = tempPoint.x; + pointer.worldY = tempPoint.y; + + var point = { x: 0, y: 0 }; + + var matrix = this._tempMatrix; + var parentMatrix = this._tempMatrix2; + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + // Checks if the Game Object can receive input (isn't being ignored by the camera, invisible, etc) + // and also checks all of its parents, if any + if (!this.inputCandidate(gameObject, camera)) + { + continue; + } + + var px = tempPoint.x + (csx * gameObject.scrollFactorX) - csx; + var py = tempPoint.y + (csy * gameObject.scrollFactorY) - csy; + + if (gameObject.parentContainer) + { + gameObject.getWorldTransformMatrix(matrix, parentMatrix); + + matrix.applyInverse(px, py, point); + } + else + { + TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); + } + + if (this.pointWithinHitArea(gameObject, point.x, point.y)) + { + output.push(gameObject); + } + } + + return output; + }, + + /** + * Checks if the given x and y coordinate are within the hit area of the Game Object. + * + * This method assumes that the coordinate values have already been translated into the space of the Game Object. + * + * If the coordinates are within the hit area they are set into the Game Objects Input `localX` and `localY` properties. + * + * @method Phaser.Input.InputManager#pointWithinHitArea + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object to check against. + * @param {number} x - The translated x coordinate for the hit test. + * @param {number} y - The translated y coordinate for the hit test. + * + * @return {boolean} `true` if the coordinates were inside the Game Objects hit area, otherwise `false`. + */ + pointWithinHitArea: function (gameObject, x, y) + { + // Normalize the origin + x += gameObject.displayOriginX; + y += gameObject.displayOriginY; + + var input = gameObject.input; + + if (input && input.hitAreaCallback(input.hitArea, x, y, gameObject)) + { + input.localX = x; + input.localY = y; + + return true; + } + else + { + return false; + } + }, + + /** + * Checks if the given x and y coordinate are within the hit area of the Interactive Object. + * + * This method assumes that the coordinate values have already been translated into the space of the Interactive Object. + * + * If the coordinates are within the hit area they are set into the Interactive Objects Input `localX` and `localY` properties. + * + * @method Phaser.Input.InputManager#pointWithinInteractiveObject + * @since 3.0.0 + * + * @param {Phaser.Types.Input.InteractiveObject} object - The Interactive Object to check against. + * @param {number} x - The translated x coordinate for the hit test. + * @param {number} y - The translated y coordinate for the hit test. + * + * @return {boolean} `true` if the coordinates were inside the Interactive Object's hit area, otherwise `false`. + */ + pointWithinInteractiveObject: function (object, x, y) + { + if (!object.hitArea) + { + return false; + } + + // Normalize the origin + x += object.gameObject.displayOriginX; + y += object.gameObject.displayOriginY; + + object.localX = x; + object.localY = y; + + return object.hitAreaCallback(object.hitArea, x, y, object); + }, + + /** + * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. + * + * @method Phaser.Input.InputManager#transformPointer + * @since 3.10.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to transform the values for. + * @param {number} pageX - The Page X value. + * @param {number} pageY - The Page Y value. + * @param {boolean} wasMove - Are we transforming the Pointer from a move event, or an up / down event? + */ + transformPointer: function (pointer, pageX, pageY, wasMove) + { + var p0 = pointer.position; + var p1 = pointer.prevPosition; + + // Store previous position + p1.x = p0.x; + p1.y = p0.y; + + // Translate coordinates + var x = this.scaleManager.transformX(pageX); + var y = this.scaleManager.transformY(pageY); + + var a = pointer.smoothFactor; + + if (!wasMove || a === 0) + { + // Set immediately + p0.x = x; + p0.y = y; + } + else + { + // Apply smoothing + p0.x = x * a + p1.x * (1 - a); + p0.y = y * a + p1.y * (1 - a); + } + }, + + /** + * Destroys the Input Manager and all of its systems. + * + * There is no way to recover from doing this. + * + * @method Phaser.Input.InputManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.events.removeAllListeners(); + + this.game.events.off(GameEvents.PRE_RENDER); + + if (this.keyboard) + { + this.keyboard.destroy(); + } + + if (this.mouse) + { + this.mouse.destroy(); + } + + if (this.touch) + { + this.touch.destroy(); + } + + for (var i = 0; i < this.pointers.length; i++) + { + this.pointers[i].destroy(); + } + + this.pointers = []; + this._tempHitTest = []; + this._tempMatrix.destroy(); + this.canvas = null; + this.game = null; + } + +}); + +module.exports = InputManager; + + +/***/ }, + +/***/ 48205 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Circle = __webpack_require__(96503); +var CircleContains = __webpack_require__(87902); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(93301); +var CreateInteractiveObject = __webpack_require__(74457); +var CreatePixelPerfectHandler = __webpack_require__(84409); +var DistanceBetween = __webpack_require__(20339); +var Ellipse = __webpack_require__(8497); +var EllipseContains = __webpack_require__(81154); +var Events = __webpack_require__(8214); +var EventEmitter = __webpack_require__(50792); +var GetFastValue = __webpack_require__(95540); +var GEOM_CONST = __webpack_require__(23777); +var InputPluginCache = __webpack_require__(89639); +var IsPlainObject = __webpack_require__(41212); +var PluginCache = __webpack_require__(37277); +var Rectangle = __webpack_require__(87841); +var RectangleContains = __webpack_require__(37303); +var SceneEvents = __webpack_require__(44594); +var Triangle = __webpack_require__(16483); +var TriangleContains = __webpack_require__(10690); + +/** + * @classdesc + * The Input Plugin belongs to a Scene and handles all input related events and operations for it. + * + * You can access it from within a Scene using `this.input`. + * + * It emits events directly. For example, you can do: + * + * ```javascript + * this.input.on('pointerdown', callback, context); + * ``` + * + * To listen for a pointer down event anywhere on the game canvas. + * + * Game Objects can be enabled for input by calling their `setInteractive` method. After which they + * will directly emit input events: + * + * ```javascript + * var sprite = this.add.sprite(x, y, texture); + * sprite.setInteractive(); + * sprite.on('pointerdown', callback, context); + * ``` + * + * There are lots of game configuration options available relating to input. + * See the [Input Config object]{@linkcode Phaser.Types.Core.InputConfig} for more details, including how to deal with Phaser + * listening for input events outside of the canvas, how to set a default number of pointers, input + * capture settings and more. + * + * Please also see the Input examples and tutorials for further information. + * + * **Incorrect input coordinates with Angular** + * + * If you are using Phaser within Angular, and use nglf or the router, to make the component in which the Phaser game resides + * change state (i.e. appear or disappear) then you'll need to notify the Scale Manager about this, as Angular will mess with + * the DOM in a way in which Phaser can't detect directly. Call `this.scale.updateBounds()` as part of your game init in order + * to refresh the canvas DOM bounds values, which Phaser uses for input point position calculations. + * + * @class InputPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that this Input Plugin is responsible for. + */ +var InputPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function InputPlugin (scene) + { + EventEmitter.call(this); + + /** + * A reference to the Scene that this Input Plugin is responsible for. + * + * @name Phaser.Input.InputPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene Systems class. + * + * @name Phaser.Input.InputPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Systems Settings. + * + * @name Phaser.Input.InputPlugin#settings + * @type {Phaser.Types.Scenes.SettingsObject} + * @since 3.5.0 + */ + this.settings = scene.sys.settings; + + /** + * A reference to the Game Input Manager. + * + * @name Phaser.Input.InputPlugin#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = scene.sys.game.input; + + /** + * Internal event queue used for plugins only. + * + * @name Phaser.Input.InputPlugin#pluginEvents + * @type {Phaser.Events.EventEmitter} + * @private + * @since 3.10.0 + */ + this.pluginEvents = new EventEmitter(); + + /** + * If `true` this Input Plugin will process DOM input events. + * + * @name Phaser.Input.InputPlugin#enabled + * @type {boolean} + * @default true + * @since 3.5.0 + */ + this.enabled = true; + + /** + * A reference to the Scene Display List. This property is set during the `boot` method. + * + * @name Phaser.Input.InputPlugin#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Cameras Manager. This property is set during the `boot` method. + * + * @name Phaser.Input.InputPlugin#cameras + * @type {Phaser.Cameras.Scene2D.CameraManager} + * @since 3.0.0 + */ + this.cameras; + + // Inject the available input plugins into this class + InputPluginCache.install(this); + + /** + * A reference to the Mouse Manager. + * + * This property is only set if Mouse support has been enabled in your Game Configuration file. + * + * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. + * + * @name Phaser.Input.InputPlugin#mouse + * @type {?Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = this.manager.mouse; + + /** + * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * + * @name Phaser.Input.InputPlugin#topOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.topOnly = true; + + /** + * How often should the Pointers be checked? + * + * The value is a time, given in ms, and is the time that must have elapsed between game steps before + * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game + * Objects are currently below it, or being interacted with it. + * + * Pointers will *always* be checked if they have been moved by the user, or press or released. + * + * This property only controls how often they will be polled if they have not been updated. + * You should set this if you want to have Game Objects constantly check against the pointers, even + * if the pointer didn't itself move. + * + * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + * + * @name Phaser.Input.InputPlugin#pollRate + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.pollRate = -1; + + /** + * Internal poll timer value. + * + * @name Phaser.Input.InputPlugin#_pollTimer + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pollTimer = 0; + + var _eventData = { cancelled: false }; + + /** + * Internal event propagation callback container. + * + * @name Phaser.Input.InputPlugin#_eventContainer + * @type {Phaser.Types.Input.EventData} + * @private + * @since 3.13.0 + */ + this._eventContainer = { + stopPropagation: function () + { + _eventData.cancelled = true; + } + }; + + /** + * Internal event propagation data object. + * + * @name Phaser.Input.InputPlugin#_eventData + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventData = _eventData; + + /** + * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. + * + * @name Phaser.Input.InputPlugin#dragDistanceThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragDistanceThreshold = 0; + + /** + * The amount of time, in ms, a pointer has to be held down before it thinks it is dragging. + * + * The default polling rate is to poll only on move so once the time threshold is reached the + * drag event will not start until you move the mouse. If you want it to start immediately + * when the time threshold is reached, you must increase the polling rate by calling + * [setPollAlways]{@linkcode Phaser.Input.InputPlugin#setPollAlways} or + * [setPollRate]{@linkcode Phaser.Input.InputPlugin#setPollRate}. + * + * @name Phaser.Input.InputPlugin#dragTimeThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragTimeThreshold = 0; + + /** + * Used to temporarily store the results of the Hit Test + * + * @name Phaser.Input.InputPlugin#_temp + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._temp = []; + + /** + * Used to temporarily store the results of the Hit Test dropZones + * + * @name Phaser.Input.InputPlugin#_tempZones + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempZones = []; + + /** + * A list of all Game Objects that have been set to be interactive in the Scene this Input Plugin is managing. + * + * @name Phaser.Input.InputPlugin#_list + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._list = []; + + /** + * Objects waiting to be inserted to the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingInsertion + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingInsertion = []; + + /** + * Objects waiting to be removed from the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingRemoval + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingRemoval = []; + + /** + * A list of all Game Objects that have been enabled for dragging. + * + * @name Phaser.Input.InputPlugin#_draggable + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._draggable = []; + + /** + * A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_drag + * @type {{0:Array,1:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array,10:Array}} + * @private + * @since 3.0.0 + */ + this._drag = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [] }; + + /** + * An array containing the drag states for this Scene, indexed by the Pointer ID. + * + * @name Phaser.Input.InputPlugin#_dragState + * @type {number[]} + * @private + * @since 3.16.0 + */ + this._dragState = []; + + /** + * A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_over + * @type {{0:Array,1:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array,10:Array}} + * @private + * @since 3.0.0 + */ + this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [] }; + + /** + * A list of valid DOM event types. + * + * @name Phaser.Input.InputPlugin#_validTypes + * @type {string[]} + * @private + * @since 3.0.0 + */ + this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; + + /** + * Internal property that tracks frame event state. + * + * @name Phaser.Input.InputPlugin#_updatedThisFrame + * @type {boolean} + * @private + * @since 3.18.0 + */ + this._updatedThisFrame = false; + + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Input.InputPlugin#boot + * @fires Phaser.Input.Events#BOOT + * @private + * @since 3.5.1 + */ + boot: function () + { + this.cameras = this.systems.cameras; + + this.displayList = this.systems.displayList; + + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); + + // Registered input plugins listen for this + this.pluginEvents.emit(Events.BOOT); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.Input.InputPlugin#start + * @fires Phaser.Input.Events#START + * @private + * @since 3.5.0 + */ + start: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on(SceneEvents.TRANSITION_START, this.transitionIn, this); + eventEmitter.on(SceneEvents.TRANSITION_OUT, this.transitionOut, this); + eventEmitter.on(SceneEvents.TRANSITION_COMPLETE, this.transitionComplete, this); + eventEmitter.on(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); + + this.manager.events.on(Events.GAME_OUT, this.onGameOut, this); + this.manager.events.on(Events.GAME_OVER, this.onGameOver, this); + + this.enabled = true; + + // Populate the pointer drag states + this._dragState = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + + // Registered input plugins listen for this + this.pluginEvents.emit(Events.START); + }, + + /** + * Game Over handler. + * + * @method Phaser.Input.InputPlugin#onGameOver + * @fires Phaser.Input.Events#GAME_OVER + * @private + * @since 3.16.2 + */ + onGameOver: function (event) + { + if (this.isActive()) + { + this.emit(Events.GAME_OVER, event.timeStamp, event); + } + }, + + /** + * Game Out handler. + * + * @method Phaser.Input.InputPlugin#onGameOut + * @fires Phaser.Input.Events#GAME_OUT + * @private + * @since 3.16.2 + */ + onGameOut: function (event) + { + if (this.isActive()) + { + this.emit(Events.GAME_OUT, event.timeStamp, event); + } + }, + + /** + * The pre-update handler is responsible for checking the pending removal and insertion lists and + * deleting old Game Objects. + * + * @method Phaser.Input.InputPlugin#preUpdate + * @private + * @fires Phaser.Input.Events#PRE_UPDATE + * @since 3.0.0 + */ + preUpdate: function () + { + // Registered input plugins listen for this + this.pluginEvents.emit(Events.PRE_UPDATE); + + var removeList = this._pendingRemoval; + var insertList = this._pendingInsertion; + + var toRemove = removeList.length; + var toInsert = insertList.length; + + if (toRemove === 0 && toInsert === 0) + { + // Quick bail + return; + } + + var current = this._list; + + // Delete old gameObjects + for (var i = 0; i < toRemove; i++) + { + var gameObject = removeList[i]; + + var index = current.indexOf(gameObject); + + if (index > -1) + { + current.splice(index, 1); + + this.clear(gameObject, true); + } + } + + // Clear the removal list + this._pendingRemoval.length = 0; + + // Move pendingInsertion to list (also clears pendingInsertion at the same time) + this._list = current.concat(insertList.splice(0)); + }, + + /** + * Checks to see if the Input Manager, this plugin and the Scene to which it belongs are all active and input enabled. + * + * @method Phaser.Input.InputPlugin#isActive + * @since 3.10.0 + * + * @return {boolean} `true` if the plugin and the Scene it belongs to is active. + */ + isActive: function () + { + return (this.manager && this.manager.enabled && this.enabled && this.scene.sys.canInput()); + }, + + /** + * Sets a custom cursor on the parent canvas element of the game, based on the `cursor` + * setting of the given Interactive Object (i.e. a Sprite). + * + * See the CSS property `cursor` for more information on MDN: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * + * @method Phaser.Input.InputPlugin#setCursor + * @since 3.85.0 + * + * @param {Phaser.Types.Input.InteractiveObject} interactiveObject - The Interactive Object that will set the cursor on the canvas. + */ + setCursor: function (interactiveObject) + { + if (this.manager) + { + this.manager.setCursor(interactiveObject); + } + }, + + /** + * Forces the Input Manager to clear the custom or hand cursor, regardless of the + * interactive state of any Game Objects. + * + * @method Phaser.Input.InputPlugin#resetCursor + * @since 3.85.0 + */ + resetCursor: function () + { + if (this.manager) + { + this.manager.resetCursor(null, true); + } + }, + + /** + * This is called automatically by the Input Manager. + * It emits events for plugins to listen to and also handles polling updates, if enabled. + * + * @method Phaser.Input.InputPlugin#updatePoll + * @since 3.18.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * + * @return {boolean} `true` if the plugin and the Scene it belongs to is active. + */ + updatePoll: function (time, delta) + { + if (!this.isActive()) + { + return false; + } + + // The plugins should update every frame, regardless if there has been + // any DOM input events or not (such as the Gamepad and Keyboard) + this.pluginEvents.emit(Events.UPDATE, time, delta); + + // We can leave now if we've already updated once this frame via the immediate DOM event handlers + if (this._updatedThisFrame) + { + this._updatedThisFrame = false; + + return false; + } + + var i; + var manager = this.manager; + + var pointers = manager.pointers; + + for (i = 0; i < pointers.length; i++) + { + pointers[i].updateMotion(); + } + + // No point going any further if there aren't any interactive objects + if (this._list.length === 0) + { + return false; + } + + var rate = this.pollRate; + + if (rate === -1) + { + return false; + } + else if (rate > 0) + { + this._pollTimer -= delta; + + if (this._pollTimer < 0) + { + // Discard timer diff, we're ready to poll again + this._pollTimer = this.pollRate; + } + else + { + // Not enough time has elapsed since the last poll, so abort now + return false; + } + } + + // We got this far? Then we should poll for movement + var captured = false; + + for (i = 0; i < pointers.length; i++) + { + var total = 0; + + var pointer = pointers[i]; + + // Always reset this array + this._tempZones = []; + + // _temp contains a hit tested and camera culled list of IO objects + this._temp = this.hitTestPointer(pointer); + + this.sortGameObjects(this._temp, pointer); + this.sortDropZones(this._tempZones); + + if (this.topOnly) + { + // Only the top-most one counts now, so safely ignore the rest + if (this._temp.length) + { + this._temp.splice(1); + } + + if (this._tempZones.length) + { + this._tempZones.splice(1); + } + } + + total += this.processOverOutEvents(pointer); + + if (this.getDragState(pointer) === 2) + { + this.processDragThresholdEvent(pointer, time); + } + + if (total > 0) + { + // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame + captured = true; + } + } + + return captured; + }, + + /** + * This method is called when a DOM Event is received by the Input Manager. It handles dispatching the events + * to relevant input enabled Game Objects in this scene. + * + * @method Phaser.Input.InputPlugin#update + * @private + * @fires Phaser.Input.Events#UPDATE + * @since 3.0.0 + * + * @param {number} type - The type of event to process. + * @param {Phaser.Input.Pointer[]} pointers - An array of Pointers on which the event occurred. + * + * @return {boolean} `true` if this Scene has captured the input events from all other Scenes, otherwise `false`. + */ + update: function (type, pointers) + { + if (!this.isActive()) + { + return false; + } + + var captured = false; + + for (var i = 0; i < pointers.length; i++) + { + var total = 0; + var pointer = pointers[i]; + + // Always reset this array + this._tempZones = []; + + // _temp contains a hit tested and camera culled list of IO objects + this._temp = this.hitTestPointer(pointer); + + this.sortGameObjects(this._temp, pointer); + this.sortDropZones(this._tempZones); + + if (this.topOnly) + { + // Only the top-most one counts now, so safely ignore the rest + if (this._temp.length) + { + this._temp.splice(1); + } + + if (this._tempZones.length) + { + this._tempZones.splice(1); + } + } + + switch (type) + { + case CONST.MOUSE_DOWN: + total += this.processDragDownEvent(pointer); + total += this.processDownEvents(pointer); + total += this.processOverOutEvents(pointer); + break; + + case CONST.MOUSE_UP: + total += this.processDragUpEvent(pointer); + total += this.processUpEvents(pointer); + total += this.processOverOutEvents(pointer); + break; + + case CONST.TOUCH_START: + total += this.processDragDownEvent(pointer); + total += this.processDownEvents(pointer); + total += this.processOverEvents(pointer); + break; + + case CONST.TOUCH_END: + case CONST.TOUCH_CANCEL: + total += this.processDragUpEvent(pointer); + total += this.processUpEvents(pointer); + total += this.processOutEvents(pointer); + break; + + case CONST.MOUSE_MOVE: + case CONST.TOUCH_MOVE: + total += this.processDragMoveEvent(pointer); + total += this.processMoveEvents(pointer); + total += this.processOverOutEvents(pointer); + break; + + case CONST.MOUSE_WHEEL: + total += this.processWheelEvent(pointer); + break; + } + + if (total > 0) + { + // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame + captured = true; + } + } + + this._updatedThisFrame = true; + + return captured; + }, + + /** + * Clears a Game Object so it no longer has an Interactive Object associated with it. + * The Game Object is then queued for removal from the Input Plugin on the next update. + * + * @method Phaser.Input.InputPlugin#clear + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will have its Interactive Object removed. + * @param {boolean} [skipQueue=false] - Skip adding this Game Object into the removal queue? + * + * @return {Phaser.GameObjects.GameObject} The Game Object that had its Interactive Object removed. + */ + clear: function (gameObject, skipQueue) + { + if (skipQueue === undefined) { skipQueue = false; } + + this.disable(gameObject); + + var input = gameObject.input; + + // If GameObject.input already cleared from higher class + if (input) + { + this.removeDebug(gameObject); + this.manager.resetCursor(input); + + input.gameObject = undefined; + input.target = undefined; + input.hitArea = undefined; + input.hitAreaCallback = undefined; + input.callbackContext = undefined; + + gameObject.input = null; + } + + if (!skipQueue) + { + this.queueForRemoval(gameObject); + } + + var index = this._draggable.indexOf(gameObject); + + if (index > -1) + { + this._draggable.splice(index, 1); + } + + return gameObject; + }, + + /** + * Disables Input on a single Game Object. + * + * An input disabled Game Object still retains its Interactive Object component and can be re-enabled + * at any time, by passing it to `InputPlugin.enable`. + * + * @method Phaser.Input.InputPlugin#disable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its input system disabled. + * @param {boolean} [resetCursor=false] - Reset the cursor to the default? + * + * @return {this} This Input Plugin. + */ + disable: function (gameObject, resetCursor) + { + if (resetCursor === undefined) { resetCursor = false; } + + var input = gameObject.input; + + if (input) + { + input.enabled = false; + input.dragState = 0; + } + + // Clear from _drag and _over + var drag = this._drag; + var over = this._over; + var manager = this.manager; + + for (var i = 0, index; i < manager.pointers.length; i++) + { + index = drag[i].indexOf(gameObject); + + if (index > -1) + { + drag[i].splice(index, 1); + } + + index = over[i].indexOf(gameObject); + + if (index > -1) + { + over[i].splice(index, 1); + } + } + + if (resetCursor) + { + this.resetCursor(); + } + + return this; + }, + + /** + * Enable a Game Object for interaction. + * + * If the Game Object already has an Interactive Object component, it is enabled and returned. + * + * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @method Phaser.Input.InputPlugin#enable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to be enabled for input. + * @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {Phaser.Types.Input.HitAreaCallback} [hitAreaCallback] - The 'contains' function to invoke to check if the pointer is within the hit area. + * @param {boolean} [dropZone=false] - Is this Game Object a drop zone or not? + * + * @return {this} This Input Plugin. + */ + enable: function (gameObject, hitArea, hitAreaCallback, dropZone) + { + if (dropZone === undefined) { dropZone = false; } + + if (gameObject.input) + { + // If it already has an InteractiveObject then just enable it and return + gameObject.input.enabled = true; + } + else + { + // Create an InteractiveObject and enable it + this.setHitArea(gameObject, hitArea, hitAreaCallback); + } + + if (gameObject.input && dropZone && !gameObject.input.dropZone) + { + gameObject.input.dropZone = dropZone; + } + + return this; + }, + + /** + * Takes the given Pointer and performs a hit test against it, to see which interactive Game Objects + * it is currently above. + * + * The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple + * cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list. + * + * @method Phaser.Input.InputPlugin#hitTestPointer + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects. + * + * @return {Phaser.GameObjects.GameObject[]} An array of all the interactive Game Objects the Pointer was above. + */ + hitTestPointer: function (pointer) + { + var cameras = this.cameras.getCamerasBelowPointer(pointer); + + for (var c = 0; c < cameras.length; c++) + { + var camera = cameras[c]; + + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'over' array. + // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. + var over = this.manager.hitTest(pointer, this._list, camera); + + // Filter out the drop zones + for (var i = 0; i < over.length; i++) + { + var obj = over[i]; + + if (obj.input.dropZone) + { + this._tempZones.push(obj); + } + } + + if (over.length > 0) + { + pointer.camera = camera; + + return over; + } + } + + // If we got this far then there were no Game Objects below the pointer, but it was still over + // a camera, so set that the top-most one into the pointer + + pointer.camera = cameras[0]; + + return []; + }, + + /** + * An internal method that handles the Pointer down event. + * + * @method Phaser.Input.InputPlugin#processDownEvents + * @private + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_DOWN + * @fires Phaser.Input.Events#GAMEOBJECT_DOWN + * @fires Phaser.Input.Events#POINTER_DOWN + * @fires Phaser.Input.Events#POINTER_DOWN_OUTSIDE + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer being tested. + * + * @return {number} The total number of objects interacted with. + */ + processDownEvents: function (pointer) + { + var total = 0; + var currentlyOver = this._temp; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + total++; + + // 1) GAMEOBJECT_POINTER_DOWN + gameObject.emit(Events.GAMEOBJECT_POINTER_DOWN, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + // Check that the game object wasn't input disabled or destroyed as a result of its input event + if (gameObject.input && gameObject.input.enabled) + { + // 2) GAMEOBJECT_DOWN + + this.emit(Events.GAMEOBJECT_DOWN, pointer, gameObject, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + } + } + + // If they pressed down outside the canvas, dispatch that event. + if (!_eventData.cancelled && this.isActive()) + { + if (pointer.downElement === this.manager.game.canvas) + { + // 3) POINTER_DOWN + this.emit(Events.POINTER_DOWN, pointer, currentlyOver); + } + else + { + // 4) POINTER_DOWN_OUTSIDE + this.emit(Events.POINTER_DOWN_OUTSIDE, pointer); + } + } + + return total; + }, + + /** + * Returns the drag state of the given Pointer for this Input Plugin. + * + * The state will be one of the following: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * + * @method Phaser.Input.InputPlugin#getDragState + * @since 3.16.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to get the drag state for. + * + * @return {number} The drag state of the given Pointer. + */ + getDragState: function (pointer) + { + return this._dragState[pointer.id]; + }, + + /** + * Sets the drag state of the given Pointer for this Input Plugin. + * + * The state must be one of the following values: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * + * @method Phaser.Input.InputPlugin#setDragState + * @since 3.16.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to set the drag state for. + * @param {number} state - The drag state value. An integer between 0 and 5. + */ + setDragState: function (pointer, state) + { + this._dragState[pointer.id] = state; + }, + + /** + * Checks to see if a Pointer is ready to drag the objects below it, based on either a distance + * or time threshold. + * + * @method Phaser.Input.InputPlugin#processDragThresholdEvent + * @private + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check the drag thresholds on. + * @param {number} time - The current time. + */ + processDragThresholdEvent: function (pointer, time) + { + var passed = false; + var timeThreshold = this.dragTimeThreshold; + var distanceThreshold = this.dragDistanceThreshold; + + if (distanceThreshold > 0 && DistanceBetween(pointer.x, pointer.y, pointer.downX, pointer.downY) >= distanceThreshold) + { + // It has moved far enough to be considered a drag + passed = true; + } + else if (timeThreshold > 0 && (time >= pointer.downTime + timeThreshold)) + { + // It has been held down long enough to be considered a drag + passed = true; + } + + if (passed) + { + this.setDragState(pointer, 3); + + return this.processDragStartList(pointer); + } + }, + + /** + * Processes the drag list for the given pointer and dispatches the start events for each object on it. + * + * @method Phaser.Input.InputPlugin#processDragStartList + * @private + * @fires Phaser.Input.Events#DRAG_START + * @fires Phaser.Input.Events#GAMEOBJECT_DRAG_START + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to process the drag event on. + * + * @return {number} The number of items that DRAG_START was called on. + */ + processDragStartList: function (pointer) + { + // 3 = Pointer meets criteria and is freshly down, notify the draglist + if (this.getDragState(pointer) !== 3) + { + return 0; + } + + var list = this._drag[pointer.id]; + + if (list.length > 1) + { + list = list.slice(0); + } + + for (var i = 0; i < list.length; i++) + { + var gameObject = list[i]; + + var input = gameObject.input; + + input.dragState = 2; + + input.dragStartX = gameObject.x; + input.dragStartY = gameObject.y; + + input.dragStartXGlobal = pointer.worldX; + input.dragStartYGlobal = pointer.worldY; + + input.dragStartCamera = pointer.camera; + + input.dragX = input.dragStartXGlobal - input.dragStartX; + input.dragY = input.dragStartYGlobal - input.dragStartY; + + gameObject.emit(Events.GAMEOBJECT_DRAG_START, pointer, input.dragX, input.dragY); + + this.emit(Events.DRAG_START, pointer, gameObject); + } + + this.setDragState(pointer, 4); + + return list.length; + }, + + /** + * Processes a 'drag down' event for the given pointer. Checks the pointer state, builds-up the drag list + * and prepares them all for interaction. + * + * @method Phaser.Input.InputPlugin#processDragDownEvent + * @private + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to process the drag event on. + * + * @return {number} The number of items that were collected on the drag list. + */ + processDragDownEvent: function (pointer) + { + var currentlyOver = this._temp; + + if (this._draggable.length === 0 || currentlyOver.length === 0 || !pointer.primaryDown || this.getDragState(pointer) !== 0) + { + // There are no draggable items, no over items or the pointer isn't down, so let's not even bother going further + return 0; + } + + // 1 = Primary button down and objects below, so collect a draglist + this.setDragState(pointer, 1); + + // Get draggable objects, sort them, pick the top (or all) and store them somewhere + var draglist = []; + + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (gameObject.input.draggable && (gameObject.input.dragState === 0)) + { + draglist.push(gameObject); + } + } + + if (draglist.length === 0) + { + this.setDragState(pointer, 0); + + return 0; + } + else if (draglist.length > 1) + { + this.sortGameObjects(draglist, pointer); + + if (this.topOnly) + { + draglist.splice(1); + } + } + + // draglist now contains all potential candidates for dragging + this._drag[pointer.id] = draglist; + + if (this.dragDistanceThreshold === 0 && this.dragTimeThreshold === 0) + { + // No drag criteria, so snap immediately to mode 3 + this.setDragState(pointer, 3); + + return this.processDragStartList(pointer); + } + else + { + // Check the distance / time on the next event + this.setDragState(pointer, 2); + + return 0; + } + }, + + /** + * Processes a 'drag move' event for the given pointer. + * + * @method Phaser.Input.InputPlugin#processDragMoveEvent + * @private + * @fires Phaser.Input.Events#DRAG_ENTER + * @fires Phaser.Input.Events#DRAG + * @fires Phaser.Input.Events#DRAG_LEAVE + * @fires Phaser.Input.Events#DRAG_OVER + * @fires Phaser.Input.Events#GAMEOBJECT_DRAG_ENTER + * @fires Phaser.Input.Events#GAMEOBJECT_DRAG + * @fires Phaser.Input.Events#GAMEOBJECT_DRAG_LEAVE + * @fires Phaser.Input.Events#GAMEOBJECT_DRAG_OVER + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to process the drag event on. + * + * @return {number} The number of items that were updated by this drag event. + */ + processDragMoveEvent: function (pointer) + { + // 2 = Pointer being checked if meets drag criteria + if (this.getDragState(pointer) === 2) + { + this.processDragThresholdEvent(pointer, this.manager.game.loop.now); + } + + if (this.getDragState(pointer) !== 4) + { + return 0; + } + + // 4 = Pointer actively dragging the draglist and has moved + var dropZones = this._tempZones; + + var list = this._drag[pointer.id]; + + if (list.length > 1) + { + list = list.slice(0); + } + + for (var i = 0; i < list.length; i++) + { + var gameObject = list[i]; + + var input = gameObject.input; + + var target = input.target; + + // If this GO has a target then let's check it + if (target) + { + var index = dropZones.indexOf(target); + + // Got a target, are we still over it? + if (index === 0) + { + // We're still over it, and it's still the top of the display list, phew ... + gameObject.emit(Events.GAMEOBJECT_DRAG_OVER, pointer, target); + + this.emit(Events.DRAG_OVER, pointer, gameObject, target); + } + else if (index > 0) + { + // Still over it but it's no longer top of the display list (targets must always be at the top) + gameObject.emit(Events.GAMEOBJECT_DRAG_LEAVE, pointer, target); + + this.emit(Events.DRAG_LEAVE, pointer, gameObject, target); + + input.target = dropZones[0]; + + target = input.target; + + gameObject.emit(Events.GAMEOBJECT_DRAG_ENTER, pointer, target); + + this.emit(Events.DRAG_ENTER, pointer, gameObject, target); + } + else + { + // Nope, we've moved on (or the target has!), leave the old target + gameObject.emit(Events.GAMEOBJECT_DRAG_LEAVE, pointer, target); + + this.emit(Events.DRAG_LEAVE, pointer, gameObject, target); + + // Anything new to replace it? + // Yup! + if (dropZones[0]) + { + input.target = dropZones[0]; + + target = input.target; + + gameObject.emit(Events.GAMEOBJECT_DRAG_ENTER, pointer, target); + + this.emit(Events.DRAG_ENTER, pointer, gameObject, target); + } + else + { + // Nope + input.target = null; + } + } + } + else if (!target && dropZones[0]) + { + input.target = dropZones[0]; + + target = input.target; + + gameObject.emit(Events.GAMEOBJECT_DRAG_ENTER, pointer, target); + + this.emit(Events.DRAG_ENTER, pointer, gameObject, target); + } + + var dragX; + var dragY; + + var dragWorldXY = pointer.positionToCamera(input.dragStartCamera); + + if (!gameObject.parentContainer) + { + dragX = dragWorldXY.x - input.dragX; + dragY = dragWorldXY.y - input.dragY; + } + else + { + var dx = dragWorldXY.x - input.dragStartXGlobal; + var dy = dragWorldXY.y - input.dragStartYGlobal; + + var rotation = gameObject.getParentRotation(); + + var dxRotated = dx * Math.cos(rotation) + dy * Math.sin(rotation); + var dyRotated = dy * Math.cos(rotation) - dx * Math.sin(rotation); + + dxRotated *= (1 / gameObject.parentContainer.scaleX); + dyRotated *= (1 / gameObject.parentContainer.scaleY); + + dragX = dxRotated + input.dragStartX; + dragY = dyRotated + input.dragStartY; + } + + gameObject.emit(Events.GAMEOBJECT_DRAG, pointer, dragX, dragY); + + this.emit(Events.DRAG, pointer, gameObject, dragX, dragY); + } + + return list.length; + }, + + /** + * Processes a 'drag up' event for the given pointer. Handles the release of any dragged Game Objects, + * dispatching drop and drag end events as appropriate. + * + * @method Phaser.Input.InputPlugin#processDragUpEvent + * @fires Phaser.Input.Events#DRAG_END + * @fires Phaser.Input.Events#DROP + * @fires Phaser.Input.Events#GAMEOBJECT_DRAG_END + * @fires Phaser.Input.Events#GAMEOBJECT_DROP + * @private + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to process the drag event on. + * + * @return {number} The number of items that were updated by this drag event. + */ + processDragUpEvent: function (pointer) + { + // 5 = Pointer was actively dragging but has been released, notify draglist + var list = this._drag[pointer.id]; + + if (list.length > 1) + { + list = list.slice(0); + } + + for (var i = 0; i < list.length; i++) + { + var gameObject = list[i]; + + var input = gameObject.input; + + if (input && input.dragState === 2) + { + input.dragState = 0; + + input.dragX = input.localX - gameObject.displayOriginX; + input.dragY = input.localY - gameObject.displayOriginY; + + input.dragStartCamera = null; + + var dropped = false; + + var target = input.target; + + if (target) + { + gameObject.emit(Events.GAMEOBJECT_DROP, pointer, target); + + this.emit(Events.DROP, pointer, gameObject, target); + + input.target = null; + + dropped = true; + } + + // And finally the dragend event + + if (gameObject.input && gameObject.input.enabled) + { + gameObject.emit(Events.GAMEOBJECT_DRAG_END, pointer, input.dragX, input.dragY, dropped); + + this.emit(Events.DRAG_END, pointer, gameObject, dropped); + } + } + } + + this.setDragState(pointer, 0); + + list.splice(0); + + return 0; + }, + + /** + * An internal method that handles the Pointer movement event. + * + * @method Phaser.Input.InputPlugin#processMoveEvents + * @private + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_MOVE + * @fires Phaser.Input.Events#GAMEOBJECT_MOVE + * @fires Phaser.Input.Events#POINTER_MOVE + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {number} The total number of objects interacted with. + */ + processMoveEvents: function (pointer) + { + var total = 0; + var currentlyOver = this._temp; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + total++; + + gameObject.emit(Events.GAMEOBJECT_POINTER_MOVE, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + // Check that the game object wasn't input disabled or destroyed as a result of its input event + if (gameObject.input && gameObject.input.enabled) + { + this.emit(Events.GAMEOBJECT_MOVE, pointer, gameObject, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + if (this.topOnly) + { + break; + } + } + } + + if (!_eventData.cancelled && this.isActive()) + { + this.emit(Events.POINTER_MOVE, pointer, currentlyOver); + } + + return total; + }, + + /** + * An internal method that handles a mouse wheel event. + * + * @method Phaser.Input.InputPlugin#processWheelEvent + * @private + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_WHEEL + * @fires Phaser.Input.Events#GAMEOBJECT_WHEEL + * @fires Phaser.Input.Events#POINTER_WHEEL + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {number} The total number of objects interacted with. + */ + processWheelEvent: function (pointer) + { + var total = 0; + var currentlyOver = this._temp; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var dx = pointer.deltaX; + var dy = pointer.deltaY; + var dz = pointer.deltaZ; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + total++; + + gameObject.emit(Events.GAMEOBJECT_POINTER_WHEEL, pointer, dx, dy, dz, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + // Check that the game object wasn't input disabled or destroyed as a result of its input event + if (gameObject.input && gameObject.input.enabled) + { + this.emit(Events.GAMEOBJECT_WHEEL, pointer, gameObject, dx, dy, dz, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + } + } + + if (!_eventData.cancelled && this.isActive()) + { + this.emit(Events.POINTER_WHEEL, pointer, currentlyOver, dx, dy, dz); + } + + return total; + }, + + /** + * An internal method that handles the Pointer over events. + * This is called when a touch input hits the canvas, having previously been off of it. + * + * @method Phaser.Input.InputPlugin#processOverEvents + * @private + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_OVER + * @fires Phaser.Input.Events#GAMEOBJECT_OVER + * @fires Phaser.Input.Events#POINTER_OVER + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {number} The total number of objects interacted with. + */ + processOverEvents: function (pointer) + { + var currentlyOver = this._temp; + + var totalInteracted = 0; + + var total = currentlyOver.length; + + var justOver = []; + + if (total > 0) + { + var manager = this.manager; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + for (var i = 0; i < total; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + justOver.push(gameObject); + + manager.setCursor(gameObject.input); + + gameObject.emit(Events.GAMEOBJECT_POINTER_OVER, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + totalInteracted++; + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + // Check that the game object wasn't input disabled or destroyed as a result of its input event + if (gameObject.input && gameObject.input.enabled) + { + this.emit(Events.GAMEOBJECT_OVER, pointer, gameObject, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + } + } + + if (!_eventData.cancelled && this.isActive()) + { + this.emit(Events.POINTER_OVER, pointer, justOver); + } + } + + // Then sort it into display list order + this._over[pointer.id] = justOver; + + return totalInteracted; + }, + + /** + * An internal method that handles the Pointer out events. + * This is called when a touch input leaves the canvas, as it can never be 'over' in this case. + * + * @method Phaser.Input.InputPlugin#processOutEvents + * @private + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_OUT + * @fires Phaser.Input.Events#GAMEOBJECT_OUT + * @fires Phaser.Input.Events#POINTER_OUT + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {number} The total number of objects interacted with. + */ + processOutEvents: function (pointer) + { + var previouslyOver = this._over[pointer.id]; + + var totalInteracted = 0; + + var total = previouslyOver.length; + + if (total > 0) + { + var manager = this.manager; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + this.sortGameObjects(previouslyOver, pointer); + + for (var i = 0; i < total; i++) + { + var gameObject = previouslyOver[i]; + + // Call onOut for everything in the previouslyOver array + gameObject = previouslyOver[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + manager.resetCursor(gameObject.input); + + gameObject.emit(Events.GAMEOBJECT_POINTER_OUT, pointer, _eventContainer); + + totalInteracted++; + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + if (gameObject.input && gameObject.input.enabled) + { + this.emit(Events.GAMEOBJECT_OUT, pointer, gameObject, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + } + } + + if (!_eventData.cancelled && this.isActive()) + { + this.emit(Events.POINTER_OUT, pointer, previouslyOver); + } + + this._over[pointer.id] = []; + } + + return totalInteracted; + }, + + /** + * An internal method that handles the Pointer over and out events. + * + * @method Phaser.Input.InputPlugin#processOverOutEvents + * @private + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_OVER + * @fires Phaser.Input.Events#GAMEOBJECT_OVER + * @fires Phaser.Input.Events#POINTER_OVER + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_OUT + * @fires Phaser.Input.Events#GAMEOBJECT_OUT + * @fires Phaser.Input.Events#POINTER_OUT + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {number} The total number of objects interacted with. + */ + processOverOutEvents: function (pointer) + { + var currentlyOver = this._temp; + + var i; + var gameObject; + var justOut = []; + var justOver = []; + var stillOver = []; + var previouslyOver = this._over[pointer.id]; + var currentlyDragging = this._drag[pointer.id]; + + var manager = this.manager; + + // Go through all objects the pointer was previously over, and see if it still is. + // Splits the previouslyOver array into two parts: justOut and stillOver + + for (i = 0; i < previouslyOver.length; i++) + { + gameObject = previouslyOver[i]; + + if (currentlyOver.indexOf(gameObject) === -1 && currentlyDragging.indexOf(gameObject) === -1) + { + // Not in the currentlyOver array, so must be outside of this object now + justOut.push(gameObject); + } + else + { + // In the currentlyOver array + stillOver.push(gameObject); + } + } + + // Go through all objects the pointer is currently over (the hit test results) + // and if not in the previouslyOver array we know it's a new entry, so add to justOver + for (i = 0; i < currentlyOver.length; i++) + { + gameObject = currentlyOver[i]; + + // Is this newly over? + + if (previouslyOver.indexOf(gameObject) === -1) + { + justOver.push(gameObject); + } + } + + // By this point the arrays are filled, so now we can process what happened... + + // Process the Just Out objects + var total = justOut.length; + + var totalInteracted = 0; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + if (total > 0) + { + this.sortGameObjects(justOut, pointer); + + // Call onOut for everything in the justOut array + for (i = 0; i < total; i++) + { + gameObject = justOut[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + // Reset cursor before we emit the event, in case they want to change it during the event + manager.resetCursor(gameObject.input); + + gameObject.emit(Events.GAMEOBJECT_POINTER_OUT, pointer, _eventContainer); + + totalInteracted++; + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + // Check that the game object wasn't input disabled or destroyed as a result of its input event + if (gameObject.input && gameObject.input.enabled) + { + this.emit(Events.GAMEOBJECT_OUT, pointer, gameObject, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + } + } + + if (!_eventData.cancelled || this.isActive()) + { + this.emit(Events.POINTER_OUT, pointer, justOut); + } + } + + // Process the Just Over objects + total = justOver.length; + + _eventData.cancelled = false; + + if (total > 0) + { + this.sortGameObjects(justOver, pointer); + + // Call onOver for everything in the justOver array + for (i = 0; i < total; i++) + { + gameObject = justOver[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + // Set cursor before we emit the event, in case they want to change it during the event + manager.setCursor(gameObject.input); + + gameObject.emit(Events.GAMEOBJECT_POINTER_OVER, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + totalInteracted++; + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + // Check that the game object wasn't input disabled or destroyed as a result of its input event + if (gameObject.input && gameObject.input.enabled) + { + this.emit(Events.GAMEOBJECT_OVER, pointer, gameObject, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + } + } + + if (!_eventData.cancelled && this.isActive()) + { + this.emit(Events.POINTER_OVER, pointer, justOver); + } + } + + // Add the contents of justOver to the previously over array + previouslyOver = stillOver.concat(justOver); + + // Then sort it into display list order + this._over[pointer.id] = this.sortGameObjects(previouslyOver, pointer); + + return totalInteracted; + }, + + /** + * An internal method that handles the Pointer up events. + * + * @method Phaser.Input.InputPlugin#processUpEvents + * @private + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_UP + * @fires Phaser.Input.Events#GAMEOBJECT_UP + * @fires Phaser.Input.Events#POINTER_UP + * @fires Phaser.Input.Events#POINTER_UP_OUTSIDE + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {number} The total number of objects interacted with. + */ + processUpEvents: function (pointer) + { + var currentlyOver = this._temp; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input || !gameObject.input.enabled) + { + continue; + } + + // 1) GAMEOBJECT_POINTER_UP + gameObject.emit(Events.GAMEOBJECT_POINTER_UP, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + + // Check that the game object wasn't input disabled or destroyed as a result of its input event + if (gameObject.input && gameObject.input.enabled) + { + // 2) GAMEOBJECT_UP + + this.emit(Events.GAMEOBJECT_UP, pointer, gameObject, _eventContainer); + + if (_eventData.cancelled || !this.isActive()) + { + // They cancelled the whole event, it can't go any further + break; + } + } + } + + // If they released outside the canvas, but pressed down inside it, we'll still dispatch the event. + if (!_eventData.cancelled && this.isActive()) + { + if (pointer.upElement === this.manager.game.canvas) + { + this.emit(Events.POINTER_UP, pointer, currentlyOver); + } + else + { + this.emit(Events.POINTER_UP_OUTSIDE, pointer); + } + } + + return currentlyOver.length; + }, + + /** + * This method will force the given Game Object into the 'down' input state. + * + * This will check to see if the Game Object is enabled for input, and if so, + * it will emit the `GAMEOBJECT_POINTER_DOWN` event for it. If that doesn't change + * the input state, it will then emit the `GAMEOBJECT_DOWN` event. + * + * The Game Object is not checked against the Pointer to see if it can enter this state, + * that is up to you to do before calling this method. + * + * @method Phaser.Input.InputPlugin#forceDownState + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_DOWN + * @fires Phaser.Input.Events#GAMEOBJECT_DOWN + * @since 3.85.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to use when setting the state. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its state set. + */ + forceDownState: function (pointer, gameObject) + { + this.forceState(pointer, gameObject, Events.GAMEOBJECT_POINTER_DOWN, Events.GAMEOBJECT_DOWN, false); + }, + + /** + * This method will force the given Game Object into the 'up' input state. + * + * This will check to see if the Game Object is enabled for input, and if so, + * it will emit the `GAMEOBJECT_POINTER_UP` event for it. If that doesn't change + * the input state, it will then emit the `GAMEOBJECT_UP` event. + * + * The Game Object is not checked against the Pointer to see if it can enter this state, + * that is up to you to do before calling this method. + * + * @method Phaser.Input.InputPlugin#forceUpState + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_UP + * @fires Phaser.Input.Events#GAMEOBJECT_UP + * @since 3.85.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to use when setting the state. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its state set. + */ + forceUpState: function (pointer, gameObject) + { + this.forceState(pointer, gameObject, Events.GAMEOBJECT_POINTER_UP, Events.GAMEOBJECT_UP, false); + }, + + /** + * This method will force the given Game Object into the 'over' input state. + * + * This will check to see if the Game Object is enabled for input, and if so, + * it will emit the `GAMEOBJECT_POINTER_OVER` event for it. If that doesn't change + * the input state, it will then emit the `GAMEOBJECT_OVER` event. + * + * The Game Object is not checked against the Pointer to see if it can enter this state, + * that is up to you to do before calling this method. + * + * @method Phaser.Input.InputPlugin#forceOverState + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_OVER + * @fires Phaser.Input.Events#GAMEOBJECT_OVER + * @since 3.85.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to use when setting the state. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its state set. + */ + forceOverState: function (pointer, gameObject) + { + this.forceState(pointer, gameObject, Events.GAMEOBJECT_POINTER_OVER, Events.GAMEOBJECT_OVER, true); + }, + + /** + * This method will force the given Game Object into the 'out' input state. + * + * This will check to see if the Game Object is enabled for input, and if so, + * it will emit the `GAMEOBJECT_POINTER_OUT` event for it. If that doesn't change + * the input state, it will then emit the `GAMEOBJECT_OUT` event. + * + * The Game Object is not checked against the Pointer to see if it can enter this state, + * that is up to you to do before calling this method. + * + * @method Phaser.Input.InputPlugin#forceOutState + * @fires Phaser.Input.Events#GAMEOBJECT_POINTER_OUT + * @fires Phaser.Input.Events#GAMEOBJECT_OUT + * @since 3.85.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to use when setting the state. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its state set. + */ + forceOutState: function (pointer, gameObject) + { + this.forceState(pointer, gameObject, Events.GAMEOBJECT_POINTER_OUT, Events.GAMEOBJECT_OUT, false); + }, + + /** + * This method will force the given Game Object into the given input state. + * + * @method Phaser.Input.InputPlugin#forceState + * @since 3.85.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to use when setting the state. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its state set. + * @param {string} gameObjectEvent - The event to emit on the Game Object. + * @param {string} inputPluginEvent - The event to emit on the Input Plugin. + * @param {boolean} [setCursor=false] - Should the cursor be set to the Game Object's cursor? + */ + forceState: function (pointer, gameObject, gameObjectEvent, inputPluginEvent, setCursor) + { + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + if (gameObject.input && gameObject.input.enabled) + { + gameObject.emit(gameObjectEvent, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + if (setCursor) + { + this.setCursor(gameObject.input); + } + + if (!_eventData.cancelled && this.isActive() && gameObject.input && gameObject.input.enabled) + { + this.emit(inputPluginEvent, pointer, gameObject, _eventContainer); + } + } + }, + + /** + * Queues a Game Object for insertion into this Input Plugin on the next update. + * + * @method Phaser.Input.InputPlugin#queueForInsertion + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. + * + * @return {this} This InputPlugin object. + */ + queueForInsertion: function (child) + { + if (this._pendingInsertion.indexOf(child) === -1 && this._list.indexOf(child) === -1) + { + this._pendingInsertion.push(child); + } + + return this; + }, + + /** + * Queues a Game Object for removal from this Input Plugin on the next update. + * + * @method Phaser.Input.InputPlugin#queueForRemoval + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove. + * + * @return {this} This InputPlugin object. + */ + queueForRemoval: function (child) + { + this._pendingRemoval.push(child); + + return this; + }, + + /** + * Sets the draggable state of the given array of Game Objects. + * + * They can either be set to be draggable, or can have their draggable state removed by passing `false`. + * + * A Game Object will not fire drag events unless it has been specifically enabled for drag. + * + * @method Phaser.Input.InputPlugin#setDraggable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to change the draggable state on. + * @param {boolean} [value=true] - Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. + * + * @return {this} This InputPlugin object. + */ + setDraggable: function (gameObjects, value) + { + if (value === undefined) { value = true; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + gameObject.input.draggable = value; + + var index = this._draggable.indexOf(gameObject); + + if (value && index === -1) + { + this._draggable.push(gameObject); + } + else if (!value && index > -1) + { + this._draggable.splice(index, 1); + } + } + + return this; + }, + + /** + * Creates a function that can be passed to `setInteractive`, `enable` or `setHitArea` that will handle + * pixel-perfect input detection on an Image or Sprite based Game Object, or any custom class that extends them. + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 1. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect()); + * ``` + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 150. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect(150)); + * ``` + * + * Once you have made an Interactive Object pixel perfect it impacts all input related events for it: down, up, + * dragstart, drag, etc. + * + * As a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from + * the given coordinates and checking its color values. This is an expensive process, so should only be enabled on + * Game Objects that really need it. + * + * You cannot make non-texture based Game Objects pixel perfect. So this will not work on Graphics, BitmapText, + * Render Textures, Text, Tilemaps, Containers or Particles. + * + * @method Phaser.Input.InputPlugin#makePixelPerfect + * @since 3.10.0 + * + * @param {number} [alphaTolerance=1] - The alpha level that the pixel should be above to be included as a successful interaction. + * + * @return {function} A Pixel Perfect Handler for use as a hitArea shape callback. + */ + makePixelPerfect: function (alphaTolerance) + { + if (alphaTolerance === undefined) { alphaTolerance = 1; } + + var textureManager = this.systems.textures; + + return CreatePixelPerfectHandler(textureManager, alphaTolerance); + }, + + /** + * Sets the hit area for the given array of Game Objects. + * + * A hit area is typically one of the geometric shapes Phaser provides, such as a `Phaser.Geom.Rectangle` + * or `Phaser.Geom.Circle`. However, it can be any object as long as it works with the provided callback. + * + * If no hit area is provided a Rectangle is created based on the size of the Game Object, if possible + * to calculate. + * + * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if + * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, + * such as `Phaser.Geom.Rectangle.Contains`. + * + * A hit area callback can be supplied to the `hitArea` parameter without using the `hitAreaCallback` parameter. + * + * @method Phaser.Input.InputPlugin#setHitArea + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set the hit area on. + * @param {(Phaser.Types.Input.InputConfiguration|Phaser.Types.Input.HitAreaCallback|any)} [hitArea] - Either an input configuration object, a geometric shape that defines the hit area or a hit area callback. If not specified a Rectangle hit area will be used. + * @param {Phaser.Types.Input.HitAreaCallback} [hitAreaCallback] - The 'contains' function to invoke to check if the pointer is within the hit area. + * + * @return {this} This InputPlugin object. + */ + setHitArea: function (gameObjects, hitArea, hitAreaCallback) + { + if (hitArea === undefined) + { + return this.setHitAreaFromTexture(gameObjects); + } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + var draggable = false; + var dropZone = false; + var cursor = false; + var useHandCursor = false; + var pixelPerfect = false; + var customHitArea = true; + + // Config object? + if (IsPlainObject(hitArea) && Object.keys(hitArea).length) + { + var config = hitArea; + + hitArea = GetFastValue(config, 'hitArea', null); + hitAreaCallback = GetFastValue(config, 'hitAreaCallback', null); + + pixelPerfect = GetFastValue(config, 'pixelPerfect', false); + var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1); + + if (pixelPerfect) + { + hitArea = {}; + hitAreaCallback = this.makePixelPerfect(alphaTolerance); + } + + draggable = GetFastValue(config, 'draggable', false); + dropZone = GetFastValue(config, 'dropZone', false); + cursor = GetFastValue(config, 'cursor', false); + useHandCursor = GetFastValue(config, 'useHandCursor', false); + + // Still no hitArea or callback? + if (!hitArea || !hitAreaCallback) + { + this.setHitAreaFromTexture(gameObjects); + customHitArea = false; + } + } + else if (typeof hitArea === 'function' && !hitAreaCallback) + { + hitAreaCallback = hitArea; + hitArea = {}; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + if (pixelPerfect && gameObject.type === 'Container') + { + console.warn('Cannot pixelPerfect test a Container. Use a custom callback.'); + continue; + } + + var io = (!gameObject.input) ? CreateInteractiveObject(gameObject, hitArea, hitAreaCallback) : gameObject.input; + + io.customHitArea = customHitArea; + io.dropZone = dropZone; + io.cursor = (useHandCursor) ? 'pointer' : cursor; + + gameObject.input = io; + + if (draggable) + { + this.setDraggable(gameObject); + } + + this.queueForInsertion(gameObject); + } + + return this; + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Circle` shape, using + * the given coordinates and radius to control its position and size. + * + * @method Phaser.Input.InputPlugin#setHitAreaCircle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a circle hit area. + * @param {number} x - The center of the circle. + * @param {number} y - The center of the circle. + * @param {number} radius - The radius of the circle. + * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains. + * + * @return {this} This InputPlugin object. + */ + setHitAreaCircle: function (gameObjects, x, y, radius, callback) + { + if (callback === undefined) { callback = CircleContains; } + + var shape = new Circle(x, y, radius); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Ellipse` shape, using + * the given coordinates and dimensions to control its position and size. + * + * @method Phaser.Input.InputPlugin#setHitAreaEllipse + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. + * @param {number} x - The center of the ellipse. + * @param {number} y - The center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains. + * + * @return {this} This InputPlugin object. + */ + setHitAreaEllipse: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = EllipseContains; } + + var shape = new Ellipse(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the Game Objects texture frame to define the position and size of the hit area. + * + * @method Phaser.Input.InputPlugin#setHitAreaFromTexture + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a Rectangle hit area based on their texture frame. + * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {this} This InputPlugin object. + */ + setHitAreaFromTexture: function (gameObjects, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + var frame = gameObject.frame; + + var width = 0; + var height = 0; + + if (gameObject.width) + { + width = gameObject.width; + height = gameObject.height; + } + else if (frame) + { + width = frame.realWidth; + height = frame.realHeight; + } + + if (gameObject.type === 'Container' && (width === 0 || height === 0)) + { + console.warn('Container.setInteractive must specify a Shape or call setSize() first'); + continue; + } + + if (width !== 0 && height !== 0) + { + gameObject.input = CreateInteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback); + + this.queueForInsertion(gameObject); + } + } + + return this; + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the given coordinates and dimensions to control its position and size. + * + * @method Phaser.Input.InputPlugin#setHitAreaRectangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a rectangular hit area. + * @param {number} x - The top-left of the rectangle. + * @param {number} y - The top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {this} This InputPlugin object. + */ + setHitAreaRectangle: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + var shape = new Rectangle(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Triangle` shape, using + * the given coordinates to control the position of its points. + * + * @method Phaser.Input.InputPlugin#setHitAreaTriangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a triangular hit area. + * @param {number} x1 - The x coordinate of the first point of the triangle. + * @param {number} y1 - The y coordinate of the first point of the triangle. + * @param {number} x2 - The x coordinate of the second point of the triangle. + * @param {number} y2 - The y coordinate of the second point of the triangle. + * @param {number} x3 - The x coordinate of the third point of the triangle. + * @param {number} y3 - The y coordinate of the third point of the triangle. + * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains. + * + * @return {this} This InputPlugin object. + */ + setHitAreaTriangle: function (gameObjects, x1, y1, x2, y2, x3, y3, callback) + { + if (callback === undefined) { callback = TriangleContains; } + + var shape = new Triangle(x1, y1, x2, y2, x3, y3); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Creates an Input Debug Shape for the given Game Object. + * + * The Game Object must have _already_ been enabled for input prior to calling this method. + * + * This is intended to assist you during development and debugging. + * + * Debug Shapes can only be created for Game Objects that are using standard Phaser Geometry for input, + * including: Circle, Ellipse, Line, Polygon, Rectangle and Triangle. + * + * Game Objects that are using their automatic hit areas are using Rectangles by default, so will also work. + * + * The Debug Shape is created and added to the display list and is then kept in sync with the Game Object + * it is connected with. Should you need to modify it yourself, such as to hide it, you can access it via + * the Game Object property: `GameObject.input.hitAreaDebug`. + * + * Calling this method on a Game Object that already has a Debug Shape will first destroy the old shape, + * before creating a new one. If you wish to remove the Debug Shape entirely, you should call the + * method `InputPlugin.removeDebug`. + * + * Note that the debug shape will only show the outline of the input area. If the input test is using a + * pixel perfect check, for example, then this is not displayed. If you are using a custom shape, that + * doesn't extend one of the base Phaser Geometry objects, as your hit area, then this method will not + * work. + * + * @method Phaser.Input.InputPlugin#enableDebug + * @since 3.19.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to create the input debug shape for. + * @param {number} [color=0x00ff00] - The outline color of the debug shape. + * + * @return {this} This Input Plugin. + */ + enableDebug: function (gameObject, color) + { + if (color === undefined) { color = 0x00ff00; } + + var input = gameObject.input; + + if (!input || !input.hitArea) + { + return this; + } + + var shape = input.hitArea; + var shapeType = shape.type; + var debug = input.hitAreaDebug; + var factory = this.systems.add; + var updateList = this.systems.updateList; + + if (debug) + { + updateList.remove(debug); + + debug.destroy(); + + debug = null; + } + + var offsetx = 0; + var offsety = 0; + + switch (shapeType) + { + case GEOM_CONST.CIRCLE: + debug = factory.arc(0, 0, shape.radius); + offsetx = shape.x - shape.radius; + offsety = shape.y - shape.radius; + break; + + case GEOM_CONST.ELLIPSE: + debug = factory.ellipse(0, 0, shape.width, shape.height); + offsetx = shape.x - shape.width / 2; + offsety = shape.y - shape.height / 2; + break; + + case GEOM_CONST.LINE: + debug = factory.line(0, 0, shape.x1, shape.y1, shape.x2, shape.y2); + break; + + case GEOM_CONST.POLYGON: + debug = factory.polygon(0, 0, shape.points); + break; + + case GEOM_CONST.RECTANGLE: + debug = factory.rectangle(0, 0, shape.width, shape.height); + offsetx = shape.x; + offsety = shape.y; + break; + + case GEOM_CONST.TRIANGLE: + debug = factory.triangle(0, 0, shape.x1, shape.y1, shape.x2, shape.y2, shape.x3, shape.y3); + break; + } + + if (debug) + { + debug.isFilled = false; + debug.strokeColor = color; + + debug.preUpdate = function () + { + debug.setVisible(gameObject.visible); + + debug.setStrokeStyle(1 / gameObject.scale, debug.strokeColor); + + debug.setDisplayOrigin(gameObject.displayOriginX, gameObject.displayOriginY); + + var x = gameObject.x; + var y = gameObject.y; + var rotation = gameObject.rotation; + var scaleX = gameObject.scaleX; + var scaleY = gameObject.scaleY; + + if (gameObject.parentContainer) + { + var matrix = gameObject.getWorldTransformMatrix(); + + x = matrix.tx; + y = matrix.ty; + rotation = matrix.rotation; + scaleX = matrix.scaleX; + scaleY = matrix.scaleY; + } + + debug.setRotation(rotation); + debug.setScale(scaleX, scaleY); + debug.setPosition(x + offsetx * scaleX, y + offsety * scaleY); + debug.setScrollFactor(gameObject.scrollFactorX, gameObject.scrollFactorY); + debug.setDepth(gameObject.depth); + }; + + updateList.add(debug); + + input.hitAreaDebug = debug; + } + + return this; + }, + + /** + * Removes an Input Debug Shape from the given Game Object. + * + * The shape is destroyed immediately and the `hitAreaDebug` property is set to `null`. + * + * @method Phaser.Input.InputPlugin#removeDebug + * @since 3.19.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to remove the input debug shape from. + * + * @return {this} This Input Plugin. + */ + removeDebug: function (gameObject) + { + var input = gameObject.input; + + if (input && input.hitAreaDebug) + { + var debug = input.hitAreaDebug; + + // This will remove it from both the display list and update list + debug.destroy(); + + input.hitAreaDebug = null; + } + + return this; + }, + + /** + * Sets the Pointers to always poll. + * + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it, regardless if the Pointer has actually moved or not. + * + * You should enable this if you want objects in your game to fire over / out events, and the objects + * are constantly moving, but the pointer may not have. Polling every frame has additional computation + * costs, especially if there are a large number of interactive objects in your game. + * + * @method Phaser.Input.InputPlugin#setPollAlways + * @since 3.0.0 + * + * @return {this} This InputPlugin object. + */ + setPollAlways: function () + { + return this.setPollRate(0); + }, + + /** + * Sets the Pointers to only poll when they are moved or updated. + * + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it. + * + * @method Phaser.Input.InputPlugin#setPollOnMove + * @since 3.0.0 + * + * @return {this} This InputPlugin object. + */ + setPollOnMove: function () + { + return this.setPollRate(-1); + }, + + /** + * Sets the poll rate value. This is the amount of time that should have elapsed before a pointer + * will be polled again. See the `setPollAlways` and `setPollOnMove` methods. + * + * @method Phaser.Input.InputPlugin#setPollRate + * @since 3.0.0 + * + * @param {number} value - The amount of time, in ms, that should elapsed before re-polling the pointers. + * + * @return {this} This InputPlugin object. + */ + setPollRate: function (value) + { + this.pollRate = value; + this._pollTimer = 0; + + return this; + }, + + /** + * When set to `true` the global Input Manager will emulate DOM behavior by only emitting events from + * the top-most Scene in the Scene List. By default, if a Scene receives an input event it will then stop the event + * from flowing down to any Scenes below it in the Scene list. To disable this behavior call this method with `false`. + * + * @method Phaser.Input.InputPlugin#setGlobalTopOnly + * @since 3.0.0 + * + * @param {boolean} value - Set to `true` to stop processing input events on the Scene that receives it, or `false` to let the event continue down the Scene list. + * + * @return {this} This InputPlugin object. + */ + setGlobalTopOnly: function (value) + { + this.manager.globalTopOnly = value; + + return this; + }, + + /** + * When set to `true` this Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * + * @method Phaser.Input.InputPlugin#setTopOnly + * @since 3.0.0 + * + * @param {boolean} value - `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. + * + * @return {this} This InputPlugin object. + */ + setTopOnly: function (value) + { + this.topOnly = value; + + return this; + }, + + /** + * Given an array of Game Objects and a Pointer, sort the array and return it, + * so that the objects are in render order with the lowest at the bottom. + * + * @method Phaser.Input.InputPlugin#sortGameObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to be sorted. + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects. + * + * @return {Phaser.GameObjects.GameObject[]} The sorted array of Game Objects. + */ + sortGameObjects: function (gameObjects, pointer) + { + if (gameObjects.length < 2 || !pointer.camera) + { + return gameObjects; + } + + var list = pointer.camera.renderList; + + return gameObjects.sort(function (childA, childB) + { + var indexA = Math.max(list.indexOf(childA), 0); + var indexB = Math.max(list.indexOf(childB), 0); + + return indexB - indexA; + }); + }, + + /** + * Given an array of Drop Zone Game Objects, sort the array and return it, + * so that the objects are in depth index order with the lowest at the bottom. + * + * @method Phaser.Input.InputPlugin#sortDropZones + * @since 3.52.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to be sorted. + * + * @return {Phaser.GameObjects.GameObject[]} The sorted array of Game Objects. + */ + sortDropZones: function (gameObjects) + { + if (gameObjects.length < 2) + { + return gameObjects; + } + + this.scene.sys.depthSort(); + + return gameObjects.sort(this.sortDropZoneHandler.bind(this)); + }, + + /** + * Return the child lowest down the display list (with the smallest index) + * Will iterate through all parent containers, if present. + * + * Prior to version 3.52.0 this method was called `sortHandlerGO`. + * + * @method Phaser.Input.InputPlugin#sortDropZoneHandler + * @private + * @since 3.52.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first Game Object to compare. + * @param {Phaser.GameObjects.GameObject} childB - The second Game Object to compare. + * + * @return {number} Returns either a negative or positive integer, or zero if they match. + */ + sortDropZoneHandler: function (childA, childB) + { + if (!childA.parentContainer && !childB.parentContainer) + { + // Quick bail out when neither child has a container + return this.displayList.getIndex(childB) - this.displayList.getIndex(childA); + } + else if (childA.parentContainer === childB.parentContainer) + { + // Quick bail out when both children have the same container + return childB.parentContainer.getIndex(childB) - childA.parentContainer.getIndex(childA); + } + else if (childA.parentContainer === childB) + { + // Quick bail out when childA is a child of childB + return -1; + } + else if (childB.parentContainer === childA) + { + // Quick bail out when childA is a child of childB + return 1; + } + else + { + // Container index check + var listA = childA.getIndexList(); + var listB = childB.getIndexList(); + var len = Math.min(listA.length, listB.length); + + for (var i = 0; i < len; i++) + { + var indexA = listA[i]; + var indexB = listB[i]; + + if (indexA === indexB) + { + // Go to the next level down + continue; + } + else + { + // Non-matching parents, so return + return indexB - indexA; + } + } + + return listB.length - listA.length; + } + + // Technically this shouldn't happen, but ... + // eslint-disable-next-line no-unreachable + // removed by dead control flow + + }, + + /** + * This method should be called from within an input event handler, such as `pointerdown`. + * + * When called, it stops the Input Manager from allowing _this specific event_ to be processed by any other Scene + * not yet handled in the scene list. + * + * @method Phaser.Input.InputPlugin#stopPropagation + * @since 3.0.0 + * + * @return {this} This InputPlugin object. + */ + stopPropagation: function () + { + this.manager._tempSkip = true; + + return this; + }, + + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * + * @method Phaser.Input.InputPlugin#addPointer + * @since 3.10.0 + * + * @param {number} [quantity=1] The number of new Pointers to create. A maximum of 10 is allowed in total. + * + * @return {Phaser.Input.Pointer[]} An array containing all of the new Pointer objects that were created. + */ + addPointer: function (quantity) + { + return this.manager.addPointer(quantity); + }, + + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * + * @method Phaser.Input.InputPlugin#setDefaultCursor + * @since 3.10.0 + * + * @param {string} cursor - The CSS to be used when setting the default cursor. + * + * @return {this} This Input instance. + */ + setDefaultCursor: function (cursor) + { + this.manager.setDefaultCursor(cursor); + + return this; + }, + + /** + * The Scene that owns this plugin is transitioning in. + * + * @method Phaser.Input.InputPlugin#transitionIn + * @private + * @since 3.5.0 + */ + transitionIn: function () + { + this.enabled = this.settings.transitionAllowInput; + }, + + /** + * The Scene that owns this plugin has finished transitioning in. + * + * @method Phaser.Input.InputPlugin#transitionComplete + * @private + * @since 3.5.0 + */ + transitionComplete: function () + { + if (!this.settings.transitionAllowInput) + { + this.enabled = true; + } + }, + + /** + * The Scene that owns this plugin is transitioning out. + * + * @method Phaser.Input.InputPlugin#transitionOut + * @private + * @since 3.5.0 + */ + transitionOut: function () + { + this.enabled = this.settings.transitionAllowInput; + }, + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + * + * @method Phaser.Input.InputPlugin#shutdown + * @fires Phaser.Input.Events#SHUTDOWN + * @private + * @since 3.0.0 + */ + shutdown: function () + { + // Registered input plugins listen for this + this.pluginEvents.emit(Events.SHUTDOWN); + + this._temp.length = 0; + this._list.length = 0; + this._draggable.length = 0; + this._pendingRemoval.length = 0; + this._pendingInsertion.length = 0; + this._dragState.length = 0; + + for (var i = 0; i < 10; i++) + { + this._drag[i] = []; + this._over[i] = []; + } + + this.removeAllListeners(); + + var manager = this.manager; + + manager.canvas.style.cursor = manager.defaultCursor; + + var eventEmitter = this.systems.events; + + eventEmitter.off(SceneEvents.TRANSITION_START, this.transitionIn, this); + eventEmitter.off(SceneEvents.TRANSITION_OUT, this.transitionOut, this); + eventEmitter.off(SceneEvents.TRANSITION_COMPLETE, this.transitionComplete, this); + eventEmitter.off(SceneEvents.PRE_UPDATE, this.preUpdate, this); + + manager.events.off(Events.GAME_OUT, this.onGameOut, this); + manager.events.off(Events.GAME_OVER, this.onGameOver, this); + + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * Loops through all of the Input Manager Pointer instances and calls `reset` on them. + * + * Use this function if you find that input has been stolen from Phaser via a 3rd + * party component, such as Vue, and you need to tell Phaser to reset the Pointer states. + * + * @method Phaser.Input.InputPlugin#resetPointers + * @since 3.60.0 + */ + resetPointers: function () + { + var pointers = this.manager.pointers; + + for (var i = 0; i < pointers.length; i++) + { + pointers[i].reset(); + } + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Phaser.Input.InputPlugin#destroy + * @fires Phaser.Input.Events#DESTROY + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + // Registered input plugins listen for this + this.pluginEvents.emit(Events.DESTROY); + + this.pluginEvents.removeAllListeners(); + + this.scene.sys.events.off(SceneEvents.START, this.start, this); + + this.scene = null; + this.cameras = null; + this.manager = null; + this.events = null; + this.mouse = null; + }, + + /** + * The x coordinate of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#x + * @type {number} + * @readonly + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.manager.activePointer.x; + } + + }, + + /** + * The y coordinate of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#y + * @type {number} + * @readonly + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.manager.activePointer.y; + } + + }, + + /** + * Are any mouse or touch pointers currently over the game canvas? + * + * @name Phaser.Input.InputPlugin#isOver + * @type {boolean} + * @readonly + * @since 3.16.0 + */ + isOver: { + + get: function () + { + return this.manager.isOver; + } + + }, + + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + * + * @name Phaser.Input.InputPlugin#mousePointer + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + mousePointer: { + + get: function () + { + return this.manager.mousePointer; + } + + }, + + /** + * The current active input Pointer. + * + * @name Phaser.Input.InputPlugin#activePointer + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.0.0 + */ + activePointer: { + + get: function () + { + return this.manager.activePointer; + } + + }, + + /** + * A touch-based Pointer object. This is the first pointer created by Phaser and is available by default, + * alongside the `mousePointer`. + * + * @name Phaser.Input.InputPlugin#pointer1 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer1: { + + get: function () + { + return this.manager.pointers[1]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer2 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer2: { + + get: function () + { + return this.manager.pointers[2]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer3 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer3: { + + get: function () + { + return this.manager.pointers[3]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer4 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer4: { + + get: function () + { + return this.manager.pointers[4]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer5 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer5: { + + get: function () + { + return this.manager.pointers[5]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer6 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer6: { + + get: function () + { + return this.manager.pointers[6]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer7 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer7: { + + get: function () + { + return this.manager.pointers[7]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer8 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer8: { + + get: function () + { + return this.manager.pointers[8]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer9 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer9: { + + get: function () + { + return this.manager.pointers[9]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer10 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer10: { + + get: function () + { + return this.manager.pointers[10]; + } + + } + +}); + +PluginCache.register('InputPlugin', InputPlugin, 'input'); + +module.exports = InputPlugin; + + +/***/ }, + +/***/ 89639 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetValue = __webpack_require__(35154); + +// Contains the plugins that Phaser uses globally and locally. +// These are the source objects, not instantiated. +var inputPlugins = {}; + +/** + * @namespace Phaser.Input.InputPluginCache + */ + +var InputPluginCache = {}; + +/** + * Static method called directly by the core internal plugins. + * Key is a reference used to get the plugin from the input plugin cache. + * Plugin is the object to instantiate to create the plugin. + * Mapping is the property key used when the plugin is injected into the Input Plugin (e.g. `input`). + * + * @function Phaser.Input.InputPluginCache.register + * @static + * @since 3.10.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Input Plugin, this is the property key used. + * @param {string} settingsKey - The key in the Scene Settings to check to see if this plugin should install or not. + * @param {string} configKey - The key in the Game Config to check to see if this plugin should install or not. + */ +InputPluginCache.register = function (key, plugin, mapping, settingsKey, configKey) +{ + inputPlugins[key] = { plugin: plugin, mapping: mapping, settingsKey: settingsKey, configKey: configKey }; +}; + +/** + * Returns the input plugin object from the cache based on the given key. + * + * @function Phaser.Input.InputPluginCache.getPlugin + * @static + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to get. + * + * @return {Phaser.Types.Input.InputPluginContainer} The input plugin object. + */ +InputPluginCache.getPlugin = function (key) +{ + return inputPlugins[key]; +}; + +/** + * Installs all of the registered Input Plugins into the given target. + * + * @function Phaser.Input.InputPluginCache.install + * @static + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} target - The target InputPlugin to install the plugins into. + */ +InputPluginCache.install = function (target) +{ + var sys = target.scene.sys; + var settings = sys.settings.input; + var config = sys.game.config; + + for (var key in inputPlugins) + { + var source = inputPlugins[key].plugin; + var mapping = inputPlugins[key].mapping; + var settingsKey = inputPlugins[key].settingsKey; + var configKey = inputPlugins[key].configKey; + + if (GetValue(settings, settingsKey, config[configKey])) + { + target[mapping] = new source(target); + } + } +}; + +/** + * Removes an input plugin based on the given key. + * + * @function Phaser.Input.InputPluginCache.remove + * @static + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to remove. + */ +InputPluginCache.remove = function (key) +{ + if (inputPlugins.hasOwnProperty(key)) + { + delete inputPlugins[key]; + } +}; + +module.exports = InputPluginCache; + + +/***/ }, + +/***/ 42515 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Angle = __webpack_require__(31040); +var Class = __webpack_require__(83419); +var Distance = __webpack_require__(20339); +var FuzzyEqual = __webpack_require__(43855); +var SmoothStepInterpolation = __webpack_require__(47235); +var Vector2 = __webpack_require__(26099); +var OS = __webpack_require__(25892); + +/** + * @classdesc + * A Pointer object encapsulates both mouse and touch input within Phaser. + * + * By default, Phaser will create 2 pointers for your game to use. If you require more, i.e. for a multi-touch + * game, then use the `InputPlugin.addPointer` method to do so, rather than instantiating this class directly, + * otherwise it won't be managed by the input system. + * + * You can reference the current active pointer via `InputPlugin.activePointer`. You can also use the properties + * `InputPlugin.pointer1` through to `pointer10`, for each pointer you have enabled in your game. + * + * The properties of this object are set by the Input Plugin during processing. This object is then sent in all + * input related events that the Input Plugin emits, so you can reference properties from it directly in your + * callbacks. + * + * @class Pointer + * @memberof Phaser.Input + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} manager - A reference to the Input Manager. + * @param {number} id - The internal ID of this Pointer. + */ +var Pointer = new Class({ + + initialize: + + function Pointer (manager, id) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Pointer#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The internal ID of this Pointer. + * + * @name Phaser.Input.Pointer#id + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.id = id; + + /** + * The most recent native DOM Event this Pointer has processed. + * + * @name Phaser.Input.Pointer#event + * @type {(TouchEvent|MouseEvent|WheelEvent)} + * @since 3.0.0 + */ + this.event; + + /** + * The DOM element the Pointer was pressed down on, taken from the DOM event. + * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. + * + * @name Phaser.Input.Pointer#downElement + * @type {any} + * @readonly + * @since 3.16.0 + */ + this.downElement; + + /** + * The DOM element the Pointer was released on, taken from the DOM event. + * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. + * + * @name Phaser.Input.Pointer#upElement + * @type {any} + * @readonly + * @since 3.16.0 + */ + this.upElement; + + /** + * The camera the Pointer interacted with during its last update. + * + * A Pointer can only ever interact with one camera at once, which will be the top-most camera + * in the list should multiple cameras be positioned on-top of each other. + * + * @name Phaser.Input.Pointer#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = null; + + /** + * A read-only property that indicates which button was pressed, or released, on the pointer + * during the most recent event. It is only set during `up` and `down` events. + * + * On Touch devices the value is always 0. + * + * Users may change the configuration of buttons on their pointing device so that if an event's button property + * is zero, it may not have been caused by the button that is physically left–most on the pointing device; + * however, it should behave as if the left button was clicked in the standard button layout. + * + * @name Phaser.Input.Pointer#button + * @type {number} + * @readonly + * @default 0 + * @since 3.18.0 + */ + this.button = 0; + + /** + * A bitmask representing which mouse buttons are currently held down. The possible values are: + * + * 0: No button or un-initialized + * 1: Left button + * 2: Right button + * 4: Wheel button or middle button + * 8: 4th button (typically the "Browser Back" button) + * 16: 5th button (typically the "Browser Forward" button) + * + * For a mouse configured for left-handed use, the button actions are reversed. + * In this case, the values are read from right to left. + * + * @name Phaser.Input.Pointer#buttons + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.buttons = 0; + + /** + * The position of the Pointer in screen space. + * + * @name Phaser.Input.Pointer#position + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.position = new Vector2(); + + /** + * The previous position of the Pointer in screen space. + * + * The old x and y values are stored in here during the InputManager.transformPointer call. + * + * Use the properties `velocity`, `angle` and `distance` to create your own gesture recognition. + * + * @name Phaser.Input.Pointer#prevPosition + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.11.0 + */ + this.prevPosition = new Vector2(); + + /** + * An internal vector used for calculations of the pointer speed and angle. + * + * @name Phaser.Input.Pointer#midPoint + * @type {Phaser.Math.Vector2} + * @private + * @since 3.16.0 + */ + this.midPoint = new Vector2(-1, -1); + + /** + * The current velocity of the Pointer, based on its current and previous positions. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * @name Phaser.Input.Pointer#velocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.16.0 + */ + this.velocity = new Vector2(); + + /** + * The current angle the Pointer is moving, in radians, based on its previous and current position. + * + * The angle is based on the old position facing to the current position. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * @name Phaser.Input.Pointer#angle + * @type {number} + * @readonly + * @since 3.16.0 + */ + this.angle = 0; + + /** + * The distance the Pointer has moved, based on its previous and current position. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * If you need the total distance travelled since the primary button was pressed down, + * then use the `Pointer.getDistance` method. + * + * @name Phaser.Input.Pointer#distance + * @type {number} + * @readonly + * @since 3.16.0 + */ + this.distance = 0; + + /** + * The smoothing factor to apply to the Pointer position. + * + * Due to their nature, pointer positions are inherently noisy. While this is fine for lots of games, if you need cleaner positions + * then you can set this value to apply an automatic smoothing to the positions as they are recorded. + * + * The default value of zero means 'no smoothing'. + * Set to a small value, such as 0.2, to apply an average level of smoothing between positions. You can do this by changing this + * value directly, or by setting the `input.smoothFactor` property in the Game Config. + * + * Positions are only smoothed when the pointer moves. If the primary button on this Pointer enters an Up or Down state, then the position + * is always precise, and not smoothed. + * + * @name Phaser.Input.Pointer#smoothFactor + * @type {number} + * @default 0 + * @since 3.16.0 + */ + this.smoothFactor = 0; + + /** + * The factor applied to the motion smoothing each frame. + * + * This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, + * angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current + * position of the Pointer. 0.2 provides a good average but can be increased if you need a + * quicker update and are working in a high performance environment. Never set this value to + * zero. + * + * @name Phaser.Input.Pointer#motionFactor + * @type {number} + * @default 0.2 + * @since 3.16.0 + */ + this.motionFactor = 0.2; + + /** + * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + * + * If you wish to use this value _outside_ of an input event handler then you should update it first by calling + * the `Pointer.updateWorldPoint` method. + * + * @name Phaser.Input.Pointer#worldX + * @type {number} + * @default 0 + * @since 3.10.0 + */ + this.worldX = 0; + + /** + * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + * + * If you wish to use this value _outside_ of an input event handler then you should update it first by calling + * the `Pointer.updateWorldPoint` method. + * + * @name Phaser.Input.Pointer#worldY + * @type {number} + * @default 0 + * @since 3.10.0 + */ + this.worldY = 0; + + /** + * Time when this Pointer was most recently moved (regardless of the state of its buttons, if any). + * + * @name Phaser.Input.Pointer#moveTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.moveTime = 0; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downY = 0; + + /** + * The Event timestamp when the first button, or Touch input, was pressed. Used for dragging objects. + * + * @name Phaser.Input.Pointer#downTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downTime = 0; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upY = 0; + + /** + * The Event timestamp when the final button, or Touch input, was released. Used for dragging objects. + * + * @name Phaser.Input.Pointer#upTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upTime = 0; + + /** + * Is the primary button down? (usually button 0, the left mouse button) + * + * @name Phaser.Input.Pointer#primaryDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.primaryDown = false; + + /** + * Is _any_ button on this pointer considered as being down? + * + * @name Phaser.Input.Pointer#isDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isDown = false; + + /** + * Did the previous input event come from a Touch input (true) or Mouse? (false) + * + * @name Phaser.Input.Pointer#wasTouch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.wasTouch = false; + + /** + * Did this Pointer get canceled by a touchcancel event? + * + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! + * + * @name Phaser.Input.Pointer#wasCanceled + * @type {boolean} + * @default false + * @since 3.15.0 + */ + this.wasCanceled = false; + + /** + * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementX = 0; + + /** + * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementY = 0; + + /** + * The identifier property of the Pointer as set by the DOM event when this Pointer is started. + * + * @name Phaser.Input.Pointer#identifier + * @type {number} + * @since 3.10.0 + */ + this.identifier = 0; + + /** + * The pointerId property of the Pointer as set by the DOM event when this Pointer is started. + * The browser can and will recycle this value. + * + * @name Phaser.Input.Pointer#pointerId + * @type {number} + * @since 3.10.0 + */ + this.pointerId = null; + + /** + * An active Pointer is one that is currently pressed down on the display. + * A Mouse is always considered as active. + * + * @name Phaser.Input.Pointer#active + * @type {boolean} + * @since 3.10.0 + */ + this.active = (id === 0) ? true : false; + + /** + * Is this pointer Pointer Locked? + * + * Only a mouse pointer can be locked and it only becomes locked when requested via + * the browsers Pointer Lock API. + * + * You can request this by calling the `this.input.mouse.requestPointerLock()` method from + * a `pointerdown` or `pointerup` event handler. + * + * @name Phaser.Input.Pointer#locked + * @readonly + * @type {boolean} + * @since 3.19.0 + */ + this.locked = false; + + /** + * The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * + * @name Phaser.Input.Pointer#deltaX + * @type {number} + * @default 0 + * @since 3.18.0 + */ + this.deltaX = 0; + + /** + * The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + * + * @name Phaser.Input.Pointer#deltaY + * @type {number} + * @default 0 + * @since 3.18.0 + */ + this.deltaY = 0; + + /** + * The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * + * @name Phaser.Input.Pointer#deltaZ + * @type {number} + * @default 0 + * @since 3.18.0 + */ + this.deltaZ = 0; + }, + + /** + * Takes a Camera and updates this Pointer's `worldX` and `worldY` values so they are + * the result of a translation through the given Camera. + * + * Note that the values will be automatically replaced the moment the Pointer is + * updated by an input event, such as a mouse move, so should be used immediately. + * + * @method Phaser.Input.Pointer#updateWorldPoint + * @since 3.19.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. + * + * @return {this} This Pointer object. + */ + updateWorldPoint: function (camera) + { + // Stores the world point inside of tempPoint + var temp = camera.getWorldPoint(this.x, this.y); + + this.worldX = temp.x; + this.worldY = temp.y; + + return this; + }, + + /** + * Takes a Camera and returns a Vector2 containing the translated position of this Pointer + * within that Camera. This can be used to convert this Pointers position into camera space. + * + * @method Phaser.Input.Pointer#positionToCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the translation. + * @param {(Phaser.Math.Vector2|object)} [output] - A Vector2-like object in which to store the translated position. + * + * @return {(Phaser.Math.Vector2|object)} A Vector2 containing the translated coordinates of this Pointer, based on the given camera. + */ + positionToCamera: function (camera, output) + { + return camera.getWorldPoint(this.x, this.y, output); + }, + + /** + * Calculates the motion of this Pointer, including its velocity and angle of movement. + * This method is called automatically each frame by the Input Manager. + * + * @method Phaser.Input.Pointer#updateMotion + * @private + * @since 3.16.0 + */ + updateMotion: function () + { + var cx = this.position.x; + var cy = this.position.y; + + var mx = this.midPoint.x; + var my = this.midPoint.y; + + if (cx === mx && cy === my) + { + // Nothing to do here + return; + } + + // Moving towards our goal ... + var vx = SmoothStepInterpolation(this.motionFactor, mx, cx); + var vy = SmoothStepInterpolation(this.motionFactor, my, cy); + + if (FuzzyEqual(vx, cx, 0.1)) + { + vx = cx; + } + + if (FuzzyEqual(vy, cy, 0.1)) + { + vy = cy; + } + + this.midPoint.set(vx, vy); + + var dx = cx - vx; + var dy = cy - vy; + + this.velocity.set(dx, dy); + + this.angle = Angle(vx, vy, cx, cy); + + this.distance = Math.sqrt(dx * dx + dy * dy); + }, + + /** + * Internal method to handle a Mouse Up Event. + * + * @method Phaser.Input.Pointer#up + * @private + * @since 3.0.0 + * + * @param {MouseEvent} event - The Mouse Event to process. + */ + up: function (event) + { + if ('buttons' in event) + { + this.buttons = event.buttons; + } + + this.event = event; + + this.button = event.button; + + this.upElement = event.target; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY, false); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + } + + if (this.buttons === 0) + { + // No more buttons are still down + this.isDown = false; + + this.upTime = event.timeStamp; + + this.wasTouch = false; + } + }, + + /** + * Internal method to handle a Mouse Down Event. + * + * @method Phaser.Input.Pointer#down + * @private + * @since 3.0.0 + * + * @param {MouseEvent} event - The Mouse Event to process. + */ + down: function (event) + { + if ('buttons' in event) + { + this.buttons = event.buttons; + } + + this.event = event; + + this.button = event.button; + + this.downElement = event.target; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY, false); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + } + + if (OS.macOS && event.ctrlKey) + { + // Override button settings on macOS + this.buttons = 2; + this.primaryDown = false; + } + + if (!this.isDown) + { + this.isDown = true; + + this.downTime = event.timeStamp; + } + + this.wasTouch = false; + }, + + /** + * Internal method to handle a Mouse Move Event. + * + * @method Phaser.Input.Pointer#move + * @private + * @since 3.0.0 + * + * @param {MouseEvent} event - The Mouse Event to process. + */ + move: function (event) + { + if ('buttons' in event) + { + this.buttons = event.buttons; + } + + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY, true); + + if (this.locked) + { + // Multiple DOM events may occur within one frame, but only one Phaser event will fire + this.movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0; + this.movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0; + } + + this.moveTime = event.timeStamp; + + this.wasTouch = false; + }, + + /** + * Internal method to handle a Mouse Wheel Event. + * + * @method Phaser.Input.Pointer#wheel + * @private + * @since 3.18.0 + * + * @param {WheelEvent} event - The Wheel Event to process. + */ + wheel: function (event) + { + if ('buttons' in event) + { + this.buttons = event.buttons; + } + + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY, false); + + this.deltaX = event.deltaX; + this.deltaY = event.deltaY; + this.deltaZ = event.deltaZ; + + this.wasTouch = false; + }, + + /** + * Internal method to handle a Touch Start Event. + * + * @method Phaser.Input.Pointer#touchstart + * @private + * @since 3.0.0 + * + * @param {Touch} touch - The Changed Touch from the Touch Event. + * @param {TouchEvent} event - The full Touch Event. + */ + touchstart: function (touch, event) + { + if (touch['pointerId']) + { + this.pointerId = touch.pointerId; + } + + this.identifier = touch.identifier; + this.target = touch.target; + this.active = true; + + this.buttons = 1; + + this.event = event; + + this.downElement = touch.target; + + // Sets the local x/y properties + this.manager.transformPointer(this, touch.pageX, touch.pageY, false); + + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + this.downTime = event.timeStamp; + + this.isDown = true; + + this.wasTouch = true; + this.wasCanceled = false; + + this.updateMotion(); + }, + + /** + * Internal method to handle a Touch Move Event. + * + * @method Phaser.Input.Pointer#touchmove + * @private + * @since 3.0.0 + * + * @param {Touch} touch - The Changed Touch from the Touch Event. + * @param {TouchEvent} event - The full Touch Event. + */ + touchmove: function (touch, event) + { + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, touch.pageX, touch.pageY, true); + + this.moveTime = event.timeStamp; + + this.wasTouch = true; + + this.updateMotion(); + }, + + /** + * Internal method to handle a Touch End Event. + * + * @method Phaser.Input.Pointer#touchend + * @private + * @since 3.0.0 + * + * @param {Touch} touch - The Changed Touch from the Touch Event. + * @param {TouchEvent} event - The full Touch Event. + */ + touchend: function (touch, event) + { + this.buttons = 0; + + this.event = event; + + this.upElement = touch.target; + + // Sets the local x/y properties + this.manager.transformPointer(this, touch.pageX, touch.pageY, false); + + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = event.timeStamp; + + this.isDown = false; + + this.wasTouch = true; + this.wasCanceled = false; + + this.active = false; + + this.updateMotion(); + }, + + /** + * Internal method to handle a Touch Cancel Event. + * + * @method Phaser.Input.Pointer#touchcancel + * @private + * @since 3.15.0 + * + * @param {Touch} touch - The Changed Touch from the Touch Event. + * @param {TouchEvent} event - The full Touch Event. + */ + touchcancel: function (touch, event) + { + this.buttons = 0; + + this.event = event; + + this.upElement = touch.target; + + // Sets the local x/y properties + this.manager.transformPointer(this, touch.pageX, touch.pageY, false); + + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = event.timeStamp; + + this.isDown = false; + + this.wasTouch = true; + this.wasCanceled = true; + + this.active = false; + }, + + /** + * Checks to see if any buttons are being held down on this Pointer. + * + * @method Phaser.Input.Pointer#noButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if no buttons are being held down. + */ + noButtonDown: function () + { + return (this.buttons === 0); + }, + + /** + * Checks to see if the left button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#leftButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the left button is being held down. + */ + leftButtonDown: function () + { + return (this.buttons & 1) ? true : false; + }, + + /** + * Checks to see if the right button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#rightButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the right button is being held down. + */ + rightButtonDown: function () + { + return (this.buttons & 2) ? true : false; + }, + + /** + * Checks to see if the middle button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#middleButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the middle button is being held down. + */ + middleButtonDown: function () + { + return (this.buttons & 4) ? true : false; + }, + + /** + * Checks to see if the back button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#backButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the back button is being held down. + */ + backButtonDown: function () + { + return (this.buttons & 8) ? true : false; + }, + + /** + * Checks to see if the forward button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#forwardButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the forward button is being held down. + */ + forwardButtonDown: function () + { + return (this.buttons & 16) ? true : false; + }, + + /** + * Checks to see if the release of the left button was the most recent activity on this Pointer. + * + * @method Phaser.Input.Pointer#leftButtonReleased + * @since 3.18.0 + * + * @return {boolean} `true` if the release of the left button was the most recent activity on this Pointer. + */ + leftButtonReleased: function () + { + return this.buttons === 0 ? (this.button === 0 && !this.isDown) : this.button === 0; + }, + + /** + * Checks to see if the release of the right button was the most recent activity on this Pointer. + * + * @method Phaser.Input.Pointer#rightButtonReleased + * @since 3.18.0 + * + * @return {boolean} `true` if the release of the right button was the most recent activity on this Pointer. + */ + rightButtonReleased: function () + { + return this.buttons === 0 ? (this.button === 2 && !this.isDown) : this.button === 2; + }, + + /** + * Checks to see if the release of the middle button was the most recent activity on this Pointer. + * + * @method Phaser.Input.Pointer#middleButtonReleased + * @since 3.18.0 + * + * @return {boolean} `true` if the release of the middle button was the most recent activity on this Pointer. + */ + middleButtonReleased: function () + { + return this.buttons === 0 ? (this.button === 1 && !this.isDown) : this.button === 1; + }, + + /** + * Checks to see if the release of the back button was the most recent activity on this Pointer. + * + * @method Phaser.Input.Pointer#backButtonReleased + * @since 3.18.0 + * + * @return {boolean} `true` if the release of the back button was the most recent activity on this Pointer. + */ + backButtonReleased: function () + { + return this.buttons === 0 ? (this.button === 3 && !this.isDown) : this.button === 3; + }, + + /** + * Checks to see if the release of the forward button was the most recent activity on this Pointer. + * + * @method Phaser.Input.Pointer#forwardButtonReleased + * @since 3.18.0 + * + * @return {boolean} `true` if the release of the forward button was the most recent activity on this Pointer. + */ + forwardButtonReleased: function () + { + return this.buttons === 0 ? (this.button === 4 && !this.isDown) : this.button === 4; + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded distance, based on where + * the Pointer was when the button was released. + * + * If you wish to get the distance being travelled currently, based on the velocity of the Pointer, + * then see the `Pointer.distance` property. + * + * @method Phaser.Input.Pointer#getDistance + * @since 3.13.0 + * + * @return {number} The distance the Pointer moved. + */ + getDistance: function () + { + if (this.isDown) + { + return Distance(this.downX, this.downY, this.x, this.y); + } + else + { + return Distance(this.downX, this.downY, this.upX, this.upY); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * horizontal distance between the Pointer's `downX` value and the current `x` position. + * + * If no button is held down, it will return the last recorded horizontal distance, based on where + * the Pointer was when the button was released. + * + * @method Phaser.Input.Pointer#getDistanceX + * @since 3.16.0 + * + * @return {number} The horizontal distance the Pointer moved. + */ + getDistanceX: function () + { + if (this.isDown) + { + return Math.abs(this.downX - this.x); + } + else + { + return Math.abs(this.downX - this.upX); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * vertical distance between the Pointer's `downY` value and the current `y` position. + * + * If no button is held down, it will return the last recorded vertical distance, based on where + * the Pointer was when the button was released. + * + * @method Phaser.Input.Pointer#getDistanceY + * @since 3.16.0 + * + * @return {number} The vertical distance the Pointer moved. + */ + getDistanceY: function () + { + if (this.isDown) + { + return Math.abs(this.downY - this.y); + } + else + { + return Math.abs(this.downY - this.upY); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * duration since the button was pressed down. + * + * If no button is held down, it will return the last recorded duration, based on the time + * the last button on the Pointer was released. + * + * @method Phaser.Input.Pointer#getDuration + * @since 3.16.0 + * + * @return {number} The duration the Pointer was held down for in milliseconds. + */ + getDuration: function () + { + if (this.isDown) + { + return (this.manager.time - this.downTime); + } + else + { + return (this.upTime - this.downTime); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * angle between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded angle, based on where + * the Pointer was when the button was released. + * + * The angle is based on the old position facing to the current position. + * + * If you wish to get the current angle, based on the velocity of the Pointer, then + * see the `Pointer.angle` property. + * + * @method Phaser.Input.Pointer#getAngle + * @since 3.16.0 + * + * @return {number} The angle between the Pointer's coordinates in radians. + */ + getAngle: function () + { + if (this.isDown) + { + return Angle(this.downX, this.downY, this.x, this.y); + } + else + { + return Angle(this.downX, this.downY, this.upX, this.upY); + } + }, + + /** + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. + * + * ```javascript + * var points = pointer.getInterpolatedPosition(4); + * + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } + * ``` + * + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. + * + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. + * + * Internally it uses the Smooth Step interpolation calculation. + * + * @method Phaser.Input.Pointer#getInterpolatedPosition + * @since 3.11.0 + * + * @param {number} [steps=10] - The number of interpolation steps to use. + * @param {array} [out] - An array to store the results in. If not provided a new one will be created. + * + * @return {array} An array of interpolated values. + */ + getInterpolatedPosition: function (steps, out) + { + if (steps === undefined) { steps = 10; } + if (out === undefined) { out = []; } + + var prevX = this.prevPosition.x; + var prevY = this.prevPosition.y; + + var curX = this.position.x; + var curY = this.position.y; + + for (var i = 0; i < steps; i++) + { + var t = (1 / steps) * i; + + out[i] = { x: SmoothStepInterpolation(t, prevX, curX), y: SmoothStepInterpolation(t, prevY, curY) }; + } + + return out; + }, + + /** + * Fully reset this Pointer back to its uninitialized state. + * + * @method Phaser.Input.Pointer#reset + * @since 3.60.0 + */ + reset: function () + { + this.event = null; + this.downElement = null; + this.upElement = null; + + this.button = 0; + this.buttons = 0; + + this.position.set(0, 0); + this.prevPosition.set(0, 0); + this.midPoint.set(-1, -1); + this.velocity.set(0, 0); + this.angle = 0; + this.distance = 0; + this.worldX = 0; + this.worldY = 0; + this.downX = 0; + this.downY = 0; + this.upX = 0; + this.upY = 0; + this.moveTime = 0; + this.upTime = 0; + this.downTime = 0; + this.primaryDown = false; + this.isDown = false; + this.wasTouch = false; + this.wasCanceled = false; + this.movementX = 0; + this.movementY = 0; + this.identifier = 0; + this.pointerId = null; + this.deltaX = 0; + this.deltaY = 0; + this.deltaZ = 0; + + this.active = (this.id === 0) ? true : false; + }, + + /** + * Destroys this Pointer instance and resets its external references. + * + * @method Phaser.Input.Pointer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + this.manager = null; + this.position = null; + }, + + /** + * The x position of this Pointer. + * The value is in screen space. + * See `worldX` to get a camera converted position. + * + * @name Phaser.Input.Pointer#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The y position of this Pointer. + * The value is in screen space. + * See `worldY` to get a camera converted position. + * + * @name Phaser.Input.Pointer#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + }, + + /** + * Time when this Pointer was most recently updated by a DOM Event. + * This comes directly from the `event.timeStamp` property. + * If no event has yet taken place, it will return zero. + * + * @name Phaser.Input.Pointer#time + * @type {number} + * @readonly + * @since 3.16.0 + */ + time: { + + get: function () + { + return (this.event) ? this.event.timeStamp : 0; + } + + } + +}); + +module.exports = Pointer; + + +/***/ }, + +/***/ 93301 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var INPUT_CONST = { + + /** + * The mouse pointer button has been pressed down. + * + * @name Phaser.Input.MOUSE_DOWN + * @type {number} + * @since 3.10.0 + */ + MOUSE_DOWN: 0, + + /** + * The mouse pointer is being moved. + * + * @name Phaser.Input.MOUSE_MOVE + * @type {number} + * @since 3.10.0 + */ + MOUSE_MOVE: 1, + + /** + * The mouse pointer is released. + * + * @name Phaser.Input.MOUSE_UP + * @type {number} + * @since 3.10.0 + */ + MOUSE_UP: 2, + + /** + * A touch pointer has been started. + * + * @name Phaser.Input.TOUCH_START + * @type {number} + * @since 3.10.0 + */ + TOUCH_START: 3, + + /** + * A touch pointer has been moved. + * + * @name Phaser.Input.TOUCH_MOVE + * @type {number} + * @since 3.10.0 + */ + TOUCH_MOVE: 4, + + /** + * A touch pointer has ended. + * + * @name Phaser.Input.TOUCH_END + * @type {number} + * @since 3.10.0 + */ + TOUCH_END: 5, + + /** + * The pointer lock has changed. + * + * @name Phaser.Input.POINTER_LOCK_CHANGE + * @type {number} + * @since 3.10.0 + */ + POINTER_LOCK_CHANGE: 6, + + /** + * A touch pointer has been cancelled by the browser. + * + * @name Phaser.Input.TOUCH_CANCEL + * @type {number} + * @since 3.15.0 + */ + TOUCH_CANCEL: 7, + + /** + * The mouse wheel has changed. + * + * @name Phaser.Input.MOUSE_WHEEL + * @type {number} + * @since 3.18.0 + */ + MOUSE_WHEEL: 8 + +}; + +module.exports = INPUT_CONST; + + +/***/ }, + +/***/ 7179 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Boot Event. + * + * This internal event is dispatched by the Input Plugin when it boots, signalling to all of its systems to create themselves. + * + * @event Phaser.Input.Events#BOOT + * @type {string} + * @since 3.0.0 + */ +module.exports = 'boot'; + + +/***/ }, + +/***/ 85375 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Destroy Event. + * + * This internal event is dispatched by the Input Plugin when it is destroyed, signalling to all of its systems to destroy themselves. + * + * @event Phaser.Input.Events#DESTROY + * @type {string} + * @since 3.0.0 + */ +module.exports = 'destroy'; + + +/***/ }, + +/***/ 62224 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Drag End Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer stops dragging a Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('dragend', listener)`. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_END]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_END} event instead. + * + * @event Phaser.Input.Events#DRAG_END + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer stopped dragging. + * @param {boolean} dropped - Whether the Game Object was dropped onto a target. + */ +module.exports = 'dragend'; + + +/***/ }, + +/***/ 23388 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Drag Enter Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object into a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragenter', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_ENTER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_ENTER} event instead. + * + * @event Phaser.Input.Events#DRAG_ENTER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer is dragging. + * @param {Phaser.GameObjects.GameObject} target - The drag target that this pointer has moved into. + */ +module.exports = 'dragenter'; + + +/***/ }, + +/***/ 16133 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Drag Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves while dragging a Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('drag', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG} event instead. + * + * @event Phaser.Input.Events#DRAG + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer is dragging. + * @param {number} dragX - The x coordinate where the Pointer is currently dragging the Game Object, in world space. + * @param {number} dragY - The y coordinate where the Pointer is currently dragging the Game Object, in world space. + */ +module.exports = 'drag'; + + +/***/ }, + +/***/ 27829 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Drag Leave Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object out of a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragleave', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_LEAVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_LEAVE} event instead. + * + * @event Phaser.Input.Events#DRAG_LEAVE + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer is dragging. + * @param {Phaser.GameObjects.GameObject} target - The drag target that this pointer has left. + */ +module.exports = 'dragleave'; + + +/***/ }, + +/***/ 53904 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Drag Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object over a Drag Target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from within a Scene using: `this.input.on('dragover', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_OVER} event instead. + * + * @event Phaser.Input.Events#DRAG_OVER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer is dragging. + * @param {Phaser.GameObjects.GameObject} target - The drag target that this pointer has moved over. + */ +module.exports = 'dragover'; + + +/***/ }, + +/***/ 56058 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Drag Start Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer starts to drag any Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('dragstart', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_START]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_START} event instead. + * + * @event Phaser.Input.Events#DRAG_START + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer is dragging. + */ +module.exports = 'dragstart'; + + +/***/ }, + +/***/ 2642 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Drop Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drops a Game Object on a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('drop', listener)`. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DROP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DROP} event instead. + * + * @event Phaser.Input.Events#DROP + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer was dragging. + * @param {Phaser.GameObjects.GameObject} target - The Drag Target the `gameObject` has been dropped on. + */ +module.exports = 'drop'; + + +/***/ }, + +/***/ 88171 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Down Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down on _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectdown', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_DOWN + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was pressed down on. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'gameobjectdown'; + + +/***/ }, + +/***/ 36147 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Drag End Event. + * + * This event is dispatched by an interactive Game Object if a pointer stops dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragend', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive](Phaser.GameObjects.GameObject#setInteractive) for more details. + * + * @event Phaser.Input.Events#GAMEOBJECT_DRAG_END + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} dragX - The x coordinate where the Pointer stopped dragging the Game Object, in world space. + * @param {number} dragY - The y coordinate where the Pointer stopped dragging the Game Object, in world space. + * @param {boolean} dropped - Whether the Game Object was dropped onto a target. + */ +module.exports = 'dragend'; + + +/***/ }, + +/***/ 71692 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Drag Enter Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it into a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragenter', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * @event Phaser.Input.Events#GAMEOBJECT_DRAG_ENTER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} target - The drag target that this pointer has moved into. + */ +module.exports = 'dragenter'; + + +/***/ }, + +/***/ 96149 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Drag Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves while dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('drag', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * @event Phaser.Input.Events#GAMEOBJECT_DRAG + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} dragX - The x coordinate where the Pointer is currently dragging the Game Object, in world space. + * @param {number} dragY - The y coordinate where the Pointer is currently dragging the Game Object, in world space. + */ +module.exports = 'drag'; + + +/***/ }, + +/***/ 81285 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Drag Leave Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it out of a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragleave', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * @event Phaser.Input.Events#GAMEOBJECT_DRAG_LEAVE + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} target - The drag target that this pointer has left. + */ +module.exports = 'dragleave'; + + +/***/ }, + +/***/ 74048 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Drag Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it over a drag target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from a Game Object using: `gameObject.on('dragover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * @event Phaser.Input.Events#GAMEOBJECT_DRAG_OVER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} target - The drag target that this pointer has moved over. + */ +module.exports = 'dragover'; + + +/***/ }, + +/***/ 21322 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Drag Start Event. + * + * This event is dispatched by an interactive Game Object if a pointer starts to drag it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragstart', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * There are lots of useful drag related properties that are set within the Game Object when dragging occurs. + * For example, `gameObject.input.dragStartX`, `dragStartY` and so on. + * + * @event Phaser.Input.Events#GAMEOBJECT_DRAG_START + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} dragX - The x coordinate where the Pointer is currently dragging the Game Object, in world space. + * @param {number} dragY - The y coordinate where the Pointer is currently dragging the Game Object, in world space. + */ +module.exports = 'dragstart'; + + +/***/ }, + +/***/ 49378 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Drop Event. + * + * This event is dispatched by an interactive Game Object if a pointer drops it on a Drag Target. + * + * Listen to this event from a Game Object using: `gameObject.on('drop', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * @event Phaser.Input.Events#GAMEOBJECT_DROP + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} target - The Drag Target the `gameObject` has been dropped on. + */ +module.exports = 'drop'; + + +/***/ }, + +/***/ 86754 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Move Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved across _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectmove', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_MOVE + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was moved on. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'gameobjectmove'; + + +/***/ }, + +/***/ 86433 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Out Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectout', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * If the pointer leaves the game canvas itself, it will not trigger this event. To handle those cases, + * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. + * + * @event Phaser.Input.Events#GAMEOBJECT_OUT + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer moved out of. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'gameobjectout'; + + +/***/ }, + +/***/ 60709 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectover', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_OVER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer moved over. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'gameobjectover'; + + +/***/ }, + +/***/ 24081 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Pointer Down Event. + * + * This event is dispatched by an interactive Game Object if a pointer is pressed down on it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerdown', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_POINTER_DOWN + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'pointerdown'; + + +/***/ }, + +/***/ 11172 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Pointer Move Event. + * + * This event is dispatched by an interactive Game Object if a pointer is moved while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointermove', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_POINTER_MOVE + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'pointermove'; + + +/***/ }, + +/***/ 18907 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Pointer Out Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves out of it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerout', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * If the pointer leaves the game canvas itself, it will not trigger this event. To handle those cases, + * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. + * + * @event Phaser.Input.Events#GAMEOBJECT_POINTER_OUT + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'pointerout'; + + +/***/ }, + +/***/ 95579 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Pointer Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_POINTER_OVER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'pointerover'; + + +/***/ }, + +/***/ 35368 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Pointer Up Event. + * + * This event is dispatched by an interactive Game Object if a pointer is released while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerup', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_POINTER_UP + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'pointerup'; + + +/***/ }, + +/***/ 26972 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Pointer Wheel Event. + * + * This event is dispatched by an interactive Game Object if a pointer has its wheel moved while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('wheel', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_POINTER_WHEEL + * @type {string} + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} deltaX - The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {number} deltaY - The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + * @param {number} deltaZ - The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'wheel'; + + +/***/ }, + +/***/ 47078 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released while over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectup', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_UP + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was over when released. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'gameobjectup'; + + +/***/ }, + +/***/ 73802 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Wheel Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel moved while over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectwheel', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_WHEEL + * @type {string} + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was over when the wheel changed. + * @param {number} deltaX - The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {number} deltaY - The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + * @param {number} deltaZ - The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'gameobjectwheel'; + + +/***/ }, + +/***/ 56718 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Game Out Event. + * + * This event is dispatched by the Input Plugin if the active pointer leaves the game canvas and is now + * outside of it, elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameout', listener)`. + * + * @event Phaser.Input.Events#GAME_OUT + * @type {string} + * @since 3.16.1 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {(MouseEvent|TouchEvent)} event - The DOM Event that triggered the canvas out. + */ +module.exports = 'gameout'; + + +/***/ }, + +/***/ 25936 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Game Over Event. + * + * This event is dispatched by the Input Plugin if the active pointer enters the game canvas and is now + * over it, having previously been elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameover', listener)`. + * + * @event Phaser.Input.Events#GAME_OVER + * @type {string} + * @since 3.16.1 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {(MouseEvent|TouchEvent)} event - The DOM Event that triggered the canvas over. + */ +module.exports = 'gameover'; + + +/***/ }, + +/***/ 27503 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Manager Boot Event. + * + * This internal event is dispatched by the Input Manager when it boots. + * + * @event Phaser.Input.Events#MANAGER_BOOT + * @type {string} + * @since 3.0.0 + */ +module.exports = 'boot'; + + +/***/ }, + +/***/ 50852 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Manager Process Event. + * + * This internal event is dispatched by the Input Manager when not using the legacy queue system, + * and it wants the Input Plugins to update themselves. + * + * @event Phaser.Input.Events#MANAGER_PROCESS + * @type {string} + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ +module.exports = 'process'; + + +/***/ }, + +/***/ 96438 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Manager Update Event. + * + * This internal event is dispatched by the Input Manager as part of its update step. + * + * @event Phaser.Input.Events#MANAGER_UPDATE + * @type {string} + * @since 3.0.0 + */ +module.exports = 'update'; + + +/***/ }, + +/***/ 59152 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Manager Pointer Lock Change Event. + * + * This event is dispatched by the Input Manager when it is processing a native Pointer Lock Change DOM Event. + * + * @event Phaser.Input.Events#POINTERLOCK_CHANGE + * @type {string} + * @since 3.0.0 + * + * @param {Event} event - The native DOM Event. + * @param {boolean} locked - The locked state of the Mouse Pointer. + */ +module.exports = 'pointerlockchange'; + + +/***/ }, + +/***/ 47777 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Down Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdown', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_DOWN + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created. + */ +module.exports = 'pointerdown'; + + +/***/ }, + +/***/ 27957 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Down Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdownoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_DOWN_OUTSIDE + * @type {string} + * @since 3.16.1 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + */ +module.exports = 'pointerdownoutside'; + + +/***/ }, + +/***/ 19444 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Move Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointermove', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_MOVE + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created. + */ +module.exports = 'pointermove'; + + +/***/ }, + +/***/ 54251 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Out Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of any interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('pointerout', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * If the pointer leaves the game canvas itself, it will not trigger this event. To handle those cases, + * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. + * + * @event Phaser.Input.Events#POINTER_OUT + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject[]} justOut - An array containing all interactive Game Objects that the pointer moved out of when the event was created. + */ +module.exports = 'pointerout'; + + +/***/ }, + +/***/ 18667 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over any interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('pointerover', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_OVER + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject[]} justOver - An array containing all interactive Game Objects that the pointer moved over when the event was created. + */ +module.exports = 'pointerover'; + + +/***/ }, + +/***/ 27192 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_UP + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created. + */ +module.exports = 'pointerup'; + + +/***/ }, + +/***/ 24652 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Up Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerupoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_UP_OUTSIDE + * @type {string} + * @since 3.16.1 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + */ +module.exports = 'pointerupoutside'; + + +/***/ }, + +/***/ 45132 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Wheel Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel updated. + * + * Listen to this event from within a Scene using: `this.input.on('wheel', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_WHEEL + * @type {string} + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created. + * @param {number} deltaX - The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {number} deltaY - The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + * @param {number} deltaZ - The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + */ +module.exports = 'wheel'; + + +/***/ }, + +/***/ 44512 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Pre-Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `preUpdate` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + * + * @event Phaser.Input.Events#PRE_UPDATE + * @type {string} + * @since 3.0.0 + */ +module.exports = 'preupdate'; + + +/***/ }, + +/***/ 15757 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Shutdown Event. + * + * This internal event is dispatched by the Input Plugin when it shuts down, signalling to all of its systems to shut themselves down. + * + * @event Phaser.Input.Events#SHUTDOWN + * @type {string} + * @since 3.0.0 + */ +module.exports = 'shutdown'; + + +/***/ }, + +/***/ 41637 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Start Event. + * + * This internal event is dispatched by the Input Plugin when it has finished setting-up, + * signalling to all of its internal systems to start. + * + * @event Phaser.Input.Events#START + * @type {string} + * @since 3.0.0 + */ +module.exports = 'start'; + + +/***/ }, + +/***/ 93802 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Input Plugin Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `update` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + * + * @event Phaser.Input.Events#UPDATE + * @type {string} + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ +module.exports = 'update'; + + +/***/ }, + +/***/ 8214 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Events + */ + +module.exports = { + + BOOT: __webpack_require__(7179), + DESTROY: __webpack_require__(85375), + DRAG_END: __webpack_require__(62224), + DRAG_ENTER: __webpack_require__(23388), + DRAG: __webpack_require__(16133), + DRAG_LEAVE: __webpack_require__(27829), + DRAG_OVER: __webpack_require__(53904), + DRAG_START: __webpack_require__(56058), + DROP: __webpack_require__(2642), + GAME_OUT: __webpack_require__(56718), + GAME_OVER: __webpack_require__(25936), + GAMEOBJECT_DOWN: __webpack_require__(88171), + GAMEOBJECT_DRAG_END: __webpack_require__(36147), + GAMEOBJECT_DRAG_ENTER: __webpack_require__(71692), + GAMEOBJECT_DRAG: __webpack_require__(96149), + GAMEOBJECT_DRAG_LEAVE: __webpack_require__(81285), + GAMEOBJECT_DRAG_OVER: __webpack_require__(74048), + GAMEOBJECT_DRAG_START: __webpack_require__(21322), + GAMEOBJECT_DROP: __webpack_require__(49378), + GAMEOBJECT_MOVE: __webpack_require__(86754), + GAMEOBJECT_OUT: __webpack_require__(86433), + GAMEOBJECT_OVER: __webpack_require__(60709), + GAMEOBJECT_POINTER_DOWN: __webpack_require__(24081), + GAMEOBJECT_POINTER_MOVE: __webpack_require__(11172), + GAMEOBJECT_POINTER_OUT: __webpack_require__(18907), + GAMEOBJECT_POINTER_OVER: __webpack_require__(95579), + GAMEOBJECT_POINTER_UP: __webpack_require__(35368), + GAMEOBJECT_POINTER_WHEEL: __webpack_require__(26972), + GAMEOBJECT_UP: __webpack_require__(47078), + GAMEOBJECT_WHEEL: __webpack_require__(73802), + MANAGER_BOOT: __webpack_require__(27503), + MANAGER_PROCESS: __webpack_require__(50852), + MANAGER_UPDATE: __webpack_require__(96438), + POINTER_DOWN: __webpack_require__(47777), + POINTER_DOWN_OUTSIDE: __webpack_require__(27957), + POINTER_MOVE: __webpack_require__(19444), + POINTER_OUT: __webpack_require__(54251), + POINTER_OVER: __webpack_require__(18667), + POINTER_UP: __webpack_require__(27192), + POINTER_UP_OUTSIDE: __webpack_require__(24652), + POINTER_WHEEL: __webpack_require__(45132), + POINTERLOCK_CHANGE: __webpack_require__(59152), + PRE_UPDATE: __webpack_require__(44512), + SHUTDOWN: __webpack_require__(15757), + START: __webpack_require__(41637), + UPDATE: __webpack_require__(93802) + +}; + + +/***/ }, + +/***/ 97421 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * Represents a single axis on a Gamepad controller, such as one direction of an analog stick. + * Each axis has a `value` property ranging from -1 to 1 (with 0 as dead center), and a + * configurable `threshold` below which the value is treated as zero by `getValue()`. Axis + * objects are created automatically by the Gamepad as they are needed. + * + * @class Axis + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.Gamepad} pad - A reference to the Gamepad that this Axis belongs to. + * @param {number} index - The index of this Axis. + */ +var Axis = new Class({ + + initialize: + + function Axis (pad, index) + { + /** + * A reference to the Gamepad that this Axis belongs to. + * + * @name Phaser.Input.Gamepad.Axis#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; + + /** + * An event emitter to use to emit the axis events. + * + * @name Phaser.Input.Gamepad.Axis#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = pad.events; + + /** + * The index of this Axis. + * + * @name Phaser.Input.Gamepad.Axis#index + * @type {number} + * @since 3.0.0 + */ + this.index = index; + + /** + * The raw axis value, between -1 and 1 with 0 being dead center. + * Use the method `getValue` to get a normalized value with the threshold applied. + * + * @name Phaser.Input.Gamepad.Axis#value + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + /** + * Movement tolerance threshold below which axis values are ignored in `getValue`. + * + * @name Phaser.Input.Gamepad.Axis#threshold + * @type {number} + * @default 0.1 + * @since 3.0.0 + */ + this.threshold = 0.1; + }, + + /** + * Internal update handler for this Axis. + * Called automatically by the Gamepad as part of its update. + * + * @method Phaser.Input.Gamepad.Axis#update + * @private + * @since 3.0.0 + * + * @param {number} value - The value of the axis movement. + */ + update: function (value) + { + this.value = value; + }, + + /** + * Returns the axis value after applying the dead zone threshold. If the absolute value + * of the axis is less than `threshold`, zero is returned instead, preventing minor stick + * drift from registering as intentional input. Otherwise the raw `value` is returned. + * + * @method Phaser.Input.Gamepad.Axis#getValue + * @since 3.0.0 + * + * @return {number} The axis value, adjusted for the movement threshold. + */ + getValue: function () + { + return (Math.abs(this.value) < this.threshold) ? 0 : this.value; + }, + + /** + * Destroys this Axis instance and releases external references it holds. + * + * @method Phaser.Input.Gamepad.Axis#destroy + * @since 3.10.0 + */ + destroy: function () + { + this.pad = null; + this.events = null; + } + +}); + +module.exports = Axis; + + +/***/ }, + +/***/ 28884 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Events = __webpack_require__(92734); + +/** + * @classdesc + * Represents a single button on a Gamepad controller. Each Button has a `value` between 0 and 1 + * (supporting analog pressure for triggers) and a `pressed` boolean state. When the value exceeds + * the configurable `threshold`, the button emits `BUTTON_DOWN` and `GAMEPAD_BUTTON_DOWN` events. + * Button objects are created automatically by the Gamepad as they are needed. + * + * @class Button + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.Gamepad} pad - A reference to the Gamepad that this Button belongs to. + * @param {number} index - The index of this Button. + * @param {boolean} [isPressed=false] - Whether or not the button is already being pressed at creation time. This prevents the Button from emitting spurious 'down' events at first update. + */ +var Button = new Class({ + + initialize: + + function Button (pad, index, isPressed) + { + if (isPressed === undefined) { isPressed = false; } + + /** + * A reference to the Gamepad that this Button belongs to. + * + * @name Phaser.Input.Gamepad.Button#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; + + /** + * An event emitter to use to emit the button events. + * + * @name Phaser.Input.Gamepad.Button#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = pad.manager; + + /** + * The index of this Button. + * + * @name Phaser.Input.Gamepad.Button#index + * @type {number} + * @since 3.0.0 + */ + this.index = index; + + /** + * The current value of the button, between 0 (fully released) and 1 (fully pressed). + * For analog buttons like triggers, this reflects the pressure applied. + * + * @name Phaser.Input.Gamepad.Button#value + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + /** + * The minimum value the button must reach before it is considered as being pressed. + * The value is between 0 and 1. The default of 1 requires the button to be fully pressed. + * For analog buttons such as triggers, you can lower this threshold to detect partial presses. + * + * @name Phaser.Input.Gamepad.Button#threshold + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.threshold = 1; + + /** + * Is the Button being pressed down or not? + * + * @name Phaser.Input.Gamepad.Button#pressed + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pressed = isPressed; + }, + + /** + * Internal update handler for this Button. + * Called automatically by the Gamepad as part of its update. + * + * @method Phaser.Input.Gamepad.Button#update + * @fires Phaser.Input.Gamepad.Events#BUTTON_DOWN + * @fires Phaser.Input.Gamepad.Events#BUTTON_UP + * @fires Phaser.Input.Gamepad.Events#GAMEPAD_BUTTON_DOWN + * @fires Phaser.Input.Gamepad.Events#GAMEPAD_BUTTON_UP + * @private + * @since 3.0.0 + * + * @param {number} value - The value of the button. Between 0 and 1. + */ + update: function (value) + { + this.value = value; + + var pad = this.pad; + var index = this.index; + + if (value >= this.threshold) + { + if (!this.pressed) + { + this.pressed = true; + this.events.emit(Events.BUTTON_DOWN, pad, this, value); + this.pad.emit(Events.GAMEPAD_BUTTON_DOWN, index, value, this); + } + } + else if (this.pressed) + { + this.pressed = false; + this.events.emit(Events.BUTTON_UP, pad, this, value); + this.pad.emit(Events.GAMEPAD_BUTTON_UP, index, value, this); + } + }, + + /** + * Destroys this Button instance and releases external references it holds. + * + * @method Phaser.Input.Gamepad.Button#destroy + * @since 3.10.0 + */ + destroy: function () + { + this.pad = null; + this.events = null; + } + +}); + +module.exports = Button; + + +/***/ }, + +/***/ 99125 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Axis = __webpack_require__(97421); +var Button = __webpack_require__(28884); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Vector2 = __webpack_require__(26099); + +/** + * @classdesc + * Represents a single connected gamepad controller. Each Gamepad contains Button and Axis + * objects that are automatically created and updated by the Gamepad Plugin. You can access + * the directional sticks via the `leftStick` and `rightStick` Vector2 properties, individual + * buttons via the `buttons` array, and axes via the `axes` array. Gamepads are typically + * accessed through `this.input.gamepad.pad1` through `pad4` in a Scene. + * + * @class Gamepad + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.GamepadPlugin} manager - A reference to the Gamepad Plugin. + * @param {Phaser.Types.Input.Gamepad.Pad} pad - The Gamepad object, as extracted from GamepadEvent. + */ +var Gamepad = new Class({ + + Extends: EventEmitter, + + initialize: + + function Gamepad (manager, pad) + { + EventEmitter.call(this); + + /** + * A reference to the Gamepad Plugin. + * + * @name Phaser.Input.Gamepad.Gamepad#manager + * @type {Phaser.Input.Gamepad.GamepadPlugin} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * A reference to the native Gamepad object that is connected to the browser. + * + * @name Phaser.Input.Gamepad.Gamepad#pad + * @type {any} + * @since 3.10.0 + */ + this.pad = pad; + + /** + * A string containing some information about the controller. + * + * This is not strictly specified, but in Firefox it will contain three pieces of information + * separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and + * product id of the controller, and the name of the controller as provided by the driver. + * In Chrome it will contain the name of the controller as provided by the driver, + * followed by vendor and product 4-digit hexadecimal strings. + * + * @name Phaser.Input.Gamepad.Gamepad#id + * @type {string} + * @since 3.0.0 + */ + this.id = pad.id; + + /** + * An integer that is unique for each Gamepad currently connected to the system. + * This can be used to distinguish multiple controllers. + * Note that disconnecting a device and then connecting a new device may reuse the previous index. + * + * @name Phaser.Input.Gamepad.Gamepad#index + * @type {number} + * @since 3.0.0 + */ + this.index = pad.index; + + var buttons = []; + + for (var i = 0; i < pad.buttons.length; i++) + { + buttons.push(new Button(this, i, (pad.buttons[i].value >= 0.5))); + } + + /** + * An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad. + * + * @name Phaser.Input.Gamepad.Gamepad#buttons + * @type {Phaser.Input.Gamepad.Button[]} + * @since 3.0.0 + */ + this.buttons = buttons; + + var axes = []; + + for (i = 0; i < pad.axes.length; i++) + { + axes.push(new Axis(this, i)); + } + + /** + * An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any. + * + * @name Phaser.Input.Gamepad.Gamepad#axes + * @type {Phaser.Input.Gamepad.Axis[]} + * @since 3.0.0 + */ + this.axes = axes; + + /** + * The Gamepad's Haptic Actuator (Vibration / Rumble support). + * This is highly experimental and only set if both present on the device, + * and exposed by both the hardware and browser. + * + * @name Phaser.Input.Gamepad.Gamepad#vibration + * @type {GamepadHapticActuator} + * @since 3.10.0 + */ + this.vibration = pad.vibrationActuator; + + // https://w3c.github.io/gamepad/#remapping + + var _noButton = { value: 0, pressed: false }; + + /** + * A reference to the Left Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCLeft + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCLeft = (buttons[14]) ? buttons[14] : _noButton; + + /** + * A reference to the Right Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCRight + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCRight = (buttons[15]) ? buttons[15] : _noButton; + + /** + * A reference to the Top Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCTop = (buttons[12]) ? buttons[12] : _noButton; + + /** + * A reference to the Bottom Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCBottom = (buttons[13]) ? buttons[13] : _noButton; + + /** + * A reference to the Left Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCLeft + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCLeft = (buttons[2]) ? buttons[2] : _noButton; + + /** + * A reference to the Right Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCRight + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCRight = (buttons[1]) ? buttons[1] : _noButton; + + /** + * A reference to the Top Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCTop = (buttons[3]) ? buttons[3] : _noButton; + + /** + * A reference to the Bottom Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCBottom = (buttons[0]) ? buttons[0] : _noButton; + + /** + * A reference to the Top Left Front Button (L1 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBLeftTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBLeftTop = (buttons[4]) ? buttons[4] : _noButton; + + /** + * A reference to the Bottom Left Front Button (L2 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBLeftBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBLeftBottom = (buttons[6]) ? buttons[6] : _noButton; + + /** + * A reference to the Top Right Front Button (R1 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBRightTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBRightTop = (buttons[5]) ? buttons[5] : _noButton; + + /** + * A reference to the Bottom Right Front Button (R2 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBRightBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBRightBottom = (buttons[7]) ? buttons[7] : _noButton; + + var _noAxis = { value: 0 }; + + /** + * A reference to the Horizontal Axis for the Left Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_HAxisLeft + * @type {Phaser.Input.Gamepad.Axis} + * @private + * @since 3.10.0 + */ + this._HAxisLeft = (axes[0]) ? axes[0] : _noAxis; + + /** + * A reference to the Vertical Axis for the Left Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_VAxisLeft + * @type {Phaser.Input.Gamepad.Axis} + * @private + * @since 3.10.0 + */ + this._VAxisLeft = (axes[1]) ? axes[1] : _noAxis; + + /** + * A reference to the Horizontal Axis for the Right Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_HAxisRight + * @type {Phaser.Input.Gamepad.Axis} + * @private + * @since 3.10.0 + */ + this._HAxisRight = (axes[2]) ? axes[2] : _noAxis; + + /** + * A reference to the Vertical Axis for the Right Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_VAxisRight + * @type {Phaser.Input.Gamepad.Axis} + * @private + * @since 3.10.0 + */ + this._VAxisRight = (axes[3]) ? axes[3] : _noAxis; + + /** + * A Vector2 containing the most recent values from the Gamepad's left axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a left axis stick, the values will always be zero. + * + * @name Phaser.Input.Gamepad.Gamepad#leftStick + * @type {Phaser.Math.Vector2} + * @since 3.10.0 + */ + this.leftStick = new Vector2(); + + /** + * A Vector2 containing the most recent values from the Gamepad's right axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a right axis stick, the values will always be zero. + * + * @name Phaser.Input.Gamepad.Gamepad#rightStick + * @type {Phaser.Math.Vector2} + * @since 3.10.0 + */ + this.rightStick = new Vector2(); + + /** + * When was this Gamepad created? Used to avoid duplicate event spamming in the update loop. + * + * @name Phaser.Input.Gamepad.Gamepad#_created + * @type {number} + * @private + * @since 3.50.0 + */ + this._created = performance.now(); + }, + + /** + * Gets the total number of axis this Gamepad claims to support. + * + * @method Phaser.Input.Gamepad.Gamepad#getAxisTotal + * @since 3.10.0 + * + * @return {number} The total number of axes this Gamepad claims to support. + */ + getAxisTotal: function () + { + return this.axes.length; + }, + + /** + * Gets the value of an axis based on the given index. + * The index must be valid within the range of axes supported by this Gamepad. + * The return value will be a float between -1 and 1. + * + * @method Phaser.Input.Gamepad.Gamepad#getAxisValue + * @since 3.10.0 + * + * @param {number} index - The index of the axes to get the value for. + * + * @return {number} The value of the axis, between -1 and 1. + */ + getAxisValue: function (index) + { + return this.axes[index].getValue(); + }, + + /** + * Sets the threshold value of all axis on this Gamepad. + * The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved. + * + * @method Phaser.Input.Gamepad.Gamepad#setAxisThreshold + * @since 3.10.0 + * + * @param {number} value - A value between 0 and 1. + */ + setAxisThreshold: function (value) + { + for (var i = 0; i < this.axes.length; i++) + { + this.axes[i].threshold = value; + } + }, + + /** + * Gets the total number of buttons this Gamepad claims to have. + * + * @method Phaser.Input.Gamepad.Gamepad#getButtonTotal + * @since 3.10.0 + * + * @return {number} The total number of buttons this Gamepad claims to have. + */ + getButtonTotal: function () + { + return this.buttons.length; + }, + + /** + * Gets the value of a button based on the given index. + * The index must be valid within the range of buttons supported by this Gamepad. + * + * The return value will be either 0 or 1 for a digital button, or a float between 0 and 1 + * for a pressure-sensitive analogue button, such as the shoulder buttons on a Dual Shock. + * + * @method Phaser.Input.Gamepad.Gamepad#getButtonValue + * @since 3.10.0 + * + * @param {number} index - The index of the button to get the value for. + * + * @return {number} The value of the button, between 0 and 1. + */ + getButtonValue: function (index) + { + return this.buttons[index].value; + }, + + /** + * Returns if the button is pressed down or not. + * The index must be valid within the range of buttons supported by this Gamepad. + * + * @method Phaser.Input.Gamepad.Gamepad#isButtonDown + * @since 3.10.0 + * + * @param {number} index - The index of the button to get the value for. + * + * @return {boolean} `true` if the button is considered as being pressed down, otherwise `false`. + */ + isButtonDown: function (index) + { + return this.buttons[index].pressed; + }, + + /** + * Internal update handler for this Gamepad. + * Called automatically by the Gamepad Manager as part of its update. + * + * @method Phaser.Input.Gamepad.Gamepad#update + * @private + * @since 3.0.0 + */ + update: function (pad) + { + if (pad.timestamp < this._created) + { + return; + } + + var i; + + // Sync the button values + + var localButtons = this.buttons; + var gamepadButtons = pad.buttons; + + var len = localButtons.length; + + for (i = 0; i < len; i++) + { + localButtons[i].update(gamepadButtons[i].value); + } + + // Sync the axis values + + var localAxes = this.axes; + var gamepadAxes = pad.axes; + + len = localAxes.length; + + for (i = 0; i < len; i++) + { + localAxes[i].update(gamepadAxes[i]); + } + + if (len >= 2) + { + this.leftStick.set(localAxes[0].getValue(), localAxes[1].getValue()); + + if (len >= 4) + { + this.rightStick.set(localAxes[2].getValue(), localAxes[3].getValue()); + } + } + }, + + /** + * Destroys this Gamepad instance, its buttons and axes, and releases external references it holds. + * + * @method Phaser.Input.Gamepad.Gamepad#destroy + * @since 3.10.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.manager = null; + this.pad = null; + + var i; + + for (i = 0; i < this.buttons.length; i++) + { + this.buttons[i].destroy(); + } + + for (i = 0; i < this.axes.length; i++) + { + this.axes[i].destroy(); + } + + this.buttons = []; + this.axes = []; + }, + + /** + * Is this Gamepad currently connected or not? + * + * @name Phaser.Input.Gamepad.Gamepad#connected + * @type {boolean} + * @default true + * @since 3.0.0 + */ + connected: { + + get: function () + { + return this.pad.connected; + } + + }, + + /** + * A timestamp containing the most recent time this Gamepad was updated. + * + * @name Phaser.Input.Gamepad.Gamepad#timestamp + * @type {number} + * @since 3.0.0 + */ + timestamp: { + + get: function () + { + return this.pad.timestamp; + } + + }, + + /** + * Is the Gamepad's Left button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad left button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#left + * @type {boolean} + * @since 3.10.0 + */ + left: { + + get: function () + { + return this._LCLeft.pressed; + } + + }, + + /** + * Is the Gamepad's Right button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad right button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#right + * @type {boolean} + * @since 3.10.0 + */ + right: { + + get: function () + { + return this._LCRight.pressed; + } + + }, + + /** + * Is the Gamepad's Up button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad up button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#up + * @type {boolean} + * @since 3.10.0 + */ + up: { + + get: function () + { + return this._LCTop.pressed; + } + + }, + + /** + * Is the Gamepad's Down button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad down button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#down + * @type {boolean} + * @since 3.10.0 + */ + down: { + + get: function () + { + return this._LCBottom.pressed; + } + + }, + + /** + * Is the Gamepad's bottom button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the X button. + * On an XBox controller it's the A button. + * + * @name Phaser.Input.Gamepad.Gamepad#A + * @type {boolean} + * @since 3.10.0 + */ + A: { + + get: function () + { + return this._RCBottom.pressed; + } + + }, + + /** + * Is the Gamepad's top button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Triangle button. + * On an XBox controller it's the Y button. + * + * @name Phaser.Input.Gamepad.Gamepad#Y + * @type {boolean} + * @since 3.10.0 + */ + Y: { + + get: function () + { + return this._RCTop.pressed; + } + + }, + + /** + * Is the Gamepad's left button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Square button. + * On an XBox controller it's the X button. + * + * @name Phaser.Input.Gamepad.Gamepad#X + * @type {boolean} + * @since 3.10.0 + */ + X: { + + get: function () + { + return this._RCLeft.pressed; + } + + }, + + /** + * Is the Gamepad's right button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Circle button. + * On an XBox controller it's the B button. + * + * @name Phaser.Input.Gamepad.Gamepad#B + * @type {boolean} + * @since 3.10.0 + */ + B: { + + get: function () + { + return this._RCRight.pressed; + } + + }, + + /** + * Returns the value of the Gamepad's top left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L1 button. + * On an XBox controller it's the LB button. + * + * @name Phaser.Input.Gamepad.Gamepad#L1 + * @type {number} + * @since 3.10.0 + */ + L1: { + + get: function () + { + return this._FBLeftTop.value; + } + + }, + + /** + * Returns the value of the Gamepad's bottom left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L2 button. + * On an XBox controller it's the LT button. + * + * @name Phaser.Input.Gamepad.Gamepad#L2 + * @type {number} + * @since 3.10.0 + */ + L2: { + + get: function () + { + return this._FBLeftBottom.value; + } + + }, + + /** + * Returns the value of the Gamepad's top right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R1 button. + * On an XBox controller it's the RB button. + * + * @name Phaser.Input.Gamepad.Gamepad#R1 + * @type {number} + * @since 3.10.0 + */ + R1: { + + get: function () + { + return this._FBRightTop.value; + } + + }, + + /** + * Returns the value of the Gamepad's bottom right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R2 button. + * On an XBox controller it's the RT button. + * + * @name Phaser.Input.Gamepad.Gamepad#R2 + * @type {number} + * @since 3.10.0 + */ + R2: { + + get: function () + { + return this._FBRightBottom.value; + } + + } + +}); + +module.exports = Gamepad; + + +/***/ }, + +/***/ 56654 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(92734); +var Gamepad = __webpack_require__(99125); +var GetValue = __webpack_require__(35154); +var InputPluginCache = __webpack_require__(89639); +var InputEvents = __webpack_require__(8214); + +/** + * @classdesc + * The Gamepad Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Gamepad Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.gamepad`. + * + * To listen for a gamepad being connected: + * + * ```javascript + * this.input.gamepad.once('connected', function (pad) { + * // 'pad' is a reference to the gamepad that was just connected + * }); + * ``` + * + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. + * + * Once you have received the connected event, or polled the gamepads and found them enabled, you can access + * them via the built-in properties `GamepadPlugin.pad1` to `pad4`, for up to 4 game pads. With a reference + * to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on + * the `Gamepad` class for more details. + * + * As of September 2020 Chrome, and likely other browsers, will soon start to require that games requesting + * access to the Gamepad API are running under SSL. They will actively block API access if they are not. + * + * For more information about Gamepad support in browsers see the following resources: + * + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API + * https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ + * http://html5gamepad.com/ + * + * @class GamepadPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} sceneInputPlugin - A reference to the Scene Input Plugin that the GamepadPlugin belongs to. + */ +var GamepadPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function GamepadPlugin (sceneInputPlugin) + { + EventEmitter.call(this); + + /** + * A reference to the Scene that this Input Plugin is responsible for. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#scene + * @type {Phaser.Scene} + * @since 3.10.0 + */ + this.scene = sceneInputPlugin.scene; + + /** + * A reference to the Scene Systems Settings. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#settings + * @type {Phaser.Types.Scenes.SettingsObject} + * @since 3.10.0 + */ + this.settings = this.scene.sys.settings; + + /** + * A reference to the Scene Input Plugin that created this Gamepad Plugin. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#sceneInputPlugin + * @type {Phaser.Input.InputPlugin} + * @since 3.10.0 + */ + this.sceneInputPlugin = sceneInputPlugin; + + /** + * A boolean that controls if the Gamepad Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#enabled + * @type {boolean} + * @default true + * @since 3.10.0 + */ + this.enabled = true; + + /** + * The Gamepad Event target, as defined in the Game Config. + * Typically the browser window, but can be any interactive DOM element. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#target + * @type {any} + * @since 3.10.0 + */ + this.target; + + /** + * An array of the connected Gamepads. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#gamepads + * @type {Phaser.Input.Gamepad.Gamepad[]} + * @default [] + * @since 3.10.0 + */ + this.gamepads = []; + + /** + * An internal event queue. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#queue + * @type {GamepadEvent[]} + * @private + * @since 3.10.0 + */ + this.queue = []; + + /** + * Internal event handler. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#onGamepadHandler + * @type {function} + * @private + * @since 3.10.0 + */ + this.onGamepadHandler; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad1 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad1; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad2 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad2; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad3 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad3; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad4 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad4; + + sceneInputPlugin.pluginEvents.once(InputEvents.BOOT, this.boot, this); + sceneInputPlugin.pluginEvents.on(InputEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#boot + * @private + * @since 3.10.0 + */ + boot: function () + { + var game = this.scene.sys.game; + var settings = this.settings.input; + var config = game.config; + + this.enabled = GetValue(settings, 'gamepad', config.inputGamepad) && game.device.input.gamepads; + this.target = GetValue(settings, 'gamepad.target', config.inputGamepadEventTarget); + + this.sceneInputPlugin.pluginEvents.once(InputEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#start + * @private + * @since 3.10.0 + */ + start: function () + { + if (this.enabled) + { + this.startListeners(); + + this.refreshPads(); + } + + this.sceneInputPlugin.pluginEvents.once(InputEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#isActive + * @since 3.10.0 + * + * @return {boolean} `true` if the plugin and the Scene it belongs to is active. + */ + isActive: function () + { + return (this.enabled && this.scene.sys.isActive()); + }, + + /** + * Starts the Gamepad Event listeners running. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#startListeners + * @private + * @since 3.10.0 + */ + startListeners: function () + { + var _this = this; + var target = this.target; + + var handler = function (event) + { + if (event.defaultPrevented || !_this.isActive()) + { + // Do nothing if event already handled + return; + } + + _this.refreshPads(); + + _this.queue.push(event); + }; + + this.onGamepadHandler = handler; + + target.addEventListener('gamepadconnected', handler, false); + target.addEventListener('gamepaddisconnected', handler, false); + + // FF also supports gamepadbuttondown, gamepadbuttonup and gamepadaxismove but + // nothing else does, and we can get those values via the gamepads anyway, so we will + // until more browsers support this + + // Finally, listen for an update event from the Input Plugin + this.sceneInputPlugin.pluginEvents.on(InputEvents.UPDATE, this.update, this); + }, + + /** + * Stops the Gamepad Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#stopListeners + * @private + * @since 3.10.0 + */ + stopListeners: function () + { + this.target.removeEventListener('gamepadconnected', this.onGamepadHandler); + this.target.removeEventListener('gamepaddisconnected', this.onGamepadHandler); + + this.sceneInputPlugin.pluginEvents.off(InputEvents.UPDATE, this.update); + + var gamepads = this.gamepads; + + for (var i = 0; i < gamepads.length; i++) + { + if (gamepads[i]) + { + gamepads[i].removeAllListeners(); + } + } + }, + + /** + * Disconnects all current Gamepads. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#disconnectAll + * @since 3.10.0 + */ + disconnectAll: function () + { + var gamepads = this.gamepads; + + for (var i = 0; i < gamepads.length; i++) + { + if (gamepads[i]) + { + gamepads[i].pad.connected = false; + } + } + }, + + /** + * Refreshes the list of connected Gamepads. + * + * This is called automatically when a gamepad is connected or disconnected, + * and during the update loop. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#refreshPads + * @private + * @since 3.10.0 + */ + refreshPads: function () + { + var connectedPads = navigator.getGamepads(); + + if (!connectedPads) + { + this.disconnectAll(); + } + else + { + var currentPads = this.gamepads; + + for (var i = 0; i < connectedPads.length; i++) + { + var livePad = connectedPads[i]; + + // Because sometimes they're null (yes, really) + if (!livePad) + { + continue; + } + + var id = livePad.id; + var index = livePad.index; + var currentPad = currentPads[index]; + + if (!currentPad) + { + // A new Gamepad, not currently stored locally + var newPad = new Gamepad(this, livePad); + + currentPads[index] = newPad; + + if (!this._pad1) + { + this._pad1 = newPad; + } + else if (!this._pad2) + { + this._pad2 = newPad; + } + else if (!this._pad3) + { + this._pad3 = newPad; + } + else if (!this._pad4) + { + this._pad4 = newPad; + } + } + else if (currentPad.id !== id) + { + // A new Gamepad with a different vendor string, but it has got the same index as an old one + currentPad.destroy(); + + currentPads[index] = new Gamepad(this, livePad); + } + else + { + // If neither of these, it's a pad we've already got, so update it + currentPad.update(livePad); + } + } + } + }, + + /** + * Returns an array of all currently connected Gamepads. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#getAll + * @since 3.10.0 + * + * @return {Phaser.Input.Gamepad.Gamepad[]} An array of all currently connected Gamepads. + */ + getAll: function () + { + var out = []; + var pads = this.gamepads; + + for (var i = 0; i < pads.length; i++) + { + if (pads[i]) + { + out.push(pads[i]); + } + } + + return out; + }, + + /** + * Looks up a single Gamepad based on the given index value. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#getPad + * @since 3.10.0 + * + * @param {number} index - The index of the Gamepad to get. + * + * @return {Phaser.Input.Gamepad.Gamepad} The Gamepad matching the given index, or undefined if none were found. + */ + getPad: function (index) + { + var pads = this.gamepads; + + for (var i = 0; i < pads.length; i++) + { + if (pads[i] && pads[i].index === index) + { + return pads[i]; + } + } + }, + + /** + * The internal update loop. Refreshes all connected gamepads and processes their events. + * + * Called automatically by the Input Manager, invoked from the Game step. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#update + * @private + * @fires Phaser.Input.Gamepad.Events#CONNECTED + * @fires Phaser.Input.Gamepad.Events#DISCONNECTED + * @since 3.10.0 + */ + update: function () + { + if (!this.enabled) + { + return; + } + + this.refreshPads(); + + var len = this.queue.length; + + if (len === 0) + { + return; + } + + var queue = this.queue.splice(0, len); + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var pad = this.getPad(event.gamepad.index); + + if (event.type === 'gamepadconnected') + { + this.emit(Events.CONNECTED, pad, event); + } + else if (event.type === 'gamepaddisconnected') + { + this.emit(Events.DISCONNECTED, pad, event); + } + } + }, + + /** + * Shuts the Gamepad Plugin down. + * All this does is remove any listeners bound to it. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#shutdown + * @private + * @since 3.10.0 + */ + shutdown: function () + { + this.stopListeners(); + + this.removeAllListeners(); + }, + + /** + * Destroys this Gamepad Plugin, disconnecting all Gamepads and releasing internal references. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#destroy + * @private + * @since 3.10.0 + */ + destroy: function () + { + this.shutdown(); + + for (var i = 0; i < this.gamepads.length; i++) + { + if (this.gamepads[i]) + { + this.gamepads[i].destroy(); + } + } + + this.gamepads = []; + + this.scene = null; + this.settings = null; + this.sceneInputPlugin = null; + this.target = null; + }, + + /** + * The total number of connected game pads. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#total + * @type {number} + * @since 3.10.0 + */ + total: { + + get: function () + { + return this.gamepads.length; + } + + }, + + /** + * A reference to the first connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnected, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad1 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad1: { + + get: function () + { + return this._pad1; + } + + }, + + /** + * A reference to the second connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnected, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad2 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad2: { + + get: function () + { + return this._pad2; + } + + }, + + /** + * A reference to the third connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnected, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad3 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad3: { + + get: function () + { + return this._pad3; + } + + }, + + /** + * A reference to the fourth connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnected, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad4 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad4: { + + get: function () + { + return this._pad4; + } + + } + +}); + +/** + * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. + * Use this to access Gamepads connected to the browser and respond to gamepad buttons. + * + * @name Phaser.Input.InputPlugin#gamepad + * @type {?Phaser.Input.Gamepad.GamepadPlugin} + * @since 3.10.0 + */ +InputPluginCache.register('GamepadPlugin', GamepadPlugin, 'gamepad', 'gamepad', 'inputGamepad'); + +module.exports = GamepadPlugin; + + +/***/ }, + +/***/ 89651 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Button index constants for the Tatar SNES USB Controller gamepad + * (USB Gamepad, STANDARD GAMEPAD Vendor: 0079 Product: 0011). + * + * Use these constants with Phaser's Gamepad input system to identify specific + * buttons on this controller by their standard gamepad API index. For example, + * pass `Phaser.Input.Gamepad.Configs.SNES_USB.B` as the button index when + * checking button state on a connected gamepad of this type. + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB + * @namespace + * @since 3.0.0 + */ +module.exports = { + + /** + * D-Pad up + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.UP + * @const + * @type {number} + * @since 3.0.0 + */ + UP: 12, + + /** + * D-Pad down + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.DOWN + * @const + * @type {number} + * @since 3.0.0 + */ + DOWN: 13, + + /** + * D-Pad left + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.LEFT + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT: 14, + + /** + * D-Pad right + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.RIGHT + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT: 15, + + /** + * Select button + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.SELECT + * @const + * @type {number} + * @since 3.0.0 + */ + SELECT: 8, + + /** + * Start button + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.START + * @const + * @type {number} + * @since 3.0.0 + */ + START: 9, + + /** + * B Button (Bottom) + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.B + * @const + * @type {number} + * @since 3.0.0 + */ + B: 0, + + /** + * A Button (Right) + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.A + * @const + * @type {number} + * @since 3.0.0 + */ + A: 1, + + /** + * Y Button (Left) + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.Y + * @const + * @type {number} + * @since 3.0.0 + */ + Y: 2, + + /** + * X Button (Top) + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.X + * @const + * @type {number} + * @since 3.0.0 + */ + X: 3, + + /** + * Left shoulder button (L) + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.LEFT_SHOULDER + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT_SHOULDER: 4, + + /** + * Right shoulder button (R) + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB.RIGHT_SHOULDER + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT_SHOULDER: 5 + +}; + + +/***/ }, + +/***/ 65294 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Button and axis index constants for the Sony PlayStation DualShock 4 (v2) wireless controller. + * + * This configuration object maps human-readable names to the numeric button and axis indices + * reported by the browser Gamepad API when a DualShock 4 controller is connected. Use these + * constants with Phaser's `Gamepad` class to check button states and read analog stick values + * without relying on magic numbers in your game code. + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4 + * @namespace + * @since 3.0.0 + */ +module.exports = { + + /** + * D-Pad up + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.UP + * @const + * @type {number} + * @since 3.0.0 + */ + UP: 12, + + /** + * D-Pad down + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.DOWN + * @const + * @type {number} + * @since 3.0.0 + */ + DOWN: 13, + + /** + * D-Pad left + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.LEFT + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT: 14, + + /** + * D-Pad right + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.RIGHT + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT: 15, + + /** + * Share button + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.SHARE + * @const + * @type {number} + * @since 3.0.0 + */ + SHARE: 8, + + /** + * Options button + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.OPTIONS + * @const + * @type {number} + * @since 3.0.0 + */ + OPTIONS: 9, + + /** + * PlayStation logo button + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.PS + * @const + * @type {number} + * @since 3.0.0 + */ + PS: 16, + + /** + * Touchpad click + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.TOUCHBAR + * @const + * @type {number} + * @since 3.0.0 + */ + TOUCHBAR: 17, + + /** + * Cross button (Bottom) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.X + * @const + * @type {number} + * @since 3.0.0 + */ + X: 0, + + /** + * Circle button (Right) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.CIRCLE + * @const + * @type {number} + * @since 3.0.0 + */ + CIRCLE: 1, + + /** + * Square button (Left) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.SQUARE + * @const + * @type {number} + * @since 3.0.0 + */ + SQUARE: 2, + + /** + * Triangle button (Top) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.TRIANGLE + * @const + * @type {number} + * @since 3.0.0 + */ + TRIANGLE: 3, + + /** + * Left bumper (L1) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.L1 + * @const + * @type {number} + * @since 3.0.0 + */ + L1: 4, + + /** + * Right bumper (R1) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.R1 + * @const + * @type {number} + * @since 3.0.0 + */ + R1: 5, + + /** + * Left trigger (L2) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.L2 + * @const + * @type {number} + * @since 3.0.0 + */ + L2: 6, + + /** + * Right trigger (R2) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.R2 + * @const + * @type {number} + * @since 3.0.0 + */ + R2: 7, + + /** + * Left stick click (L3) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.L3 + * @const + * @type {number} + * @since 3.0.0 + */ + L3: 10, + + /** + * Right stick click (R3) + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.R3 + * @const + * @type {number} + * @since 3.0.0 + */ + R3: 11, + + /** + * Left stick horizontal + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.LEFT_STICK_H + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT_STICK_H: 0, + + /** + * Left stick vertical + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.LEFT_STICK_V + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT_STICK_V: 1, + + /** + * Right stick horizontal + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.RIGHT_STICK_H + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT_STICK_H: 2, + + /** + * Right stick vertical + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4.RIGHT_STICK_V + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT_STICK_V: 3 + +}; + + +/***/ }, + +/***/ 90089 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Button and axis index constants for the XBox 360 gamepad. Use these values + * with Phaser's Gamepad input system to identify specific buttons and analog + * sticks by name rather than raw index. For example, check + * `pad.buttons[Phaser.Input.Gamepad.Configs.XBOX_360.A]` to test the A button, + * or read `pad.axes[Phaser.Input.Gamepad.Configs.XBOX_360.LEFT_STICK_H]` for + * the left stick's horizontal axis value. + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360 + * @namespace + * @since 3.0.0 + */ +module.exports = { + + /** + * D-Pad up + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.UP + * @const + * @type {number} + * @since 3.0.0 + */ + UP: 12, + + /** + * D-Pad down + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.DOWN + * @const + * @type {number} + * @since 3.0.0 + */ + DOWN: 13, + + /** + * D-Pad left + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.LEFT + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT: 14, + + /** + * D-Pad right + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.RIGHT + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT: 15, + + /** + * XBox menu button + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.MENU + * @const + * @type {number} + * @since 3.0.0 + */ + MENU: 16, + + /** + * A button (Bottom) + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.A + * @const + * @type {number} + * @since 3.0.0 + */ + A: 0, + + /** + * B button (Right) + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.B + * @const + * @type {number} + * @since 3.0.0 + */ + B: 1, + + /** + * X button (Left) + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.X + * @const + * @type {number} + * @since 3.0.0 + */ + X: 2, + + /** + * Y button (Top) + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.Y + * @const + * @type {number} + * @since 3.0.0 + */ + Y: 3, + + /** + * Left Bumper + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.LB + * @const + * @type {number} + * @since 3.0.0 + */ + LB: 4, + + /** + * Right Bumper + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.RB + * @const + * @type {number} + * @since 3.0.0 + */ + RB: 5, + + /** + * Left Trigger + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.LT + * @const + * @type {number} + * @since 3.0.0 + */ + LT: 6, + + /** + * Right Trigger + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.RT + * @const + * @type {number} + * @since 3.0.0 + */ + RT: 7, + + /** + * Back / Change View button + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.BACK + * @const + * @type {number} + * @since 3.0.0 + */ + BACK: 8, + + /** + * Start button + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.START + * @const + * @type {number} + * @since 3.0.0 + */ + START: 9, + + /** + * Left Stick press + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.LS + * @const + * @type {number} + * @since 3.0.0 + */ + LS: 10, + + /** + * Right Stick press + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.RS + * @const + * @type {number} + * @since 3.0.0 + */ + RS: 11, + + /** + * Left Stick horizontal + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.LEFT_STICK_H + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT_STICK_H: 0, + + /** + * Left Stick vertical + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.LEFT_STICK_V + * @const + * @type {number} + * @since 3.0.0 + */ + LEFT_STICK_V: 1, + + /** + * Right Stick horizontal + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.RIGHT_STICK_H + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT_STICK_H: 2, + + /** + * Right Stick vertical + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360.RIGHT_STICK_V + * @const + * @type {number} + * @since 3.0.0 + */ + RIGHT_STICK_V: 3 + +}; + + +/***/ }, + +/***/ 64894 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Gamepad.Configs + */ + +module.exports = { + + DUALSHOCK_4: __webpack_require__(65294), + SNES_USB: __webpack_require__(89651), + XBOX_360: __webpack_require__(90089) + +}; + + +/***/ }, + +/***/ 46008 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Gamepad Button Down Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. + * + * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. + * + * @event Phaser.Input.Gamepad.Events#BUTTON_DOWN + * @type {string} + * @since 3.10.0 + * + * @param {Phaser.Input.Gamepad} pad - A reference to the Gamepad on which the button was pressed. + * @param {Phaser.Input.Gamepad.Button} button - A reference to the Button which was pressed. + * @param {number} value - The value of the button at the time it was pressed. Between 0 and 1. Some Gamepads have pressure-sensitive buttons. + */ +module.exports = 'down'; + + +/***/ }, + +/***/ 7629 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Gamepad Button Up Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. + * + * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. + * + * @event Phaser.Input.Gamepad.Events#BUTTON_UP + * @type {string} + * @since 3.10.0 + * + * @param {Phaser.Input.Gamepad} pad - A reference to the Gamepad on which the button was released. + * @param {Phaser.Input.Gamepad.Button} button - A reference to the Button which was released. + * @param {number} value - The value of the button at the time it was released. Between 0 and 1. Some Gamepads have pressure-sensitive buttons. + */ +module.exports = 'up'; + + +/***/ }, + +/***/ 42206 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Gamepad Connected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. + * + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. + * + * @event Phaser.Input.Gamepad.Events#CONNECTED + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad} pad - A reference to the Gamepad which was connected. + * @param {Event} event - The native DOM Event that triggered the connection. + */ +module.exports = 'connected'; + + +/***/ }, + +/***/ 86544 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Gamepad Disconnected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. + * + * @event Phaser.Input.Gamepad.Events#DISCONNECTED + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad} pad - A reference to the Gamepad which was disconnected. + * @param {Event} event - The native DOM Event that triggered the disconnection. + */ +module.exports = 'disconnected'; + + +/***/ }, + +/***/ 94784 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Gamepad Button Down Event. + * + * This event is dispatched by a Gamepad instance when a button has been pressed on it. + * + * Listen to this event from a Gamepad instance. One way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('down', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. + * + * @event Phaser.Input.Gamepad.Events#GAMEPAD_BUTTON_DOWN + * @type {string} + * @since 3.10.0 + * + * @param {number} index - The index of the button that was pressed. + * @param {number} value - The value of the button at the time it was pressed. Between 0 and 1. Some Gamepads have pressure-sensitive buttons. + * @param {Phaser.Input.Gamepad.Button} button - A reference to the Button which was pressed. + */ +module.exports = 'down'; + + +/***/ }, + +/***/ 14325 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Gamepad Button Up Event. + * + * This event is dispatched by a Gamepad instance when a button has been released on it. + * + * Listen to this event from a Gamepad instance. One way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('up', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. + * + * @event Phaser.Input.Gamepad.Events#GAMEPAD_BUTTON_UP + * @type {string} + * @since 3.10.0 + * + * @param {number} index - The index of the button that was released. + * @param {number} value - The value of the button at the time it was released. Between 0 and 1. Some Gamepads have pressure-sensitive buttons. + * @param {Phaser.Input.Gamepad.Button} button - A reference to the Button which was released. + */ +module.exports = 'up'; + + +/***/ }, + +/***/ 92734 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Gamepad.Events + */ + +module.exports = { + + BUTTON_DOWN: __webpack_require__(46008), + BUTTON_UP: __webpack_require__(7629), + CONNECTED: __webpack_require__(42206), + DISCONNECTED: __webpack_require__(86544), + GAMEPAD_BUTTON_DOWN: __webpack_require__(94784), + GAMEPAD_BUTTON_UP: __webpack_require__(14325) + +}; + + +/***/ }, + +/***/ 48646 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Gamepad + */ + +module.exports = { + + Axis: __webpack_require__(97421), + Button: __webpack_require__(28884), + Events: __webpack_require__(92734), + Gamepad: __webpack_require__(99125), + GamepadPlugin: __webpack_require__(56654), + + Configs: __webpack_require__(64894) +}; + + +/***/ }, + +/***/ 14350 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(93301); +var Extend = __webpack_require__(79291); + +/** + * @namespace Phaser.Input + */ + +var Input = { + + CreatePixelPerfectHandler: __webpack_require__(84409), + CreateInteractiveObject: __webpack_require__(74457), + Events: __webpack_require__(8214), + Gamepad: __webpack_require__(48646), + InputManager: __webpack_require__(7003), + InputPlugin: __webpack_require__(48205), + InputPluginCache: __webpack_require__(89639), + Keyboard: __webpack_require__(51442), + Mouse: __webpack_require__(87078), + Pointer: __webpack_require__(42515), + Touch: __webpack_require__(95618) + +}; + +// Merge in the consts +Input = Extend(false, Input, CONST); + +module.exports = Input; + + +/***/ }, + +/***/ 78970 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ArrayRemove = __webpack_require__(72905); +var Class = __webpack_require__(83419); +var GameEvents = __webpack_require__(8443); +var InputEvents = __webpack_require__(8214); +var KeyCodes = __webpack_require__(46032); +var NOOP = __webpack_require__(29747); + +/** + * @classdesc + * The Keyboard Manager is a helper class that belongs to the global Input Manager. + * + * Its role is to listen for native DOM Keyboard Events and then store them for further processing by the Keyboard Plugin. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically if keyboard + * input has been enabled in the Game Config. + * + * @class KeyboardManager + * @memberof Phaser.Input.Keyboard + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. + */ +var KeyboardManager = new Class({ + + initialize: + + function KeyboardManager (inputManager) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Keyboard.KeyboardManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.16.0 + */ + this.manager = inputManager; + + /** + * An internal event queue. + * + * @name Phaser.Input.Keyboard.KeyboardManager#queue + * @type {KeyboardEvent[]} + * @private + * @since 3.16.0 + */ + this.queue = []; + + /** + * A flag that controls if the non-modified keys, matching those stored in the `captures` array, + * have `preventDefault` called on them or not. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle this property at run-time. + * + * @name Phaser.Input.Keyboard.KeyboardManager#preventDefault + * @type {boolean} + * @since 3.16.0 + */ + this.preventDefault = true; + + /** + * An array of Key Code values that will automatically have `preventDefault` called on them, + * as long as the `KeyboardManager.preventDefault` boolean is set to `true`. + * + * By default the array is empty. + * + * The key must be non-modified when pressed in order to be captured. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle the `KeyboardManager.preventDefault` boolean at run-time. + * + * If you need more specific control, you can create Key objects and set the flag on each of those instead. + * + * This array can be populated via the Game Config by setting the `input.keyboard.capture` array, or you + * can call the `addCapture` method. See also `removeCapture` and `clearCaptures`. + * + * @name Phaser.Input.Keyboard.KeyboardManager#captures + * @type {number[]} + * @since 3.16.0 + */ + this.captures = []; + + /** + * A boolean that controls if the Keyboard Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Keyboard.KeyboardManager#enabled + * @type {boolean} + * @default false + * @since 3.16.0 + */ + this.enabled = false; + + /** + * The Keyboard Event target, as defined in the Game Config. + * Typically the window in which the game is rendering, but can be any interactive DOM element. + * + * @name Phaser.Input.Keyboard.KeyboardManager#target + * @type {any} + * @since 3.16.0 + */ + this.target; + + /** + * The Key Down Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Keyboard.KeyboardManager#onKeyDown + * @type {function} + * @since 3.16.0 + */ + this.onKeyDown = NOOP; + + /** + * The Key Up Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Keyboard.KeyboardManager#onKeyUp + * @type {function} + * @since 3.16.0 + */ + this.onKeyUp = NOOP; + + inputManager.events.once(InputEvents.MANAGER_BOOT, this.boot, this); + }, + + /** + * The Keyboard Manager boot process. + * + * @method Phaser.Input.Keyboard.KeyboardManager#boot + * @private + * @since 3.16.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputKeyboard; + this.target = config.inputKeyboardEventTarget; + + this.addCapture(config.inputKeyboardCapture); + + if (!this.target && window) + { + this.target = window; + } + + if (this.enabled && this.target) + { + this.startListeners(); + } + + this.manager.game.events.on(GameEvents.POST_STEP, this.postUpdate, this); + }, + + /** + * Starts the Keyboard Event listeners running. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Keyboard.KeyboardManager#startListeners + * @since 3.16.0 + */ + startListeners: function () + { + var _this = this; + + this.onKeyDown = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.queue.push(event); + + _this.manager.events.emit(InputEvents.MANAGER_PROCESS); + + var modified = (event.altKey || event.ctrlKey || event.shiftKey || event.metaKey); + + if (_this.preventDefault && !modified && _this.captures.indexOf(event.keyCode) > -1) + { + event.preventDefault(); + } + }; + + this.onKeyUp = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.queue.push(event); + + _this.manager.events.emit(InputEvents.MANAGER_PROCESS); + + var modified = (event.altKey || event.ctrlKey || event.shiftKey || event.metaKey); + + if (_this.preventDefault && !modified && _this.captures.indexOf(event.keyCode) > -1) + { + event.preventDefault(); + } + }; + + var target = this.target; + + if (target) + { + target.addEventListener('keydown', this.onKeyDown, false); + target.addEventListener('keyup', this.onKeyUp, false); + + this.enabled = true; + } + }, + + /** + * Stops the Key Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Keyboard.KeyboardManager#stopListeners + * @since 3.16.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('keydown', this.onKeyDown, false); + target.removeEventListener('keyup', this.onKeyUp, false); + + this.enabled = false; + }, + + /** + * Clears the event queue. + * Called automatically by the Input Manager. + * + * @method Phaser.Input.Keyboard.KeyboardManager#postUpdate + * @private + * @since 3.16.0 + */ + postUpdate: function () + { + this.queue = []; + }, + + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard events for specific keys so they don't bubble up to the browser + * and cause the default browser behavior. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are active captures after calling this method, the `preventDefault` property is set to `true`. + * + * @method Phaser.Input.Keyboard.KeyboardManager#addCapture + * @since 3.16.0 + * + * @param {(string|number|number[]|any[])} keycode - The Key Codes to enable capture for, preventing them reaching the browser. + */ + addCapture: function (keycode) + { + if (typeof keycode === 'string') + { + keycode = keycode.split(','); + } + + if (!Array.isArray(keycode)) + { + keycode = [ keycode ]; + } + + var captures = this.captures; + + for (var i = 0; i < keycode.length; i++) + { + var code = keycode[i]; + + if (typeof code === 'string') + { + code = KeyCodes[code.trim().toUpperCase()]; + } + + if (captures.indexOf(code) === -1) + { + captures.push(code); + } + } + + this.preventDefault = captures.length > 0; + }, + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are no captures left after calling this method, the `preventDefault` property is set to `false`. + * + * @method Phaser.Input.Keyboard.KeyboardManager#removeCapture + * @since 3.16.0 + * + * @param {(string|number|number[]|any[])} keycode - The Key Codes to disable capture for, allowing them reaching the browser again. + */ + removeCapture: function (keycode) + { + if (typeof keycode === 'string') + { + keycode = keycode.split(','); + } + + if (!Array.isArray(keycode)) + { + keycode = [ keycode ]; + } + + var captures = this.captures; + + for (var i = 0; i < keycode.length; i++) + { + var code = keycode[i]; + + if (typeof code === 'string') + { + code = KeyCodes[code.toUpperCase()]; + } + + ArrayRemove(captures, code); + } + + this.preventDefault = captures.length > 0; + }, + + /** + * Removes all keyboard captures and sets the `preventDefault` property to `false`. + * + * @method Phaser.Input.Keyboard.KeyboardManager#clearCaptures + * @since 3.16.0 + */ + clearCaptures: function () + { + this.captures = []; + + this.preventDefault = false; + }, + + /** + * Destroys this Keyboard Manager instance. + * + * @method Phaser.Input.Keyboard.KeyboardManager#destroy + * @since 3.16.0 + */ + destroy: function () + { + this.stopListeners(); + + this.clearCaptures(); + + this.queue = []; + + this.manager.game.events.off(GameEvents.POST_STEP, this.postUpdate, this); + + this.target = null; + this.enabled = false; + this.manager = null; + } + +}); + +module.exports = KeyboardManager; + + +/***/ }, + +/***/ 28846 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(95922); +var GameEvents = __webpack_require__(8443); +var GetValue = __webpack_require__(35154); +var InputEvents = __webpack_require__(8214); +var InputPluginCache = __webpack_require__(89639); +var Key = __webpack_require__(30472); +var KeyCodes = __webpack_require__(46032); +var KeyCombo = __webpack_require__(87960); +var KeyMap = __webpack_require__(74600); +var SceneEvents = __webpack_require__(44594); +var SnapFloor = __webpack_require__(56583); + +/** + * @classdesc + * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Keyboard Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.keyboard`. For example, you can do: + * + * ```javascript + * this.input.keyboard.on('keydown', callback, context); + * ``` + * + * Or, to listen for a specific key: + * + * ```javascript + * this.input.keyboard.on('keydown-A', callback, context); + * ``` + * + * You can also create Key objects, which you can then poll in your game loop: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * ``` + * + * If you have multiple parallel Scenes, each trying to get keyboard input, be sure to disable capture on them to stop them from + * stealing input from another Scene in the list. You can do this with `this.input.keyboard.enabled = false` within the + * Scene to stop all input, or `this.input.keyboard.preventDefault = false` to stop a Scene halting input on another Scene. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details + * and use the site https://w3c.github.io/uievents/tools/key-event-viewer.html to test your n-key support in browser. + * + * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. + * For example the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * And there are others. So, please check your extensions before opening Phaser issues about keys that don't work. + * + * @class KeyboardPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Keyboard + * @constructor + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} sceneInputPlugin - A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. + */ +var KeyboardPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function KeyboardPlugin (sceneInputPlugin) + { + EventEmitter.call(this); + + /** + * A reference to the core game, so we can listen for visibility events. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#game + * @type {Phaser.Game} + * @since 3.16.0 + */ + this.game = sceneInputPlugin.systems.game; + + /** + * A reference to the Scene that this Input Plugin is responsible for. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#scene + * @type {Phaser.Scene} + * @since 3.10.0 + */ + this.scene = sceneInputPlugin.scene; + + /** + * A reference to the Scene Systems Settings. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#settings + * @type {Phaser.Types.Scenes.SettingsObject} + * @since 3.10.0 + */ + this.settings = this.scene.sys.settings; + + /** + * A reference to the Scene Input Plugin that created this Keyboard Plugin. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#sceneInputPlugin + * @type {Phaser.Input.InputPlugin} + * @since 3.10.0 + */ + this.sceneInputPlugin = sceneInputPlugin; + + /** + * A reference to the global Keyboard Manager. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#manager + * @type {Phaser.Input.Keyboard.KeyboardManager} + * @since 3.16.0 + */ + this.manager = sceneInputPlugin.manager.keyboard; + + /** + * A boolean that controls if this Keyboard Plugin is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#enabled + * @type {boolean} + * @default true + * @since 3.10.0 + */ + this.enabled = true; + + /** + * An array of Key objects to process. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#keys + * @type {Phaser.Input.Keyboard.Key[]} + * @since 3.10.0 + */ + this.keys = []; + + /** + * An array of KeyCombo objects to process. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#combos + * @type {Phaser.Input.Keyboard.KeyCombo[]} + * @since 3.10.0 + */ + this.combos = []; + + /** + * Internal repeat key flag. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#prevCode + * @type {string} + * @private + * @since 3.50.0 + */ + this.prevCode = null; + + /** + * Internal repeat key flag. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#prevTime + * @type {number} + * @private + * @since 3.50.0 + */ + this.prevTime = 0; + + /** + * Internal repeat key flag. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#prevType + * @type {string} + * @private + * @since 3.50.1 + */ + this.prevType = null; + + sceneInputPlugin.pluginEvents.once(InputEvents.BOOT, this.boot, this); + sceneInputPlugin.pluginEvents.on(InputEvents.START, this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#boot + * @private + * @since 3.10.0 + */ + boot: function () + { + var settings = this.settings.input; + + this.enabled = GetValue(settings, 'keyboard', true); + + var captures = GetValue(settings, 'keyboard.capture', null); + + if (captures) + { + this.addCaptures(captures); + } + + this.sceneInputPlugin.pluginEvents.once(InputEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#start + * @private + * @since 3.10.0 + */ + start: function () + { + this.sceneInputPlugin.manager.events.on(InputEvents.MANAGER_PROCESS, this.update, this); + + this.sceneInputPlugin.pluginEvents.once(InputEvents.SHUTDOWN, this.shutdown, this); + + this.game.events.on(GameEvents.BLUR, this.resetKeys, this); + + this.scene.sys.events.on(SceneEvents.PAUSE, this.resetKeys, this); + this.scene.sys.events.on(SceneEvents.SLEEP, this.resetKeys, this); + }, + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#isActive + * @since 3.10.0 + * + * @return {boolean} `true` if the plugin and the Scene it belongs to is active. + */ + isActive: function () + { + return (this.enabled && this.scene.sys.canInput()); + }, + + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard events for specific keys, so they don't bubble up the browser + * and cause the default behaviors. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#addCapture + * @since 3.16.0 + * + * @param {(string|number|number[]|any[])} keycode - The Key Codes to enable event capture for. + * + * @return {this} This KeyboardPlugin object. + */ + addCapture: function (keycode) + { + this.manager.addCapture(keycode); + + return this; + }, + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#removeCapture + * @since 3.16.0 + * + * @param {(string|number|number[]|any[])} keycode - The Key Codes to disable event capture for. + * + * @return {this} This KeyboardPlugin object. + */ + removeCapture: function (keycode) + { + this.manager.removeCapture(keycode); + + return this; + }, + + /** + * Returns an array that contains all of the keyboard captures currently enabled. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#getCaptures + * @since 3.16.0 + * + * @return {number[]} An array of all the currently capturing key codes. + */ + getCaptures: function () + { + return this.manager.captures; + }, + + /** + * Allows Phaser to prevent any key captures you may have defined from bubbling up the browser. + * You can use this to re-enable event capturing if you had paused it via `disableGlobalCapture`. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#enableGlobalCapture + * @since 3.16.0 + * + * @return {this} This KeyboardPlugin object. + */ + enableGlobalCapture: function () + { + this.manager.preventDefault = true; + + return this; + }, + + /** + * Disables Phaser from preventing any key captures you may have defined, without actually removing them. + * You can use this to temporarily disable event capturing if, for example, you swap to a DOM element. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#disableGlobalCapture + * @since 3.16.0 + * + * @return {this} This KeyboardPlugin object. + */ + disableGlobalCapture: function () + { + this.manager.preventDefault = false; + + return this; + }, + + /** + * Removes all keyboard captures. + * + * Note that this is a global change. It will clear all event captures across your game, not just for this specific Scene. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#clearCaptures + * @since 3.16.0 + * + * @return {this} This KeyboardPlugin object. + */ + clearCaptures: function () + { + this.manager.clearCaptures(); + + return this; + }, + + /** + * Creates and returns an object containing 6 hotkeys for Up, Down, Left and Right, and also Space Bar and Shift. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#createCursorKeys + * @since 3.10.0 + * + * @return {Phaser.Types.Input.Keyboard.CursorKeys} An object containing the properties: `up`, `down`, `left`, `right`, `space` and `shift`. + */ + createCursorKeys: function () + { + return this.addKeys({ + up: KeyCodes.UP, + down: KeyCodes.DOWN, + left: KeyCodes.LEFT, + right: KeyCodes.RIGHT, + space: KeyCodes.SPACE, + shift: KeyCodes.SHIFT + }); + }, + + /** + * A practical way to create an object containing user selected hotkeys. + * + * For example: + * + * ```javascript + * this.input.keyboard.addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S }); + * ``` + * + * would return an object containing the properties (`up` and `down`) mapped to W and S {@link Phaser.Input.Keyboard.Key} objects. + * + * You can also pass in a comma-separated string: + * + * ```javascript + * this.input.keyboard.addKeys('W,S,A,D'); + * ``` + * + * Which will return an object with the properties W, S, A and D mapped to the relevant Key objects. + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#addKeys + * @since 3.10.0 + * + * @param {(object|string)} keys - An object containing Key Codes, or a comma-separated string. + * @param {boolean} [enableCapture=true] - Automatically call `preventDefault` on the native DOM browser event for the key codes being added. + * @param {boolean} [emitOnRepeat=false] - Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). + * + * @return {object} An object containing Key objects mapped to the input properties. + */ + addKeys: function (keys, enableCapture, emitOnRepeat) + { + if (enableCapture === undefined) { enableCapture = true; } + if (emitOnRepeat === undefined) { emitOnRepeat = false; } + + var output = {}; + + if (typeof keys === 'string') + { + keys = keys.split(','); + + for (var i = 0; i < keys.length; i++) + { + var currentKey = keys[i].trim(); + + if (currentKey) + { + output[currentKey] = this.addKey(currentKey, enableCapture, emitOnRepeat); + } + } + } + else + { + for (var key in keys) + { + output[key] = this.addKey(keys[key], enableCapture, emitOnRepeat); + } + } + + return output; + }, + + /** + * Adds a Key object to this Keyboard Plugin. + * + * The given argument can be either an existing Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#addKey + * @since 3.10.0 + * + * @param {(Phaser.Input.Keyboard.Key|string|number)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param {boolean} [enableCapture=true] - Automatically call `preventDefault` on the native DOM browser event for the key codes being added. + * @param {boolean} [emitOnRepeat=false] - Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). + * + * @return {Phaser.Input.Keyboard.Key} The newly created Key object, or a reference to it if it already existed in the keys array. + */ + addKey: function (key, enableCapture, emitOnRepeat) + { + if (enableCapture === undefined) { enableCapture = true; } + if (emitOnRepeat === undefined) { emitOnRepeat = false; } + + var keys = this.keys; + + if (key instanceof Key) + { + var idx = keys.indexOf(key); + + if (idx > -1) + { + keys[idx] = key; + } + else + { + keys[key.keyCode] = key; + } + + if (enableCapture) + { + this.addCapture(key.keyCode); + } + + key.setEmitOnRepeat(emitOnRepeat); + + return key; + } + + if (typeof key === 'string') + { + key = KeyCodes[key.toUpperCase()]; + } + + if (!keys[key]) + { + keys[key] = new Key(this, key); + + if (enableCapture) + { + this.addCapture(key); + } + + keys[key].setEmitOnRepeat(emitOnRepeat); + } + + return keys[key]; + }, + + /** + * Removes a Key object from this Keyboard Plugin. + * + * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#removeKey + * @since 3.10.0 + * + * @param {(Phaser.Input.Keyboard.Key|string|number)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param {boolean} [destroy=false] - Call `Key.destroy` on the removed Key object? + * @param {boolean} [removeCapture=false] - Remove this Key from being captured? Only applies if set to capture when created. + * + * @return {this} This KeyboardPlugin object. + */ + removeKey: function (key, destroy, removeCapture) + { + if (destroy === undefined) { destroy = false; } + if (removeCapture === undefined) { removeCapture = false; } + + var keys = this.keys; + var ref; + + if (key instanceof Key) + { + var idx = keys.indexOf(key); + + if (idx > -1) + { + ref = this.keys[idx]; + + this.keys[idx] = undefined; + } + } + else if (typeof key === 'string') + { + key = KeyCodes[key.toUpperCase()]; + } + + if (keys[key]) + { + ref = keys[key]; + + keys[key] = undefined; + } + + if (ref) + { + ref.plugin = null; + + if (removeCapture) + { + this.removeCapture(ref.keyCode); + } + + if (destroy) + { + ref.destroy(); + } + } + + return this; + }, + + /** + * Removes all Key objects created by _this_ Keyboard Plugin. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#removeAllKeys + * @since 3.24.0 + * + * @param {boolean} [destroy=false] - Call `Key.destroy` on each removed Key object? + * @param {boolean} [removeCapture=false] - Remove all key captures for Key objects owned by this plugin? + * + * @return {this} This KeyboardPlugin object. + */ + removeAllKeys: function (destroy, removeCapture) + { + if (destroy === undefined) { destroy = false; } + if (removeCapture === undefined) { removeCapture = false; } + + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + var key = keys[i]; + + if (key) + { + keys[i] = undefined; + + if (removeCapture) + { + this.removeCapture(key.keyCode); + } + + if (destroy) + { + key.destroy(); + } + } + } + + return this; + }, + + /** + * Creates a new KeyCombo. + * + * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them + * it will emit a `keycombomatch` event from this Keyboard Plugin. + * + * The keys to be listened for can be defined as: + * + * A string (i.e. 'ATARI') + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) + * you could pass the following array of key codes: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * Or, to listen for the user entering the word PHASER: + * + * ```javascript + * this.input.keyboard.createCombo('PHASER'); + * ``` + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#createCombo + * @since 3.10.0 + * + * @param {(string|number[]|object[])} keys - The keys that comprise this combo. + * @param {Phaser.Types.Input.Keyboard.KeyComboConfig} [config] - A Key Combo configuration object. + * + * @return {Phaser.Input.Keyboard.KeyCombo} The new KeyCombo object. + */ + createCombo: function (keys, config) + { + return new KeyCombo(this, keys, config); + }, + + /** + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#checkDown + * @since 3.11.0 + * + * @param {Phaser.Input.Keyboard.Key} key - A Key object. + * @param {number} [duration=0] - The duration which must have elapsed before this Key is considered as being down. + * + * @return {boolean} `true` if the Key is down within the duration specified, otherwise `false`. + */ + checkDown: function (key, duration) + { + if (duration === undefined) { duration = 0; } + + if (this.enabled && key.isDown) + { + var t = SnapFloor(this.time - key.timeDown, duration); + + if (t > key._tick) + { + key._tick = t; + + return true; + } + } + + return false; + }, + + /** + * Internal update handler called by the Input Plugin, which is in turn invoked by the Game step. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#update + * @private + * @since 3.10.0 + */ + update: function () + { + var queue = this.manager.queue; + var len = queue.length; + + if (!this.isActive() || len === 0) + { + return; + } + + var keys = this.keys; + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var code = event.keyCode; + var key = keys[code]; + var repeat = false; + + // Override the default functions (it's too late for the browser to use them anyway, so we may as well) + if (event.cancelled === undefined) + { + // Event allowed to flow across all handlers in this Scene, and any other Scene in the Scene list + event.cancelled = 0; + + // Won't reach any more local (Scene level) handlers + event.stopImmediatePropagation = function () + { + event.cancelled = 1; + }; + + // Won't reach any more handlers in any Scene further down the Scene list + event.stopPropagation = function () + { + event.cancelled = -1; + }; + } + + if (event.cancelled === -1) + { + // This event has been stopped from broadcasting to any other Scene, so abort. + continue; + } + + // Duplicate event bailout + if (code === this.prevCode && event.timeStamp === this.prevTime && event.type === this.prevType) + { + // On some systems, the exact same event will fire multiple times. This prevents it. + continue; + } + + this.prevCode = code; + this.prevTime = event.timeStamp; + this.prevType = event.type; + + if (event.type === 'keydown') + { + // Key specific callback first + if (key) + { + repeat = key.isDown; + + key.onDown(event); + } + + if (!event.cancelled && (!key || !repeat)) + { + if (KeyMap[code]) + { + this.emit(Events.KEY_DOWN + KeyMap[code], event); + } + + if (!event.cancelled) + { + this.emit(Events.ANY_KEY_DOWN, event); + } + } + } + else + { + // Key specific callback first + if (key) + { + key.onUp(event); + } + + if (!event.cancelled) + { + if (KeyMap[code]) + { + this.emit(Events.KEY_UP + KeyMap[code], event); + } + + if (!event.cancelled) + { + this.emit(Events.ANY_KEY_UP, event); + } + } + } + + // Reset the cancel state for other Scenes to use + if (event.cancelled === 1) + { + event.cancelled = 0; + } + } + }, + + /** + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursorKeys` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#resetKeys + * @since 3.15.0 + * + * @return {this} This KeyboardPlugin object. + */ + resetKeys: function () + { + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + // Because it's a sparsely populated array + if (keys[i]) + { + keys[i].reset(); + } + } + + return this; + }, + + /** + * Shuts this Keyboard Plugin down. This performs the following tasks: + * + * 1 - Removes all keys created by this Keyboard plugin. + * 2 - Stops and removes the keyboard event listeners. + * 3 - Clears out any pending requests in the queue, without processing them. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#shutdown + * @private + * @since 3.10.0 + */ + shutdown: function () + { + this.removeAllKeys(true); + this.removeAllListeners(); + + this.sceneInputPlugin.manager.events.off(InputEvents.MANAGER_PROCESS, this.update, this); + + this.game.events.off(GameEvents.BLUR, this.resetKeys); + + this.scene.sys.events.off(SceneEvents.PAUSE, this.resetKeys, this); + this.scene.sys.events.off(SceneEvents.SLEEP, this.resetKeys, this); + + this.queue = []; + }, + + /** + * Destroys this Keyboard Plugin instance and all references it holds, plus clears out local arrays. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#destroy + * @private + * @since 3.10.0 + */ + destroy: function () + { + this.shutdown(); + + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + // Because it's a sparsely populated array + if (keys[i]) + { + keys[i].destroy(); + } + } + + this.keys = []; + this.combos = []; + this.queue = []; + + this.scene = null; + this.settings = null; + this.sceneInputPlugin = null; + this.manager = null; + }, + + /** + * Internal time value. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#time + * @type {number} + * @private + * @since 3.11.0 + */ + time: { + + get: function () + { + return this.sceneInputPlugin.manager.time; + } + + } + +}); + +/** + * An instance of the Keyboard Plugin class, if enabled via the `input.keyboard` Scene or Game Config property. + * Use this to create Key objects and listen for keyboard specific events. + * + * @name Phaser.Input.InputPlugin#keyboard + * @type {?Phaser.Input.Keyboard.KeyboardPlugin} + * @since 3.10.0 + */ +InputPluginCache.register('KeyboardPlugin', KeyboardPlugin, 'keyboard', 'keyboard', 'inputKeyboard'); + +module.exports = KeyboardPlugin; + + +/***/ }, + +/***/ 66970 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * Return `true` if it reached the end of the combo, `false` if not. + * + * @function Phaser.Input.Keyboard.AdvanceKeyCombo + * @private + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native Keyboard Event. + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to advance. + * + * @return {boolean} `true` if it reached the end of the combo, `false` if not. + */ +var AdvanceKeyCombo = function (event, combo) +{ + combo.timeLastMatched = event.timeStamp; + combo.index++; + + if (combo.index === combo.size) + { + return true; + } + else + { + combo.current = combo.keyCodes[combo.index]; + return false; + } +}; + +module.exports = AdvanceKeyCombo; + + +/***/ }, + +/***/ 87960 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Events = __webpack_require__(95922); +var GetFastValue = __webpack_require__(95540); +var ProcessKeyCombo = __webpack_require__(68769); +var ResetKeyCombo = __webpack_require__(92803); + +/** + * @classdesc + * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them + * it will emit a `keycombomatch` event from the Keyboard Manager. + * + * The keys to be listened for can be defined as: + * + * A string (i.e. 'ATARI') + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) + * you could pass the following array of key codes: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * Or, to listen for the user entering the word PHASER: + * + * ```javascript + * this.input.keyboard.createCombo('PHASER'); + * ``` + * + * @class KeyCombo + * @memberof Phaser.Input.Keyboard + * @constructor + * @listens Phaser.Input.Keyboard.Events#ANY_KEY_DOWN + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyboardPlugin} keyboardPlugin - A reference to the Keyboard Plugin. + * @param {(string|number[]|object[])} keys - The keys that comprise this combo. + * @param {Phaser.Types.Input.Keyboard.KeyComboConfig} [config] - A Key Combo configuration object. + */ +var KeyCombo = new Class({ + + initialize: + + function KeyCombo (keyboardPlugin, keys, config) + { + if (config === undefined) { config = {}; } + + // Can't have a zero or single length combo (string or array based) + if (keys.length < 2) + { + return false; + } + + /** + * A reference to the Keyboard Plugin + * + * @name Phaser.Input.Keyboard.KeyCombo#manager + * @type {Phaser.Input.Keyboard.KeyboardPlugin} + * @since 3.0.0 + */ + this.manager = keyboardPlugin; + + /** + * A flag that controls if this Key Combo is actively processing keys or not. + * + * @name Phaser.Input.Keyboard.KeyCombo#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * An array of the keycodes that comprise this combo. + * + * @name Phaser.Input.Keyboard.KeyCombo#keyCodes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.keyCodes = []; + + // if 'keys' is a string we need to get the keycode of each character in it + + for (var i = 0; i < keys.length; i++) + { + var char = keys[i]; + + if (typeof char === 'string') + { + this.keyCodes.push(char.toUpperCase().charCodeAt(0)); + } + else if (typeof char === 'number') + { + this.keyCodes.push(char); + } + else if (char.hasOwnProperty('keyCode')) + { + this.keyCodes.push(char.keyCode); + } + } + + /** + * The current keyCode the combo is waiting for. + * + * @name Phaser.Input.Keyboard.KeyCombo#current + * @type {number} + * @since 3.0.0 + */ + this.current = this.keyCodes[0]; + + /** + * The current index of the key being waited for in the `keyCodes` array. + * + * @name Phaser.Input.Keyboard.KeyCombo#index + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.index = 0; + + /** + * The length of this combo (in keycodes) + * + * @name Phaser.Input.Keyboard.KeyCombo#size + * @type {number} + * @since 3.0.0 + */ + this.size = this.keyCodes.length; + + /** + * The time the previous key in the combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeLastMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeLastMatched = 0; + + /** + * Has this Key Combo been matched yet? + * + * @name Phaser.Input.Keyboard.KeyCombo#matched + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.matched = false; + + /** + * The time the entire combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeMatched = 0; + + /** + * If the user presses an incorrect key, the combo sequence will be reset to the beginning. + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnWrongKey + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.resetOnWrongKey = GetFastValue(config, 'resetOnWrongKey', true); + + /** + * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. + * + * @name Phaser.Input.Keyboard.KeyCombo#maxKeyDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0); + + /** + * If the combo has previously been matched and the user presses the first key of the combo again, the combo will reset. + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.resetOnMatch = GetFastValue(config, 'resetOnMatch', false); + + /** + * If the combo matches successfully, this KeyCombo instance will automatically destroy itself. + * + * @name Phaser.Input.Keyboard.KeyCombo#deleteOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.deleteOnMatch = GetFastValue(config, 'deleteOnMatch', false); + + var _this = this; + + var onKeyDownHandler = function (event) + { + if (_this.matched || !_this.enabled) + { + return; + } + + var matched = ProcessKeyCombo(event, _this); + + if (matched) + { + _this.manager.emit(Events.COMBO_MATCH, _this, event); + + if (_this.resetOnMatch) + { + ResetKeyCombo(_this); + } + else if (_this.deleteOnMatch) + { + _this.destroy(); + } + } + }; + + /** + * The internal Key Down handler. + * + * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown + * @private + * @type {KeyboardKeydownCallback} + * @fires Phaser.Input.Keyboard.Events#COMBO_MATCH + * @since 3.0.0 + */ + this.onKeyDown = onKeyDownHandler; + + this.manager.on(Events.ANY_KEY_DOWN, this.onKeyDown); + }, + + /** + * How far complete is this combo? A value between 0 and 1. + * + * @name Phaser.Input.Keyboard.KeyCombo#progress + * @type {number} + * @readonly + * @since 3.0.0 + */ + progress: { + + get: function () + { + return this.index / this.size; + } + + }, + + /** + * Destroys this Key Combo and all of its references. + * + * @method Phaser.Input.Keyboard.KeyCombo#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enabled = false; + this.keyCodes = []; + + this.manager.off(Events.ANY_KEY_DOWN, this.onKeyDown); + + this.manager = null; + } + +}); + +module.exports = KeyCombo; + + +/***/ }, + +/***/ 68769 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AdvanceKeyCombo = __webpack_require__(66970); + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.ProcessKeyCombo + * @private + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native Keyboard Event. + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to be processed. + * + * @return {boolean} `true` if the combo was matched, otherwise `false`. + */ +var ProcessKeyCombo = function (event, combo) +{ + if (combo.matched) + { + return true; + } + + var comboMatched = false; + var keyMatched = false; + + if (event.keyCode === combo.current) + { + // Key was correct + + if (combo.index > 0 && combo.maxKeyDelay > 0) + { + // We have to check to see if the delay between + // the new key and the old one was too long (if enabled) + + var timeLimit = combo.timeLastMatched + combo.maxKeyDelay; + + // Check if they pressed it in time or not + if (event.timeStamp <= timeLimit) + { + keyMatched = true; + comboMatched = AdvanceKeyCombo(event, combo); + } + } + else + { + keyMatched = true; + + // We don't check the time for the first key pressed, so just advance it + comboMatched = AdvanceKeyCombo(event, combo); + } + } + + if (!keyMatched && combo.resetOnWrongKey) + { + // Wrong key was pressed + combo.index = 0; + combo.current = combo.keyCodes[0]; + } + + if (comboMatched) + { + combo.timeLastMatched = event.timeStamp; + combo.matched = true; + combo.timeMatched = event.timeStamp; + } + + return comboMatched; +}; + +module.exports = ProcessKeyCombo; + + +/***/ }, + +/***/ 92803 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.ResetKeyCombo + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset. + * + * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo. + */ +var ResetKeyCombo = function (combo) +{ + combo.current = combo.keyCodes[0]; + combo.index = 0; + combo.timeLastMatched = 0; + combo.matched = false; + combo.timeMatched = 0; + + return combo; +}; + +module.exports = ResetKeyCombo; + + +/***/ }, + +/***/ 92612 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Global Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keydown', listener)`. + * + * You can also listen for a specific key being pressed. See [Keyboard.Events.KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + * + * @event Phaser.Input.Keyboard.Events#ANY_KEY_DOWN + * @type {string} + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard Event. You can inspect this to learn more about the key that was pressed, any modifiers, etc. + */ +module.exports = 'keydown'; + + +/***/ }, + +/***/ 23345 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Global Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keyup', listener)`. + * + * You can also listen for a specific key being released. See [Keyboard.Events.KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + * + * @event Phaser.Input.Keyboard.Events#ANY_KEY_UP + * @type {string} + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard Event. You can inspect this to learn more about the key that was released, any modifiers, etc. + */ +module.exports = 'keyup'; + + +/***/ }, + +/***/ 21957 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Key Combo Match Event. + * + * This event is dispatched by the Keyboard Plugin when a [Key Combo]{@link Phaser.Input.Keyboard.KeyCombo} is matched. + * + * Listen for this event from the Key Plugin after a combo has been created: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * @event Phaser.Input.Keyboard.Events#COMBO_MATCH + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyCombo} keycombo - The Key Combo object that was matched. + * @param {KeyboardEvent} event - The native DOM Keyboard Event of the final key in the combo. You can inspect this to learn more about any modifiers, etc. + */ +module.exports = 'keycombomatch'; + + +/***/ }, + +/***/ 44743 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Key Down Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is pressed. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('down', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + * + * @event Phaser.Input.Keyboard.Events#DOWN + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key object that was pressed. + * @param {KeyboardEvent} event - The native DOM Keyboard Event. You can inspect this to learn more about any modifiers, etc. + */ +module.exports = 'down'; + + +/***/ }, + +/***/ 3771 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Unlike the `ANY_KEY_DOWN` event, this one has a special dynamic event name. For example, to listen for the `A` key being pressed + * use the following from within a Scene: `this.input.keyboard.on('keydown-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keydown-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + * + * @event Phaser.Input.Keyboard.Events#KEY_DOWN + * @type {string} + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard Event. You can inspect this to learn more about the key that was pressed, any modifiers, etc. + */ +module.exports = 'keydown-'; + + +/***/ }, + +/***/ 46358 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Unlike the `ANY_KEY_UP` event, this one has a special dynamic event name. For example, to listen for the `A` key being released + * use the following from within a Scene: `this.input.keyboard.on('keyup-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keyup-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + * + * @event Phaser.Input.Keyboard.Events#KEY_UP + * @type {string} + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard Event. You can inspect this to learn more about the key that was released, any modifiers, etc. + */ +module.exports = 'keyup-'; + + +/***/ }, + +/***/ 75674 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Key Up Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is released. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('up', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + * + * @event Phaser.Input.Keyboard.Events#UP + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key object that was released. + * @param {KeyboardEvent} event - The native DOM Keyboard Event. You can inspect this to learn more about any modifiers, etc. + */ +module.exports = 'up'; + + +/***/ }, + +/***/ 95922 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Keyboard.Events + */ + +module.exports = { + + ANY_KEY_DOWN: __webpack_require__(92612), + ANY_KEY_UP: __webpack_require__(23345), + COMBO_MATCH: __webpack_require__(21957), + DOWN: __webpack_require__(44743), + KEY_DOWN: __webpack_require__(3771), + KEY_UP: __webpack_require__(46358), + UP: __webpack_require__(75674) + +}; + + +/***/ }, + +/***/ 51442 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Keyboard + */ + +module.exports = { + + Events: __webpack_require__(95922), + + KeyboardManager: __webpack_require__(78970), + KeyboardPlugin: __webpack_require__(28846), + + Key: __webpack_require__(30472), + KeyCodes: __webpack_require__(46032), + + KeyCombo: __webpack_require__(87960), + + AdvanceKeyCombo: __webpack_require__(66970), + ProcessKeyCombo: __webpack_require__(68769), + ResetKeyCombo: __webpack_require__(92803), + + JustDown: __webpack_require__(90229), + JustUp: __webpack_require__(38796), + DownDuration: __webpack_require__(37015), + UpDuration: __webpack_require__(41170) + +}; + + +/***/ }, + +/***/ 37015 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns `true` if the Key was pressed down within the `duration` value given, based on the current + * game clock time. Or `false` if it either isn't down, or was pressed down longer ago than the given duration. + * + * @function Phaser.Input.Keyboard.DownDuration + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key object to test. + * @param {number} [duration=50] - The duration, in ms, within which the key must have been pressed down. + * + * @return {boolean} `true` if the Key was pressed down within `duration` ms ago, otherwise `false`. + */ +var DownDuration = function (key, duration) +{ + if (duration === undefined) { duration = 50; } + + var current = key.plugin.game.loop.time - key.timeDown; + + return (key.isDown && current < duration); +}; + +module.exports = DownDuration; + + +/***/ }, + +/***/ 90229 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The justDown value allows you to test if this Key has just been pressed down or not. + * + * When you check this value it will return `true` if the Key is down, otherwise `false`. + * + * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. + * This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustDown + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just down or not. + * + * @return {boolean} `true` if the Key was just pressed, otherwise `false`. + */ +var JustDown = function (key) +{ + if (key._justDown) + { + key._justDown = false; + + return true; + } + else + { + return false; + } +}; + +module.exports = JustDown; + + +/***/ }, + +/***/ 38796 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The justUp value allows you to test if this Key has just been released or not. + * + * When you check this value it will return `true` if the Key is up, otherwise `false`. + * + * You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again. + * This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustUp + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just up or not. + * + * @return {boolean} `true` if the Key was just released, otherwise `false`. + */ +var JustUp = function (key) +{ + if (key._justUp) + { + key._justUp = false; + + return true; + } + else + { + return false; + } +}; + +module.exports = JustUp; + + +/***/ }, + +/***/ 30472 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(95922); + +/** + * @classdesc + * Represents a single key on the keyboard. Key objects are created by the Keyboard Plugin + * via `addKey()` and track the state of a specific key, including whether it is currently + * held down, the duration it has been held, timestamps for press and release events, and + * repeat counts. You can poll Key objects directly in your game loop using properties like + * `isDown` and `isUp`, or listen for events via the `on` method. The keyCode must be an + * integer corresponding to a `Phaser.Input.Keyboard.KeyCodes` value. + * + * @class Key + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Keyboard + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyboardPlugin} plugin - The Keyboard Plugin instance that owns this Key object. + * @param {number} keyCode - The keycode of this key. + */ +var Key = new Class({ + + Extends: EventEmitter, + + initialize: + + function Key (plugin, keyCode) + { + EventEmitter.call(this); + + /** + * The Keyboard Plugin instance that owns this Key object. + * + * @name Phaser.Input.Keyboard.Key#plugin + * @type {Phaser.Input.Keyboard.KeyboardPlugin} + * @since 3.17.0 + */ + this.plugin = plugin; + + /** + * The keycode of this key. + * + * @name Phaser.Input.Keyboard.Key#keyCode + * @type {number} + * @since 3.0.0 + */ + this.keyCode = keyCode; + + /** + * The original DOM event. + * + * @name Phaser.Input.Keyboard.Key#originalEvent + * @type {KeyboardEvent} + * @since 3.0.0 + */ + this.originalEvent = undefined; + + /** + * Can this Key be processed? + * + * @name Phaser.Input.Keyboard.Key#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. + * + * @name Phaser.Input.Keyboard.Key#isDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isDown = false; + + /** + * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. + * + * @name Phaser.Input.Keyboard.Key#isUp + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isUp = true; + + /** + * The down state of the ALT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#altKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.altKey = false; + + /** + * The down state of the CTRL key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#ctrlKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.ctrlKey = false; + + /** + * The down state of the SHIFT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#shiftKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shiftKey = false; + + /** + * The down state of the Meta key, if pressed at the same time as this key. + * On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key. + * + * @name Phaser.Input.Keyboard.Key#metaKey + * @type {boolean} + * @default false + * @since 3.16.0 + */ + this.metaKey = false; + + /** + * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. + * + * @name Phaser.Input.Keyboard.Key#location + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.location = 0; + + /** + * The timestamp when the key was last pressed down. + * + * @name Phaser.Input.Keyboard.Key#timeDown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeDown = 0; + + /** + * The number of milliseconds this key was held down for in the previous down - up sequence. + * This value isn't updated every game step, only when the Key changes state. + * To get the current duration use the `getDuration` method. + * + * @name Phaser.Input.Keyboard.Key#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * The timestamp when the key was last released. + * + * @name Phaser.Input.Keyboard.Key#timeUp + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeUp = 0; + + /** + * When a key is held down should it continuously fire the `down` event each time it repeats? + * + * By default it will emit the `down` event just once, but if you wish to receive the event + * for each repeat as well, enable this property. + * + * @name Phaser.Input.Keyboard.Key#emitOnRepeat + * @type {boolean} + * @default false + * @since 3.16.0 + */ + this.emitOnRepeat = false; + + /** + * If a key is held down this holds the number of times the key has 'repeated'. + * + * @name Phaser.Input.Keyboard.Key#repeats + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeats = 0; + + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + * + * @name Phaser.Input.Keyboard.Key#_justDown + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justDown = false; + + /** + * True if the key has just been released (NOTE: requires to be reset, see justUp getter) + * + * @name Phaser.Input.Keyboard.Key#_justUp + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justUp = false; + + /** + * Internal tick counter. + * + * @name Phaser.Input.Keyboard.Key#_tick + * @type {number} + * @private + * @since 3.11.0 + */ + this._tick = -1; + }, + + /** + * Controls if this Key will continuously emit a `down` event while being held down (true), + * or emit the event just once, on first press, and then skip future events (false). + * + * @method Phaser.Input.Keyboard.Key#setEmitOnRepeat + * @since 3.16.0 + * + * @param {boolean} value - Emit `down` events on repeated key down actions, or just once? + * + * @return {this} This Key instance. + */ + setEmitOnRepeat: function (value) + { + this.emitOnRepeat = value; + + return this; + }, + + /** + * Processes the Key Down action for this Key. + * Called automatically by the Keyboard Plugin. + * + * @method Phaser.Input.Keyboard.Key#onDown + * @fires Phaser.Input.Keyboard.Events#DOWN + * @since 3.16.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard event. + */ + onDown: function (event) + { + this.originalEvent = event; + + if (!this.enabled) + { + return; + } + + this.altKey = event.altKey; + this.ctrlKey = event.ctrlKey; + this.shiftKey = event.shiftKey; + this.metaKey = event.metaKey; + this.location = event.location; + + this.repeats++; + + if (!this.isDown) + { + this.isDown = true; + this.isUp = false; + this.timeDown = event.timeStamp; + this.duration = 0; + this._justDown = true; + this._justUp = false; + + this.emit(Events.DOWN, this, event); + } + else if (this.emitOnRepeat) + { + this.emit(Events.DOWN, this, event); + } + }, + + /** + * Processes the Key Up action for this Key. + * Called automatically by the Keyboard Plugin. + * + * @method Phaser.Input.Keyboard.Key#onUp + * @fires Phaser.Input.Keyboard.Events#UP + * @since 3.16.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard event. + */ + onUp: function (event) + { + this.originalEvent = event; + + if (!this.enabled) + { + return; + } + + this.isDown = false; + this.isUp = true; + this.timeUp = event.timeStamp; + this.duration = this.timeUp - this.timeDown; + this.repeats = 0; + + this._justDown = false; + this._justUp = true; + this._tick = -1; + + this.emit(Events.UP, this, event); + }, + + /** + * Resets this Key object back to its default un-pressed state. + * + * As of version 3.60.0 it no longer resets the `enabled` or `preventDefault` flags. + * + * @method Phaser.Input.Keyboard.Key#reset + * @since 3.6.0 + * + * @return {this} This Key instance. + */ + reset: function () + { + this.isDown = false; + this.isUp = true; + this.altKey = false; + this.ctrlKey = false; + this.shiftKey = false; + this.metaKey = false; + this.timeDown = 0; + this.duration = 0; + this.timeUp = 0; + this.repeats = 0; + this._justDown = false; + this._justUp = false; + this._tick = -1; + + return this; + }, + + /** + * Returns the duration, in ms, that the Key has been held down for. + * + * If the key is not currently down it will return zero. + * + * To get the duration the Key was held down for in the previous up-down cycle, + * use the `Key.duration` property value instead. + * + * @method Phaser.Input.Keyboard.Key#getDuration + * @since 3.17.0 + * + * @return {number} The duration, in ms, that the Key has been held down for if currently down. + */ + getDuration: function () + { + if (this.isDown) + { + return (this.plugin.game.loop.time - this.timeDown); + } + else + { + return 0; + } + }, + + /** + * Removes any bound event handlers and removes local references. + * + * @method Phaser.Input.Keyboard.Key#destroy + * @since 3.16.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.originalEvent = null; + + this.plugin = null; + } + +}); + +module.exports = Key; + + +/***/ }, + +/***/ 46032 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * A mapping of keyboard key names to their corresponding browser key codes, as reported by + * `KeyboardEvent.keyCode`. Use these constants with `Phaser.Input.Keyboard.KeyboardPlugin` + * methods such as `addKey` and `addKeys`, or when checking the state of `Phaser.Input.Keyboard.Key` + * objects, to avoid hard-coding numeric values in your game code. + * + * Some entries include browser-specific variants (e.g. `SEMICOLON_FIREFOX`) to handle historical + * differences in key code reporting across browsers. + * + * @namespace Phaser.Input.Keyboard.KeyCodes + * @memberof Phaser.Input.Keyboard + * @since 3.0.0 + */ + +var KeyCodes = { + + /** + * The BACKSPACE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE + * @type {number} + * @since 3.0.0 + */ + BACKSPACE: 8, + + /** + * The TAB key. + * + * @name Phaser.Input.Keyboard.KeyCodes.TAB + * @type {number} + * @since 3.0.0 + */ + TAB: 9, + + /** + * The ENTER key. + * + * @name Phaser.Input.Keyboard.KeyCodes.ENTER + * @type {number} + * @since 3.0.0 + */ + ENTER: 13, + + /** + * The SHIFT key. + * + * @name Phaser.Input.Keyboard.KeyCodes.SHIFT + * @type {number} + * @since 3.0.0 + */ + SHIFT: 16, + + /** + * The CTRL key. + * + * @name Phaser.Input.Keyboard.KeyCodes.CTRL + * @type {number} + * @since 3.0.0 + */ + CTRL: 17, + + /** + * The ALT key. + * + * @name Phaser.Input.Keyboard.KeyCodes.ALT + * @type {number} + * @since 3.0.0 + */ + ALT: 18, + + /** + * The PAUSE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.PAUSE + * @type {number} + * @since 3.0.0 + */ + PAUSE: 19, + + /** + * The CAPS_LOCK key. + * + * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK + * @type {number} + * @since 3.0.0 + */ + CAPS_LOCK: 20, + + /** + * The ESC key. + * + * @name Phaser.Input.Keyboard.KeyCodes.ESC + * @type {number} + * @since 3.0.0 + */ + ESC: 27, + + /** + * The SPACE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.SPACE + * @type {number} + * @since 3.0.0 + */ + SPACE: 32, + + /** + * The PAGE_UP key. + * + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP + * @type {number} + * @since 3.0.0 + */ + PAGE_UP: 33, + + /** + * The PAGE_DOWN key. + * + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN + * @type {number} + * @since 3.0.0 + */ + PAGE_DOWN: 34, + + /** + * The END key. + * + * @name Phaser.Input.Keyboard.KeyCodes.END + * @type {number} + * @since 3.0.0 + */ + END: 35, + + /** + * The HOME key. + * + * @name Phaser.Input.Keyboard.KeyCodes.HOME + * @type {number} + * @since 3.0.0 + */ + HOME: 36, + + /** + * The LEFT key. + * + * @name Phaser.Input.Keyboard.KeyCodes.LEFT + * @type {number} + * @since 3.0.0 + */ + LEFT: 37, + + /** + * The UP key. + * + * @name Phaser.Input.Keyboard.KeyCodes.UP + * @type {number} + * @since 3.0.0 + */ + UP: 38, + + /** + * The RIGHT key. + * + * @name Phaser.Input.Keyboard.KeyCodes.RIGHT + * @type {number} + * @since 3.0.0 + */ + RIGHT: 39, + + /** + * The DOWN key. + * + * @name Phaser.Input.Keyboard.KeyCodes.DOWN + * @type {number} + * @since 3.0.0 + */ + DOWN: 40, + + /** + * The PRINT_SCREEN key. + * + * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN + * @type {number} + * @since 3.0.0 + */ + PRINT_SCREEN: 42, + + /** + * The INSERT key. + * + * @name Phaser.Input.Keyboard.KeyCodes.INSERT + * @type {number} + * @since 3.0.0 + */ + INSERT: 45, + + /** + * The DELETE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.DELETE + * @type {number} + * @since 3.0.0 + */ + DELETE: 46, + + /** + * The ZERO key. + * + * @name Phaser.Input.Keyboard.KeyCodes.ZERO + * @type {number} + * @since 3.0.0 + */ + ZERO: 48, + + /** + * The ONE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.ONE + * @type {number} + * @since 3.0.0 + */ + ONE: 49, + + /** + * The TWO key. + * + * @name Phaser.Input.Keyboard.KeyCodes.TWO + * @type {number} + * @since 3.0.0 + */ + TWO: 50, + + /** + * The THREE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.THREE + * @type {number} + * @since 3.0.0 + */ + THREE: 51, + + /** + * The FOUR key. + * + * @name Phaser.Input.Keyboard.KeyCodes.FOUR + * @type {number} + * @since 3.0.0 + */ + FOUR: 52, + + /** + * The FIVE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.FIVE + * @type {number} + * @since 3.0.0 + */ + FIVE: 53, + + /** + * The SIX key. + * + * @name Phaser.Input.Keyboard.KeyCodes.SIX + * @type {number} + * @since 3.0.0 + */ + SIX: 54, + + /** + * The SEVEN key. + * + * @name Phaser.Input.Keyboard.KeyCodes.SEVEN + * @type {number} + * @since 3.0.0 + */ + SEVEN: 55, + + /** + * The EIGHT key. + * + * @name Phaser.Input.Keyboard.KeyCodes.EIGHT + * @type {number} + * @since 3.0.0 + */ + EIGHT: 56, + + /** + * The NINE key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NINE + * @type {number} + * @since 3.0.0 + */ + NINE: 57, + + /** + * The numeric keypad 0 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ZERO + * @type {number} + * @since 3.0.0 + */ + NUMPAD_ZERO: 96, + + /** + * The numeric keypad 1 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE + * @type {number} + * @since 3.0.0 + */ + NUMPAD_ONE: 97, + + /** + * The numeric keypad 2 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO + * @type {number} + * @since 3.0.0 + */ + NUMPAD_TWO: 98, + + /** + * The numeric keypad 3 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE + * @type {number} + * @since 3.0.0 + */ + NUMPAD_THREE: 99, + + /** + * The numeric keypad 4 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR + * @type {number} + * @since 3.0.0 + */ + NUMPAD_FOUR: 100, + + /** + * The numeric keypad 5 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE + * @type {number} + * @since 3.0.0 + */ + NUMPAD_FIVE: 101, + + /** + * The numeric keypad 6 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX + * @type {number} + * @since 3.0.0 + */ + NUMPAD_SIX: 102, + + /** + * The numeric keypad 7 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN + * @type {number} + * @since 3.0.0 + */ + NUMPAD_SEVEN: 103, + + /** + * The numeric keypad 8 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT + * @type {number} + * @since 3.0.0 + */ + NUMPAD_EIGHT: 104, + + /** + * The numeric keypad 9 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE + * @type {number} + * @since 3.0.0 + */ + NUMPAD_NINE: 105, + + /** + * The Numpad Addition (+) key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ADD + * @type {number} + * @since 3.21.0 + */ + NUMPAD_ADD: 107, + + /** + * The Numpad Subtraction (-) key. + * + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SUBTRACT + * @type {number} + * @since 3.21.0 + */ + NUMPAD_SUBTRACT: 109, + + /** + * The A key. + * + * @name Phaser.Input.Keyboard.KeyCodes.A + * @type {number} + * @since 3.0.0 + */ + A: 65, + + /** + * The B key. + * + * @name Phaser.Input.Keyboard.KeyCodes.B + * @type {number} + * @since 3.0.0 + */ + B: 66, + + /** + * The C key. + * + * @name Phaser.Input.Keyboard.KeyCodes.C + * @type {number} + * @since 3.0.0 + */ + C: 67, + + /** + * The D key. + * + * @name Phaser.Input.Keyboard.KeyCodes.D + * @type {number} + * @since 3.0.0 + */ + D: 68, + + /** + * The E key. + * + * @name Phaser.Input.Keyboard.KeyCodes.E + * @type {number} + * @since 3.0.0 + */ + E: 69, + + /** + * The F key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F + * @type {number} + * @since 3.0.0 + */ + F: 70, + + /** + * The G key. + * + * @name Phaser.Input.Keyboard.KeyCodes.G + * @type {number} + * @since 3.0.0 + */ + G: 71, + + /** + * The H key. + * + * @name Phaser.Input.Keyboard.KeyCodes.H + * @type {number} + * @since 3.0.0 + */ + H: 72, + + /** + * The I key. + * + * @name Phaser.Input.Keyboard.KeyCodes.I + * @type {number} + * @since 3.0.0 + */ + I: 73, + + /** + * The J key. + * + * @name Phaser.Input.Keyboard.KeyCodes.J + * @type {number} + * @since 3.0.0 + */ + J: 74, + + /** + * The K key. + * + * @name Phaser.Input.Keyboard.KeyCodes.K + * @type {number} + * @since 3.0.0 + */ + K: 75, + + /** + * The L key. + * + * @name Phaser.Input.Keyboard.KeyCodes.L + * @type {number} + * @since 3.0.0 + */ + L: 76, + + /** + * The M key. + * + * @name Phaser.Input.Keyboard.KeyCodes.M + * @type {number} + * @since 3.0.0 + */ + M: 77, + + /** + * The N key. + * + * @name Phaser.Input.Keyboard.KeyCodes.N + * @type {number} + * @since 3.0.0 + */ + N: 78, + + /** + * The O key. + * + * @name Phaser.Input.Keyboard.KeyCodes.O + * @type {number} + * @since 3.0.0 + */ + O: 79, + + /** + * The P key. + * + * @name Phaser.Input.Keyboard.KeyCodes.P + * @type {number} + * @since 3.0.0 + */ + P: 80, + + /** + * The Q key. + * + * @name Phaser.Input.Keyboard.KeyCodes.Q + * @type {number} + * @since 3.0.0 + */ + Q: 81, + + /** + * The R key. + * + * @name Phaser.Input.Keyboard.KeyCodes.R + * @type {number} + * @since 3.0.0 + */ + R: 82, + + /** + * The S key. + * + * @name Phaser.Input.Keyboard.KeyCodes.S + * @type {number} + * @since 3.0.0 + */ + S: 83, + + /** + * The T key. + * + * @name Phaser.Input.Keyboard.KeyCodes.T + * @type {number} + * @since 3.0.0 + */ + T: 84, + + /** + * The U key. + * + * @name Phaser.Input.Keyboard.KeyCodes.U + * @type {number} + * @since 3.0.0 + */ + U: 85, + + /** + * The V key. + * + * @name Phaser.Input.Keyboard.KeyCodes.V + * @type {number} + * @since 3.0.0 + */ + V: 86, + + /** + * The W key. + * + * @name Phaser.Input.Keyboard.KeyCodes.W + * @type {number} + * @since 3.0.0 + */ + W: 87, + + /** + * The X key. + * + * @name Phaser.Input.Keyboard.KeyCodes.X + * @type {number} + * @since 3.0.0 + */ + X: 88, + + /** + * The Y key. + * + * @name Phaser.Input.Keyboard.KeyCodes.Y + * @type {number} + * @since 3.0.0 + */ + Y: 89, + + /** + * The Z key. + * + * @name Phaser.Input.Keyboard.KeyCodes.Z + * @type {number} + * @since 3.0.0 + */ + Z: 90, + + /** + * The F1 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F1 + * @type {number} + * @since 3.0.0 + */ + F1: 112, + + /** + * The F2 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F2 + * @type {number} + * @since 3.0.0 + */ + F2: 113, + + /** + * The F3 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F3 + * @type {number} + * @since 3.0.0 + */ + F3: 114, + + /** + * The F4 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F4 + * @type {number} + * @since 3.0.0 + */ + F4: 115, + + /** + * The F5 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F5 + * @type {number} + * @since 3.0.0 + */ + F5: 116, + + /** + * The F6 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F6 + * @type {number} + * @since 3.0.0 + */ + F6: 117, + + /** + * The F7 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F7 + * @type {number} + * @since 3.0.0 + */ + F7: 118, + + /** + * The F8 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F8 + * @type {number} + * @since 3.0.0 + */ + F8: 119, + + /** + * The F9 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F9 + * @type {number} + * @since 3.0.0 + */ + F9: 120, + + /** + * The F10 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F10 + * @type {number} + * @since 3.0.0 + */ + F10: 121, + + /** + * The F11 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F11 + * @type {number} + * @since 3.0.0 + */ + F11: 122, + + /** + * The F12 key. + * + * @name Phaser.Input.Keyboard.KeyCodes.F12 + * @type {number} + * @since 3.0.0 + */ + F12: 123, + + /** + * The SEMICOLON key. + * + * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON + * @type {number} + * @since 3.0.0 + */ + SEMICOLON: 186, + + /** + * The PLUS key. + * + * @name Phaser.Input.Keyboard.KeyCodes.PLUS + * @type {number} + * @since 3.0.0 + */ + PLUS: 187, + + /** + * The COMMA key. + * + * @name Phaser.Input.Keyboard.KeyCodes.COMMA + * @type {number} + * @since 3.0.0 + */ + COMMA: 188, + + /** + * The MINUS key. + * + * @name Phaser.Input.Keyboard.KeyCodes.MINUS + * @type {number} + * @since 3.0.0 + */ + MINUS: 189, + + /** + * The PERIOD key. + * + * @name Phaser.Input.Keyboard.KeyCodes.PERIOD + * @type {number} + * @since 3.0.0 + */ + PERIOD: 190, + + /** + * The FORWARD_SLASH key. + * + * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH + * @type {number} + * @since 3.0.0 + */ + FORWARD_SLASH: 191, + + /** + * The BACK_SLASH key. + * + * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH + * @type {number} + * @since 3.0.0 + */ + BACK_SLASH: 220, + + /** + * The QUOTES key. + * + * @name Phaser.Input.Keyboard.KeyCodes.QUOTES + * @type {number} + * @since 3.0.0 + */ + QUOTES: 222, + + /** + * The BACKTICK key. + * + * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK + * @type {number} + * @since 3.0.0 + */ + BACKTICK: 192, + + /** + * The OPEN_BRACKET key. + * + * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET + * @type {number} + * @since 3.0.0 + */ + OPEN_BRACKET: 219, + + /** + * The CLOSED_BRACKET key. + * + * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET + * @type {number} + * @since 3.0.0 + */ + CLOSED_BRACKET: 221, + + /** + * The Firefox-specific alternate key code for the SEMICOLON (;) key. Firefox historically + * reported key code 59 for this key, whereas other browsers use 186 (see `SEMICOLON`). + * + * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON_FIREFOX + * @type {number} + * @since 3.0.0 + */ + SEMICOLON_FIREFOX: 59, + + /** + * The COLON (:) key. + * + * @name Phaser.Input.Keyboard.KeyCodes.COLON + * @type {number} + * @since 3.0.0 + */ + COLON: 58, + + /** + * The Firefox on Windows-specific alternate key code for the less-than sign (<) key. + * + * @name Phaser.Input.Keyboard.KeyCodes.COMMA_FIREFOX_WINDOWS + * @type {number} + * @since 3.0.0 + */ + COMMA_FIREFOX_WINDOWS: 60, + + /** + * The Firefox-specific alternate key code for the greater-than sign (>) key. + * + * @name Phaser.Input.Keyboard.KeyCodes.COMMA_FIREFOX + * @type {number} + * @since 3.0.0 + */ + COMMA_FIREFOX: 62, + + /** + * The Firefox-specific alternate key code for the right bracket (]) key. Firefox historically + * reported key code 174 for this key, whereas other browsers use 221 (see `CLOSED_BRACKET`). + * + * @name Phaser.Input.Keyboard.KeyCodes.BRACKET_RIGHT_FIREFOX + * @type {number} + * @since 3.0.0 + */ + BRACKET_RIGHT_FIREFOX: 174, + + /** + * The Firefox-specific alternate key code for the left bracket ([) key. Firefox historically + * reported key code 175 for this key, whereas other browsers use 219 (see `OPEN_BRACKET`). + * + * @name Phaser.Input.Keyboard.KeyCodes.BRACKET_LEFT_FIREFOX + * @type {number} + * @since 3.0.0 + */ + BRACKET_LEFT_FIREFOX: 175 +}; + +module.exports = KeyCodes; + + +/***/ }, + +/***/ 74600 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var KeyCodes = __webpack_require__(46032); + +var KeyMap = {}; + +for (var key in KeyCodes) +{ + KeyMap[KeyCodes[key]] = key; +} + +module.exports = KeyMap; + + +/***/ }, + +/***/ 41170 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Returns `true` if the Key was released within the `duration` value given, based on the current + * game clock time. Or returns `false` if it either isn't up, or was released longer ago than the given duration. + * + * @function Phaser.Input.Keyboard.UpDuration + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key object to test. + * @param {number} [duration=50] - The duration, in ms, within which the key must have been released. + * + * @return {boolean} `true` if the Key was released within `duration` ms ago, otherwise `false`. + */ +var UpDuration = function (key, duration) +{ + if (duration === undefined) { duration = 50; } + + var current = key.plugin.game.loop.time - key.timeUp; + + return (key.isUp && current < duration); +}; + +module.exports = UpDuration; + + +/***/ }, + +/***/ 85098 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var Features = __webpack_require__(89357); +var InputEvents = __webpack_require__(8214); +var NOOP = __webpack_require__(29747); + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent +// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md + +/** + * @classdesc + * The Mouse Manager is a helper class that belongs to the Input Manager. + * + * Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. + * + * @class MouseManager + * @memberof Phaser.Input.Mouse + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. + */ +var MouseManager = new Class({ + + initialize: + + function MouseManager (inputManager) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Mouse.MouseManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If `true` the DOM `mousedown` event will have `preventDefault` set. + * + * @name Phaser.Input.Mouse.MouseManager#preventDefaultDown + * @type {boolean} + * @default true + * @since 3.50.0 + */ + this.preventDefaultDown = true; + + /** + * If `true` the DOM `mouseup` event will have `preventDefault` set. + * + * @name Phaser.Input.Mouse.MouseManager#preventDefaultUp + * @type {boolean} + * @default true + * @since 3.50.0 + */ + this.preventDefaultUp = true; + + /** + * If `true` the DOM `mousemove` event will have `preventDefault` set. + * + * @name Phaser.Input.Mouse.MouseManager#preventDefaultMove + * @type {boolean} + * @default true + * @since 3.50.0 + */ + this.preventDefaultMove = true; + + /** + * If `true` the DOM `wheel` event will have `preventDefault` set. + * + * @name Phaser.Input.Mouse.MouseManager#preventDefaultWheel + * @type {boolean} + * @default false + * @since 3.50.0 + */ + this.preventDefaultWheel = false; + + /** + * A boolean that controls if the Mouse Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Mouse.MouseManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * The Mouse target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + * + * @name Phaser.Input.Mouse.MouseManager#target + * @type {any} + * @since 3.0.0 + */ + this.target; + + /** + * If the mouse has been pointer locked successfully this will be set to true. + * + * @name Phaser.Input.Mouse.MouseManager#locked + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.locked = false; + + /** + * The Mouse Move Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseMove + * @type {function} + * @since 3.10.0 + */ + this.onMouseMove = NOOP; + + /** + * The Mouse Down Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseDown + * @type {function} + * @since 3.10.0 + */ + this.onMouseDown = NOOP; + + /** + * The Mouse Up Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseUp + * @type {function} + * @since 3.10.0 + */ + this.onMouseUp = NOOP; + + /** + * The Mouse Down Event handler specifically for events on the Window. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseDownWindow + * @type {function} + * @since 3.17.0 + */ + this.onMouseDownWindow = NOOP; + + /** + * The Mouse Up Event handler specifically for events on the Window. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseUpWindow + * @type {function} + * @since 3.17.0 + */ + this.onMouseUpWindow = NOOP; + + /** + * The Mouse Over Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseOver + * @type {function} + * @since 3.16.0 + */ + this.onMouseOver = NOOP; + + /** + * The Mouse Out Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseOut + * @type {function} + * @since 3.16.0 + */ + this.onMouseOut = NOOP; + + /** + * The Mouse Wheel Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseWheel + * @type {function} + * @since 3.18.0 + */ + this.onMouseWheel = NOOP; + + /** + * Internal pointerLockChange handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#pointerLockChange + * @type {function} + * @since 3.0.0 + */ + this.pointerLockChange = NOOP; + + /** + * Are the event listeners hooked into `window.top` or `window`? + * + * This is set during the `boot` sequence. If the browser does not have access to `window.top`, + * such as in cross-origin iframe environments, this property gets set to `false` and the events + * are hooked into `window` instead. + * + * @name Phaser.Input.Mouse.MouseManager#isTop + * @type {boolean} + * @readonly + * @since 3.50.0 + */ + this.isTop = true; + + inputManager.events.once(InputEvents.MANAGER_BOOT, this.boot, this); + }, + + /** + * The Mouse Manager boot process. + * + * @method Phaser.Input.Mouse.MouseManager#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputMouse; + this.target = config.inputMouseEventTarget; + this.passive = config.inputMousePassive; + + this.preventDefaultDown = config.inputMousePreventDefaultDown; + this.preventDefaultUp = config.inputMousePreventDefaultUp; + this.preventDefaultMove = config.inputMousePreventDefaultMove; + this.preventDefaultWheel = config.inputMousePreventDefaultWheel; + + if (!this.target) + { + this.target = this.manager.game.canvas; + } + else if (typeof this.target === 'string') + { + this.target = document.getElementById(this.target); + } + + if (config.disableContextMenu) + { + this.disableContextMenu(); + } + + if (this.enabled && this.target) + { + this.startListeners(); + } + }, + + /** + * Attempts to disable the context menu from appearing if you right-click on the game canvas, or specified input target. + * + * Works by listening for the `contextmenu` event and prevent defaulting it. + * + * Use this if you need to enable right-button mouse support in your game, and the context + * menu keeps getting in the way. + * + * @method Phaser.Input.Mouse.MouseManager#disableContextMenu + * @since 3.0.0 + * + * @return {this} This Mouse Manager instance. + */ + disableContextMenu: function () + { + this.target.addEventListener('contextmenu', function (event) + { + event.preventDefault(); + return false; + }); + + return this; + }, + + /** + * If the browser supports it, you can request that the pointer be locked to the browser window. + * + * This is classically known as 'FPS controls', where the pointer can't leave the browser until + * the user presses an exit key. + * + * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, + * from the games Input Manager, with an `isPointerLocked` property. + * + * It is important to note that pointer lock can only be enabled after an 'engagement gesture', + * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. + * + * Note for Firefox: There is a bug in certain Firefox releases that cause native DOM events like + * `mousemove` to fire continuously when in pointer lock mode. You can get around this by setting + * `this.preventDefaultMove` to `false` in this class. You may also need to do the same for + * `preventDefaultDown` and/or `preventDefaultUp`. Please test combinations of these if you encounter + * the error. + * + * @method Phaser.Input.Mouse.MouseManager#requestPointerLock + * @since 3.0.0 + */ + requestPointerLock: function () + { + if (Features.pointerLock) + { + var element = this.target; + + element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; + + element.requestPointerLock(); + } + }, + + /** + * If the browser supports pointer lock, this will request that the pointer lock is released. If + * the browser successfully exits the locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be + * dispatched - from the game's input manager - with an `isPointerLocked` property. + * + * @method Phaser.Input.Mouse.MouseManager#releasePointerLock + * @since 3.0.0 + */ + releasePointerLock: function () + { + if (Features.pointerLock) + { + document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; + document.exitPointerLock(); + } + }, + + /** + * Starts the Mouse Event listeners running. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Mouse.MouseManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var target = this.target; + + if (!target) + { + return; + } + + var _this = this; + var manager = this.manager; + var canvas = manager.canvas; + var autoFocus = (window && window.focus && manager.game.config.autoFocus); + + this.onMouseMove = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onMouseMove(event); + + if (_this.preventDefaultMove) + { + event.preventDefault(); + } + } + }; + + this.onMouseDown = function (event) + { + if (autoFocus) + { + window.focus(); + } + + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onMouseDown(event); + + if (_this.preventDefaultDown && event.target === canvas) + { + event.preventDefault(); + } + } + }; + + this.onMouseDownWindow = function (event) + { + if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) + { + return; + } + + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas) + { + // Only process the event if the target isn't the canvas + manager.onMouseDown(event); + } + }; + + this.onMouseUp = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onMouseUp(event); + + if (_this.preventDefaultUp && event.target === canvas) + { + event.preventDefault(); + } + } + }; + + this.onMouseUpWindow = function (event) + { + if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) + { + return; + } + + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas) + { + // Only process the event if the target isn't the canvas + manager.onMouseUp(event); + } + }; + + this.onMouseOver = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.setCanvasOver(event); + } + }; + + this.onMouseOut = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.setCanvasOut(event); + } + }; + + this.onMouseWheel = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onMouseWheel(event); + } + + if (_this.preventDefaultWheel && event.target === canvas) + { + event.preventDefault(); + } + }; + + var passive = { passive: true }; + + target.addEventListener('mousemove', this.onMouseMove); + target.addEventListener('mousedown', this.onMouseDown); + target.addEventListener('mouseup', this.onMouseUp); + target.addEventListener('mouseover', this.onMouseOver, passive); + target.addEventListener('mouseout', this.onMouseOut, passive); + + if (this.preventDefaultWheel) + { + target.addEventListener('wheel', this.onMouseWheel, { passive: false }); + } + else + { + target.addEventListener('wheel', this.onMouseWheel, passive); + } + + if (window && manager.game.config.inputWindowEvents) + { + try + { + window.top.addEventListener('mousedown', this.onMouseDownWindow, passive); + window.top.addEventListener('mouseup', this.onMouseUpWindow, passive); + } + catch (exception) + { + window.addEventListener('mousedown', this.onMouseDownWindow, passive); + window.addEventListener('mouseup', this.onMouseUpWindow, passive); + + this.isTop = false; + } + } + + if (Features.pointerLock) + { + this.pointerLockChange = function (event) + { + var element = _this.target; + + _this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + manager.onPointerLockChange(event); + }; + + document.addEventListener('pointerlockchange', this.pointerLockChange, true); + document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); + document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); + } + + this.enabled = true; + }, + + /** + * Stops the Mouse Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Mouse.MouseManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('mousemove', this.onMouseMove); + target.removeEventListener('mousedown', this.onMouseDown); + target.removeEventListener('mouseup', this.onMouseUp); + target.removeEventListener('mouseover', this.onMouseOver); + target.removeEventListener('mouseout', this.onMouseOut); + + if (window) + { + target = (this.isTop) ? window.top : window; + + target.removeEventListener('mousedown', this.onMouseDownWindow); + target.removeEventListener('mouseup', this.onMouseUpWindow); + } + + if (Features.pointerLock) + { + document.removeEventListener('pointerlockchange', this.pointerLockChange, true); + document.removeEventListener('mozpointerlockchange', this.pointerLockChange, true); + document.removeEventListener('webkitpointerlockchange', this.pointerLockChange, true); + } + }, + + /** + * Destroys this Mouse Manager instance. + * + * @method Phaser.Input.Mouse.MouseManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.target = null; + this.enabled = false; + this.manager = null; + } + +}); + +module.exports = MouseManager; + + +/***/ }, + +/***/ 87078 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Mouse + */ + +/* eslint-disable */ +module.exports = { + + MouseManager: __webpack_require__(85098) + +}; +/* eslint-enable */ + + +/***/ }, + +/***/ 36210 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var InputEvents = __webpack_require__(8214); +var NOOP = __webpack_require__(29747); + +// https://developer.mozilla.org/en-US/docs/Web/API/Touch_events +// https://patrickhlauke.github.io/touch/tests/results/ +// https://www.html5rocks.com/en/mobile/touch/ + +/** + * @classdesc + * The Touch Manager is a helper class that belongs to the Input Manager. + * + * Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. + * + * @class TouchManager + * @memberof Phaser.Input.Touch + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. + */ +var TouchManager = new Class({ + + initialize: + + function TouchManager (inputManager) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Touch.TouchManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. + * + * @name Phaser.Input.Touch.TouchManager#capture + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.capture = true; + + /** + * A boolean that controls if the Touch Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Touch.TouchManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * The Touch Event target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + * + * @name Phaser.Input.Touch.TouchManager#target + * @type {any} + * @since 3.0.0 + */ + this.target; + + /** + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchStart + * @type {function} + * @since 3.0.0 + */ + this.onTouchStart = NOOP; + + /** + * The Touch Start event handler function specifically for events on the Window. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchStartWindow + * @type {function} + * @since 3.17.0 + */ + this.onTouchStartWindow = NOOP; + + /** + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchMove + * @type {function} + * @since 3.0.0 + */ + this.onTouchMove = NOOP; + + /** + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchEnd + * @type {function} + * @since 3.0.0 + */ + this.onTouchEnd = NOOP; + + /** + * The Touch End event handler function specifically for events on the Window. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchEndWindow + * @type {function} + * @since 3.17.0 + */ + this.onTouchEndWindow = NOOP; + + /** + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchCancel + * @type {function} + * @since 3.15.0 + */ + this.onTouchCancel = NOOP; + + /** + * The Touch Cancel event handler function specifically for events on the Window. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchCancelWindow + * @type {function} + * @since 3.18.0 + */ + this.onTouchCancelWindow = NOOP; + + /** + * Are the event listeners hooked into `window.top` or `window`? + * + * This is set during the `boot` sequence. If the browser does not have access to `window.top`, + * such as in cross-origin iframe environments, this property gets set to `false` and the events + * are hooked into `window` instead. + * + * @name Phaser.Input.Touch.TouchManager#isTop + * @type {boolean} + * @readonly + * @since 3.60.0 + */ + this.isTop = true; + + inputManager.events.once(InputEvents.MANAGER_BOOT, this.boot, this); + }, + + /** + * The Touch Manager boot process. + * + * @method Phaser.Input.Touch.TouchManager#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputTouch; + this.target = config.inputTouchEventTarget; + this.capture = config.inputTouchCapture; + + if (!this.target) + { + this.target = this.manager.game.canvas; + } + else if (typeof this.target === 'string') + { + this.target = document.getElementById(this.target); + } + + if (config.disableContextMenu) + { + this.disableContextMenu(); + } + + if (this.enabled && this.target) + { + this.startListeners(); + } + }, + + /** + * Attempts to disable the context menu from appearing if you touch-hold on the browser. + * + * Works by listening for the `contextmenu` event and calling `preventDefault()` on it. + * + * Use this if you need to disable the OS context menu on mobile. + * + * @method Phaser.Input.Touch.TouchManager#disableContextMenu + * @since 3.20.0 + * + * @return {this} This Touch Manager instance. + */ + disableContextMenu: function () + { + this.target.addEventListener('contextmenu', function (event) + { + event.preventDefault(); + return false; + }); + + return this; + }, + + /** + * Starts the Touch Event listeners running as long as an input target is set. + * + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. + * + * @method Phaser.Input.Touch.TouchManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var target = this.target; + + if (!target) + { + return; + } + + var _this = this; + var manager = this.manager; + var canvas = manager.canvas; + var autoFocus = (window && window.focus && manager.game.config.autoFocus); + + this.onTouchMove = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onTouchMove(event); + + if (_this.capture && event.cancelable) + { + event.preventDefault(); + } + } + }; + + this.onTouchStart = function (event) + { + if (autoFocus) + { + window.focus(); + } + + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onTouchStart(event); + + if (_this.capture && event.cancelable && event.target === canvas) + { + event.preventDefault(); + } + } + }; + + this.onTouchStartWindow = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas) + { + // Only process the event if the target isn't the canvas + manager.onTouchStart(event); + } + }; + + this.onTouchEnd = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onTouchEnd(event); + + if (_this.capture && event.cancelable && event.target === canvas) + { + event.preventDefault(); + } + } + }; + + this.onTouchEndWindow = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas) + { + // Only process the event if the target isn't the canvas + manager.onTouchEnd(event); + } + }; + + this.onTouchCancel = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onTouchCancel(event); + + if (_this.capture) + { + event.preventDefault(); + } + } + }; + + this.onTouchCancelWindow = function (event) + { + if (!event.defaultPrevented && _this.enabled && manager && manager.enabled) + { + manager.onTouchCancel(event); + } + }; + + var capture = this.capture; + var passive = { passive: true }; + var nonPassive = { passive: false }; + + target.addEventListener('touchstart', this.onTouchStart, (capture) ? nonPassive : passive); + target.addEventListener('touchmove', this.onTouchMove, (capture) ? nonPassive : passive); + target.addEventListener('touchend', this.onTouchEnd, (capture) ? nonPassive : passive); + target.addEventListener('touchcancel', this.onTouchCancel, (capture) ? nonPassive : passive); + + if (window && manager.game.config.inputWindowEvents) + { + try + { + window.top.addEventListener('touchstart', this.onTouchStartWindow, nonPassive); + window.top.addEventListener('touchend', this.onTouchEndWindow, nonPassive); + window.top.addEventListener('touchcancel', this.onTouchCancelWindow, nonPassive); + } + catch (exception) + { + window.addEventListener('touchstart', this.onTouchStartWindow, nonPassive); + window.addEventListener('touchend', this.onTouchEndWindow, nonPassive); + window.addEventListener('touchcancel', this.onTouchCancelWindow, nonPassive); + + this.isTop = false; + } + } + + this.enabled = true; + }, + + /** + * Stops the Touch Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Touch.TouchManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('touchstart', this.onTouchStart); + target.removeEventListener('touchmove', this.onTouchMove); + target.removeEventListener('touchend', this.onTouchEnd); + target.removeEventListener('touchcancel', this.onTouchCancel); + + if (window) + { + target = (this.isTop) ? window.top : window; + + target.removeEventListener('touchstart', this.onTouchStartWindow); + target.removeEventListener('touchend', this.onTouchEndWindow); + target.removeEventListener('touchcancel', this.onTouchCancelWindow); + } + }, + + /** + * Destroys this Touch Manager instance. + * + * @method Phaser.Input.Touch.TouchManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.target = null; + this.enabled = false; + this.manager = null; + } + +}); + +module.exports = TouchManager; + + +/***/ }, + +/***/ 95618 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Input.Touch + */ + +/* eslint-disable */ +module.exports = { + + TouchManager: __webpack_require__(36210) + +}; +/* eslint-enable */ + + +/***/ }, + +/***/ 41299 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var Events = __webpack_require__(54899); +var GetFastValue = __webpack_require__(95540); +var GetURL = __webpack_require__(98356); +var MergeXHRSettings = __webpack_require__(3374); +var XHRLoader = __webpack_require__(84376); +var XHRSettings = __webpack_require__(92638); + +/** + * @classdesc + * The base File class used by all File Types that the Loader can support. It manages the lifecycle + * of a single file from queue to download to processing to completion, handling XHR configuration, + * URL resolution, progress tracking, and error states. You should not create an instance of a File + * directly, but should extend it with your own class, setting a custom type and overriding the + * `onProcess` method to handle the loaded data. See `Phaser.Loader.FileTypes` for built-in file + * type examples. + * + * @class File + * @memberof Phaser.Loader + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {Phaser.Types.Loader.FileConfig} fileConfig - The file configuration object, as created by the file type. + */ +var File = new Class({ + + initialize: + + function File (loader, fileConfig) + { + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.File#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.0.0 + */ + this.loader = loader; + + /** + * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. + * + * @name Phaser.Loader.File#cache + * @type {(Phaser.Cache.BaseCache|Phaser.Textures.TextureManager)} + * @since 3.7.0 + */ + this.cache = GetFastValue(fileConfig, 'cache', false); + + /** + * The file type string (image, json, etc) for sorting within the Loader. + * + * @name Phaser.Loader.File#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(fileConfig, 'type', false); + + if (!this.type) + { + throw new Error('Invalid File type: ' + this.type); + } + + /** + * Unique cache key (unique within its file type) + * + * @name Phaser.Loader.File#key + * @type {string} + * @since 3.0.0 + */ + this.key = GetFastValue(fileConfig, 'key', false); + + var loadKey = this.key; + + if (loader.prefix && loader.prefix !== '') + { + this.key = loader.prefix + loadKey; + } + + if (!this.key) + { + throw new Error('Invalid File key: ' + this.key); + } + + var url = GetFastValue(fileConfig, 'url'); + + if (url === undefined) + { + url = loader.path + loadKey + '.' + GetFastValue(fileConfig, 'extension', ''); + } + else if (typeof url === 'string' && !url.match(/^(?:blob:|data:|capacitor:\/\/|http:\/\/|https:\/\/|\/\/)/)) + { + url = loader.path + url; + } + + /** + * The URL of the file, not including baseURL. + * + * Automatically has Loader.path prepended to it if a string. + * + * Can also be a JavaScript Object, such as the results of parsing JSON data. + * + * @name Phaser.Loader.File#url + * @type {object|string} + * @since 3.0.0 + */ + this.url = url; + + /** + * The final URL this file will load from, including baseURL and path. + * Set automatically when the Loader calls 'load' on this file. + * + * @name Phaser.Loader.File#src + * @type {string} + * @since 3.0.0 + */ + this.src = ''; + + /** + * The merged XHRSettings for this file. + * + * @name Phaser.Loader.File#xhrSettings + * @type {Phaser.Types.Loader.XHRSettingsObject} + * @since 3.0.0 + */ + this.xhrSettings = XHRSettings(GetFastValue(fileConfig, 'responseType', undefined)); + + if (GetFastValue(fileConfig, 'xhrSettings', false)) + { + this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {})); + } + + /** + * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. + * + * @name Phaser.Loader.File#xhrLoader + * @type {?XMLHttpRequest} + * @since 3.0.0 + */ + this.xhrLoader = null; + + /** + * The current state of the file. One of the FILE_CONST values. + * + * @name Phaser.Loader.File#state + * @type {number} + * @since 3.0.0 + */ + this.state = (typeof(this.url) === 'function') ? CONST.FILE_POPULATED : CONST.FILE_PENDING; + + /** + * The total size of this file. + * Set by onProgress and only if loading via XHR. + * + * @name Phaser.Loader.File#bytesTotal + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bytesTotal = 0; + + /** + * Updated as the file loads. + * Only set if loading via XHR. + * + * @name Phaser.Loader.File#bytesLoaded + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.bytesLoaded = -1; + + /** + * A percentage value between 0 and 1 indicating how much of this file has loaded. + * Only set if loading via XHR. + * + * @name Phaser.Loader.File#percentComplete + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.percentComplete = -1; + + /** + * For CORS based loading. + * If this is undefined then the File will check LoaderPlugin.crossOrigin and use that (if set) + * + * @name Phaser.Loader.File#crossOrigin + * @type {(string|undefined)} + * @since 3.0.0 + */ + this.crossOrigin = undefined; + + /** + * The processed file data, stored here after the file has loaded. + * + * @name Phaser.Loader.File#data + * @type {*} + * @since 3.0.0 + */ + this.data = undefined; + + /** + * A config object that can be used by file types to store transitional data. + * + * @name Phaser.Loader.File#config + * @type {*} + * @since 3.0.0 + */ + this.config = GetFastValue(fileConfig, 'config', {}); + + /** + * If this is a multipart file, i.e. an atlas and its json together, then this is a reference + * to the parent MultiFile. Set and used internally by the Loader or specific file types. + * + * @name Phaser.Loader.File#multiFile + * @type {?Phaser.Loader.MultiFile} + * @since 3.7.0 + */ + this.multiFile; + + /** + * Does this file have an associated linked file? Such as an image and a normal map. + * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't + * actually bound by data, where-as a linkFile is. + * + * @name Phaser.Loader.File#linkFile + * @type {?Phaser.Loader.File} + * @since 3.7.0 + */ + this.linkFile; + + /** + * Does this File contain a data URI? + * + * @name Phaser.Loader.File#base64 + * @type {boolean} + * @since 3.80.0 + */ + this.base64 = (typeof url === 'string') && (url.indexOf('data:') === 0); + + /** + * The counter for the number of times to retry loading this file before it fails. + * + * You can set this property value in the FileConfig object. If not present, + * this property is read from the `LoaderPlugin.maxRetries` property when + * this File instance is created. + * + * You can set this value via the Game Config, or you can adjust the `LoaderPlugin` property + * at any point after the Loader has started. However, it will not apply to files + * that have already been added to the Loader, only those added after this value + * is changed. + * + * @name Phaser.Loader.File#retryAttempts + * @type {number} + * @default 2 + * @since 3.85.0 + */ + this.retryAttempts = GetFastValue(fileConfig, 'maxRetries', loader.maxRetries); + }, + + /** + * Links this File with another, so they depend upon each other for loading and processing. + * + * @method Phaser.Loader.File#setLink + * @since 3.7.0 + * + * @param {Phaser.Loader.File} fileB - The file to link to this one. + */ + setLink: function (fileB) + { + this.linkFile = fileB; + + fileB.linkFile = this; + }, + + /** + * Clears the `onload`, `onerror`, and `onprogress` event handlers from the XHRLoader instance + * this file is using, preventing stale callbacks from firing after the load has completed or errored. + * + * @method Phaser.Loader.File#resetXHR + * @since 3.0.0 + */ + resetXHR: function () + { + if (this.xhrLoader) + { + this.xhrLoader.onload = undefined; + this.xhrLoader.onerror = undefined; + this.xhrLoader.onprogress = undefined; + } + }, + + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + * + * @method Phaser.Loader.File#load + * @since 3.0.0 + */ + load: function () + { + if (this.state === CONST.FILE_POPULATED) + { + // Can happen for example in a JSONFile if they've provided a JSON object instead of a URL + this.loader.nextFile(this, true); + } + else + { + this.state = CONST.FILE_LOADING; + + this.src = GetURL(this, this.loader.baseURL); + + if (!this.src) + { + throw new Error('URL Error in File: ' + this.key + ' from: ' + this.url); + } + + if (this.src.indexOf('data:') === 0) + { + this.base64 = true; + } + + this.xhrLoader = XHRLoader(this, this.loader.xhr); + } + }, + + /** + * Called when the file finishes loading, is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onLoad + * @since 3.0.0 + * + * @param {XMLHttpRequest} xhr - The XMLHttpRequest that caused this onload event. + * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this load. + */ + onLoad: function (xhr, event) + { + var isLocalFile = xhr.responseURL && this.loader.localSchemes.some(function (scheme) + { + return xhr.responseURL.indexOf(scheme) === 0; + }); + + var localFileOk = (isLocalFile && event.target.status === 0); + + var success = !(event.target && event.target.status !== 200) || localFileOk; + + // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called. + if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) + { + success = false; + } + + this.state = CONST.FILE_LOADED; + + this.resetXHR(); + + this.loader.nextFile(this, success); + }, + + /** + * Called by the XHRLoader if it was given a File with base64 data to load. + * + * @method Phaser.Loader.File#onBase64Load + * @since 3.80.0 + * + * @param {XMLHttpRequest} xhr - The FakeXHR object containing the decoded base64 data. + */ + onBase64Load: function (xhr) + { + this.xhrLoader = xhr; + + this.state = CONST.FILE_LOADED; + + this.percentComplete = 1; + + this.loader.emit(Events.FILE_PROGRESS, this, this.percentComplete); + + this.loader.nextFile(this, true); + }, + + /** + * Called if the file errors while loading. Resets the XHR state, then either decrements + * `retryAttempts` and retries the load, or signals failure to the Loader via `nextFile` + * if no retry attempts remain. + * + * @method Phaser.Loader.File#onError + * @since 3.0.0 + * + * @param {XMLHttpRequest} xhr - The XMLHttpRequest that caused this onerror event. + * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this error. + */ + onError: function () + { + this.resetXHR(); + + if (this.retryAttempts > 0) + { + this.retryAttempts--; + + this.load(); + } + else + { + this.loader.nextFile(this, false); + } + }, + + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onProgress + * @fires Phaser.Loader.Events#FILE_PROGRESS + * @since 3.0.0 + * + * @param {ProgressEvent} event - The DOM ProgressEvent. + */ + onProgress: function (event) + { + if (event.lengthComputable) + { + this.bytesLoaded = event.loaded; + this.bytesTotal = event.total; + + this.percentComplete = Math.min((this.bytesLoaded / this.bytesTotal), 1); + + this.loader.emit(Events.FILE_PROGRESS, this, this.percentComplete); + } + }, + + /** + * Usually overridden by the FileTypes and is called by Loader.nextFile. + * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. + * + * @method Phaser.Loader.File#onProcess + * @since 3.0.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.onProcessComplete(); + }, + + /** + * Called when the File has completed processing. + * Checks on the state of its multifile, if set. + * + * @method Phaser.Loader.File#onProcessComplete + * @since 3.7.0 + */ + onProcessComplete: function () + { + this.state = CONST.FILE_COMPLETE; + + if (this.multiFile) + { + this.multiFile.onFileComplete(this); + } + + this.loader.fileProcessComplete(this); + }, + + /** + * Called when the File has completed processing but it generated an error. + * Checks on the state of its multifile, if set. + * + * @method Phaser.Loader.File#onProcessError + * @since 3.7.0 + */ + onProcessError: function () + { + // eslint-disable-next-line no-console + console.error('Failed to process file: %s "%s"', this.type, this.key); + + this.state = CONST.FILE_ERRORED; + + if (this.multiFile) + { + this.multiFile.onFileFailed(this); + } + + this.loader.fileProcessComplete(this); + }, + + /** + * Checks if a key matching the one used by this file exists in the target Cache or not. + * This is called automatically by the LoaderPlugin to decide if the file can be safely + * loaded or will conflict. + * + * @method Phaser.Loader.File#hasCacheConflict + * @since 3.7.0 + * + * @return {boolean} `true` if adding this file will cause a conflict, otherwise `false`. + */ + hasCacheConflict: function () + { + return (this.cache && this.cache.exists(this.key)); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * This method is often overridden by specific file types. + * + * @method Phaser.Loader.File#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.cache && this.data) + { + this.cache.add(this.key, this.data); + } + }, + + /** + * Called once the file has been added to its cache and is now ready for deletion from the Loader. + * It will emit a `filecomplete` event from the LoaderPlugin. + * + * @method Phaser.Loader.File#pendingDestroy + * @fires Phaser.Loader.Events#FILE_COMPLETE + * @fires Phaser.Loader.Events#FILE_KEY_COMPLETE + * @since 3.7.0 + */ + pendingDestroy: function (data) + { + if (this.state === CONST.FILE_PENDING_DESTROY) + { + return; + } + + if (data === undefined) { data = this.data; } + + var key = this.key; + var type = this.type; + + this.loader.emit(Events.FILE_COMPLETE, key, type, data); + this.loader.emit(Events.FILE_KEY_COMPLETE + type + '-' + key, key, type, data); + + this.loader.flagForRemoval(this); + + this.state = CONST.FILE_PENDING_DESTROY; + }, + + /** + * Destroy this File and any references it holds. + * + * @method Phaser.Loader.File#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.loader = null; + this.cache = null; + this.xhrSettings = null; + this.multiFile = null; + this.linkFile = null; + this.data = null; + } + +}); + +/** + * Static method for creating an object URL using the URL API and setting it as the image 'src' attribute. + * If the URL API is not supported (usually on old browsers) it falls back to creating a Base64 encoded URL using FileReader. + * + * @method Phaser.Loader.File.createObjectURL + * @static + * @since 3.7.0 + * + * @param {HTMLImageElement} image - Image object which 'src' attribute should be set to object URL. + * @param {Blob} blob - A Blob object to create an object URL for. + * @param {string} defaultType - Default mime type used if blob type is not available. + */ +File.createObjectURL = function (image, blob, defaultType) +{ + if (typeof URL === 'function') + { + image.src = URL.createObjectURL(blob); + } + else + { + var reader = new FileReader(); + + reader.onload = function () + { + image.removeAttribute('crossOrigin'); + image.src = 'data:' + (blob.type || defaultType) + ';base64,' + reader.result.split(',')[1]; + }; + + reader.onerror = image.onerror; + + reader.readAsDataURL(blob); + } +}; + +/** + * Static method for releasing an existing object URL which was previously created + * by calling {@link Phaser.Loader.File.createObjectURL} method. + * + * @method Phaser.Loader.File.revokeObjectURL + * @static + * @since 3.7.0 + * + * @param {HTMLImageElement} image - Image object which 'src' attribute should be revoked. + */ +File.revokeObjectURL = function (image) +{ + if (typeof URL === 'function') + { + URL.revokeObjectURL(image.src); + } +}; + +module.exports = File; + + +/***/ }, + +/***/ 74099 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var types = {}; + +/** + * The FileTypesManager is a static object containing a registry of file type loader functions. + * + * Each file type (such as `image`, `audio`, `tilemapTiledJSON`, etc.) registers itself here + * via the `register` method. When a LoaderPlugin is instantiated, it calls `install` to copy + * all registered file type methods onto itself, making them available as `this.load.image()`, + * `this.load.audio()`, and so on within a Scene. + * + * @namespace Phaser.Loader.FileTypesManager + */ + +var FileTypesManager = { + + /** + * Static method called when a LoaderPlugin is created. + * + * Loops through the local types object and injects all of them as + * properties into the LoaderPlugin instance. + * + * @method Phaser.Loader.FileTypesManager.install + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The LoaderPlugin to install the types into. + */ + install: function (loader) + { + for (var key in types) + { + loader[key] = types[key]; + } + }, + + /** + * Static method called directly by the File Types. + * + * The key is a reference to the function used to load the files via the Loader, i.e. `image`. + * + * @method Phaser.Loader.FileTypesManager.register + * @since 3.0.0 + * + * @param {string} key - The key that will be used as the method name in the LoaderPlugin. + * @param {function} factoryFunction - The function that will be called when LoaderPlugin.key is invoked. + */ + register: function (key, factoryFunction) + { + types[key] = factoryFunction; + }, + + /** + * Removes all associated file types. + * + * @method Phaser.Loader.FileTypesManager.destroy + * @since 3.0.0 + */ + destroy: function () + { + types = {}; + } + +}; + +module.exports = FileTypesManager; + + +/***/ }, + +/***/ 98356 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Given a File and a baseURL value, this returns the URL the File will use to download from. + * + * If the file has no URL, `false` is returned. If the file URL is already absolute (i.e. it + * begins with `blob:`, `data:`, `capacitor://`, `file://`, `http://`, `https://`, or `//`), + * it is returned as-is. Otherwise, the baseURL is prepended to the file URL to form a + * complete URL. + * + * @function Phaser.Loader.GetURL + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File object whose URL will be resolved. + * @param {string} baseURL - A default base URL to prepend when the file URL is relative. + * + * @return {string} The resolved URL the File will use to download from, or `false` if the file has no URL. + */ +var GetURL = function (file, baseURL) +{ + if (!file.url) + { + return false; + } + + if (file.url.match(/^(?:blob:|data:|capacitor:\/\/|file:\/\/|http:\/\/|https:\/\/|\/\/)/)) + { + return file.url; + } + else + { + return baseURL + file.url; + } +}; + +module.exports = GetURL; + + +/***/ }, + +/***/ 74261 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(54899); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var IsPlainObject = __webpack_require__(41212); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); +var XHRSettings = __webpack_require__(92638); + +/** + * @classdesc + * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. + * You typically interact with it via `this.load` in your Scene. Scenes can have a `preload` method, which is always + * called before the Scenes `create` method, allowing you to preload assets that the Scene may need. + * + * If you call any `this.load` methods from outside of `Scene.preload` then you need to start the Loader going + * yourself by calling `Loader.start()`. It's only automatically started during the Scene preload. + * + * The Loader uses a combination of tag loading (eg. Audio elements) and XHR and provides progress and completion events. + * Files are loaded in parallel by default. The amount of concurrent connections can be controlled in your Game Configuration. + * + * Once the Loader has started loading you are still able to add files to it. These can be injected as a result of a loader + * event, the type of file being loaded (such as a pack file) or other external events. As long as the Loader hasn't finished + * simply adding a new file to it, while running, will ensure it's added into the current queue. + * + * Every Scene has its own instance of the Loader and they are bound to the Scene in which they are created. However, + * assets loaded by the Loader are placed into global game-level caches. For example, loading an XML file will place that + * file inside `Game.cache.xml`, which is accessible from every Scene in your game, no matter who was responsible + * for loading it. The same is true of Textures. A texture loaded in one Scene is instantly available to all other Scenes + * in your game. + * + * The Loader works by using custom File Types. These are stored in the FileTypesManager, which injects them into the Loader + * when it's instantiated. You can create your own custom file types by extending either the File or MultiFile classes. + * See those files for more details. + * + * @class LoaderPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Loader + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene which owns this Loader instance. + */ +var LoaderPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function LoaderPlugin (scene) + { + EventEmitter.call(this); + + var gameConfig = scene.sys.game.config; + var sceneConfig = scene.sys.settings.loader; + + /** + * The Scene which owns this Loader instance. + * + * @name Phaser.Loader.LoaderPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene Systems. + * + * @name Phaser.Loader.LoaderPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the global Cache Manager. + * + * @name Phaser.Loader.LoaderPlugin#cacheManager + * @type {Phaser.Cache.CacheManager} + * @since 3.7.0 + */ + this.cacheManager = scene.sys.cache; + + /** + * A reference to the global Texture Manager. + * + * @name Phaser.Loader.LoaderPlugin#textureManager + * @type {Phaser.Textures.TextureManager} + * @since 3.7.0 + */ + this.textureManager = scene.sys.textures; + + /** + * A reference to the global Scene Manager. + * + * @name Phaser.Loader.LoaderPlugin#sceneManager + * @type {Phaser.Scenes.SceneManager} + * @protected + * @since 3.16.0 + */ + this.sceneManager = scene.sys.game.scene; + + // Inject the available filetypes into the Loader + FileTypesManager.install(this); + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * You can set this directly, or call `Loader.setPrefix()`. It will then affect every file added to the Loader + * from that point on. It does _not_ change any file already in the load queue. + * + * @name Phaser.Loader.LoaderPlugin#prefix + * @type {string} + * @default '' + * @since 3.7.0 + */ + this.prefix = ''; + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.path = "images/sprites/"; + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setPath()` and it'll do it for you. + * + * @name Phaser.Loader.LoaderPlugin#path + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.path = ''; + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setBaseURL()` and it'll do it for you. + * + * @name Phaser.Loader.LoaderPlugin#baseURL + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.baseURL = ''; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + + this.setPrefix(GetFastValue(sceneConfig, 'prefix', gameConfig.loaderPrefix)); + + /** + * The number of concurrent / parallel resources to try and fetch at once. + * + * Old browsers limit 6 requests per domain; modern ones, especially those with HTTP/2 don't limit it at all. + * + * The default is 32 but you can change this in your Game Config, or by changing this property before the Loader starts. + * + * @name Phaser.Loader.LoaderPlugin#maxParallelDownloads + * @type {number} + * @since 3.0.0 + */ + this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads); + + /** + * XHR-specific global settings (can be overridden on a per-file basis) + * + * @name Phaser.Loader.LoaderPlugin#xhr + * @type {Phaser.Types.Loader.XHRSettingsObject} + * @since 3.0.0 + */ + this.xhr = XHRSettings( + GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType), + GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync), + GetFastValue(sceneConfig, 'user', gameConfig.loaderUser), + GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword), + GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout), + GetFastValue(sceneConfig, 'withCredentials', gameConfig.loaderWithCredentials) + ); + + /** + * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. + * + * @name Phaser.Loader.LoaderPlugin#crossOrigin + * @type {string} + * @since 3.0.0 + */ + this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin); + + /** + * Optional load type for image files. `XHR` is the default. Set to `HTMLImageElement` to load images using the Image tag instead. + * + * @name Phaser.Loader.LoaderPlugin#imageLoadType + * @type {string} + * @since 3.60.0 + */ + this.imageLoadType = GetFastValue(sceneConfig, 'imageLoadType', gameConfig.loaderImageLoadType); + + /** + * An array of all schemes that the Loader considers as being 'local'. + * + * This is populated by the `Phaser.Core.Config#loaderLocalScheme` game configuration setting and defaults to + * `[ 'file://', 'capacitor://' ]`. Additional local schemes can be added to this array as needed. + * + * @name Phaser.Loader.LoaderPlugin#localSchemes + * @type {string[]} + * @since 3.60.0 + */ + this.localSchemes = GetFastValue(sceneConfig, 'localScheme', gameConfig.loaderLocalScheme); + + /** + * The total number of files to load. It may not always be accurate because you may add to the Loader during the process + * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. + * + * @name Phaser.Loader.LoaderPlugin#totalToLoad + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalToLoad = 0; + + /** + * The progress of the current load queue, as a float value between 0 and 1. + * This is updated automatically as files complete loading. + * Note that it is possible for this value to go down again if you add content to the current load queue during a load. + * + * @name Phaser.Loader.LoaderPlugin#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Files are placed in this Set when they're added to the Loader via `addFile`. + * + * They are moved to the `inflight` Set when they start loading, and assuming a successful + * load, to the `queue` Set for further processing. + * + * By the end of the load process this Set will be empty. + * + * @name Phaser.Loader.LoaderPlugin#list + * @type {Set.} + * @since 3.0.0 + */ + this.list = new Set(); + + /** + * Files are stored in this Set while they're in the process of being loaded. + * + * Upon a successful load they are moved to the `queue` Set. + * + * By the end of the load process this Set will be empty. + * + * @name Phaser.Loader.LoaderPlugin#inflight + * @type {Set.} + * @since 3.0.0 + */ + this.inflight = new Set(); + + /** + * Files are stored in this Set while they're being processed. + * + * If the process is successful they are moved to their final destination, which could be + * a Cache or the Texture Manager. + * + * At the end of the load process this Set will be empty. + * + * @name Phaser.Loader.LoaderPlugin#queue + * @type {Set.} + * @since 3.0.0 + */ + this.queue = new Set(); + + /** + * A temporary Set in which files are stored after processing, + * awaiting destruction at the end of the load process. + * + * @name Phaser.Loader.LoaderPlugin#_deleteQueue + * @type {Set.} + * @private + * @since 3.7.0 + */ + this._deleteQueue = new Set(); + + /** + * The total number of files that failed to load during the most recent load. + * This value is reset when you call `Loader.start`. + * + * @name Phaser.Loader.LoaderPlugin#totalFailed + * @type {number} + * @default 0 + * @since 3.7.0 + */ + this.totalFailed = 0; + + /** + * The total number of files that successfully loaded during the most recent load. + * This value is reset when you call `Loader.start`. + * + * @name Phaser.Loader.LoaderPlugin#totalComplete + * @type {number} + * @default 0 + * @since 3.7.0 + */ + this.totalComplete = 0; + + /** + * The current state of the Loader. + * + * @name Phaser.Loader.LoaderPlugin#state + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.state = CONST.LOADER_IDLE; + + /** + * The current index being used by multi-file loaders to avoid key clashes. + * + * @name Phaser.Loader.LoaderPlugin#multiKeyIndex + * @type {number} + * @private + * @since 3.20.0 + */ + this.multiKeyIndex = 0; + + /** + * The number of times to retry loading a single file before it fails. + * + * This property is read by the `File` object when it is created and set to + * the internal property of the same name. It's not used by the Loader itself. + * + * You can set this value via the Game Config, or you can adjust this property + * at any point after the Loader has started. However, it will not apply to files + * that have already been added to the Loader, only those added after this value + * is changed. + * + * @name Phaser.Loader.LoaderPlugin#maxRetries + * @type {number} + * @default 2 + * @since 3.85.0 + */ + this.maxRetries = GetFastValue(sceneConfig, 'maxRetries', gameConfig.loaderMaxRetries); + + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.pluginStart, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Loader.LoaderPlugin#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); + }, + + /** + * This method is called automatically by the Scene when it is starting up. + * It is responsible for creating local systems, properties and listening for Scene events. + * Do not invoke it directly. + * + * @method Phaser.Loader.LoaderPlugin#pluginStart + * @private + * @since 3.5.1 + */ + pluginStart: function () + { + this.systems.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * Once a base URL is set it will affect every file loaded by the Loader from that point on. It does _not_ change any + * file _already_ being loaded. To reset it, call this method with no arguments. + * + * @method Phaser.Loader.LoaderPlugin#setBaseURL + * @since 3.0.0 + * + * @param {string} [url] - The URL to use. Leave empty to reset. + * + * @return {this} This Loader object. + */ + setBaseURL: function (url) + { + if (url === undefined) { url = ''; } + + if (url !== '' && url.substr(-1) !== '/') + { + url = url.concat('/'); + } + + this.baseURL = url; + + return this; + }, + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.setPath("images/sprites/"); + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * Once a path is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * + * @method Phaser.Loader.LoaderPlugin#setPath + * @since 3.0.0 + * + * @param {string} [path] - The path to use. Leave empty to reset. + * + * @return {this} This Loader object. + */ + setPath: function (path) + { + if (path === undefined) { path = ''; } + + if (path !== '' && path.substr(-1) !== '/') + { + path = path.concat('/'); + } + + this.path = path; + + return this; + }, + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * + * Once a prefix is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * + * @method Phaser.Loader.LoaderPlugin#setPrefix + * @since 3.7.0 + * + * @param {string} [prefix] - The prefix to use. Leave empty to reset. + * + * @return {this} This Loader object. + */ + setPrefix: function (prefix) + { + if (prefix === undefined) { prefix = ''; } + + this.prefix = prefix; + + return this; + }, + + /** + * Sets the Cross Origin Resource Sharing value used when loading files. + * + * Files can override this value on a per-file basis by specifying an alternative `crossOrigin` value in their file config. + * + * Once CORs is set it will then affect every file loaded by the Loader from that point on, as long as they don't have + * their own CORs setting. To reset it, call this method with no arguments. + * + * For more details about CORs see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS + * + * @method Phaser.Loader.LoaderPlugin#setCORS + * @since 3.0.0 + * + * @param {string} [crossOrigin] - The value to use for the `crossOrigin` property in the load request. + * + * @return {this} This Loader object. + */ + setCORS: function (crossOrigin) + { + this.crossOrigin = crossOrigin; + + return this; + }, + + /** + * Adds a file, or array of files, into the load queue. + * + * The file must be an instance of `Phaser.Loader.File`, or a class that extends it. The Loader will check that the key + * used by the file won't conflict with any other key either in the loader, the inflight queue or the target cache. + * If allowed it will then add the file into the pending list, ready for the load to start. Or, if the load has already + * started, ready for the next batch of files to be pulled from the list to the inflight queue. + * + * You should not normally call this method directly, but rather use one of the Loader methods like `image` or `atlas`. + * However you can call this as long as the file given to it is well formed. + * + * @method Phaser.Loader.LoaderPlugin#addFile + * @fires Phaser.Loader.Events#ADD + * @since 3.0.0 + * + * @param {(Phaser.Loader.File|Phaser.Loader.File[])} file - The file, or array of files, to be added to the load queue. + */ + addFile: function (file) + { + if (!Array.isArray(file)) + { + file = [ file ]; + } + + for (var i = 0; i < file.length; i++) + { + var item = file[i]; + + // Does the file already exist in the cache or texture manager? + // Or will it conflict with a file already in the queue or inflight? + if (!this.keyExists(item)) + { + this.list.add(item); + + this.emit(Events.ADD, item.key, item.type, this, item); + + if (this.isLoading()) + { + this.totalToLoad++; + this.updateProgress(); + } + } + } + }, + + /** + * Checks the key and type of the given file to see if it will conflict with anything already + * in a Cache, the Texture Manager, or the list or inflight queues. + * + * @method Phaser.Loader.LoaderPlugin#keyExists + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The file to check the key of. + * + * @return {boolean} `true` if adding this file will cause a cache or queue conflict, otherwise `false`. + */ + keyExists: function (file) + { + var keyConflict = file.hasCacheConflict(); + + if (!keyConflict) + { + this.list.forEach(function (item) + { + if (item.type === file.type && item.key === file.key) + { + keyConflict = true; + + return false; + } + + }); + } + + if (!keyConflict && this.isLoading()) + { + this.inflight.forEach(function (item) + { + if (item.type === file.type && item.key === file.key) + { + keyConflict = true; + + return false; + } + + }); + + this.queue.forEach(function (item) + { + if (item.type === file.type && item.key === file.key) + { + keyConflict = true; + + return false; + } + + }); + } + + return keyConflict; + }, + + /** + * Takes a well formed, fully parsed pack file object and adds its entries into the load queue. Usually you do not call + * this method directly, but instead use `Loader.pack` and supply a path to a JSON file that holds the + * pack data. However, if you've got the data prepared you can pass it to this method. + * + * You can also provide an optional key. If you do then it will only add the entries from that part of the pack into + * to the load queue. If not specified it will add all entries it finds. For more details about the pack file format + * see the `LoaderPlugin.pack` method. + * + * @method Phaser.Loader.LoaderPlugin#addPack + * @since 3.7.0 + * + * @param {any} pack - The Pack File data to be parsed and have each entry in it added to the load queue. + * @param {string} [packKey] - An optional key to use from the pack file data. + * + * @return {boolean} `true` if any files were added to the queue, otherwise `false`. + */ + addPack: function (pack, packKey) + { + // if no packKey provided we'll add everything to the queue + if (typeof(packKey) === 'string') + { + var subPack = GetValue(pack, packKey); + + if (subPack) + { + pack = { packKey: subPack }; + } + } + + var total = 0; + + // Store the loader settings in case this pack replaces them + var currentBaseURL = this.baseURL; + var currentPath = this.path; + var currentPrefix = this.prefix; + + // Here we go ... + for (var key in pack) + { + if (!Object.prototype.hasOwnProperty.call(pack, key)) + { + continue; + } + + var config = pack[key]; + + // Any meta data to process? + var baseURL = GetFastValue(config, 'baseURL', currentBaseURL); + var path = GetFastValue(config, 'path', currentPath); + var prefix = GetFastValue(config, 'prefix', currentPrefix); + var files = GetFastValue(config, 'files', null); + var defaultType = GetFastValue(config, 'defaultType', 'void'); + + if (Array.isArray(files)) + { + this.setBaseURL(baseURL); + this.setPath(path); + this.setPrefix(prefix); + + for (var i = 0; i < files.length; i++) + { + var file = files[i]; + var type = (file.hasOwnProperty('type')) ? file.type : defaultType; + + if (this[type]) + { + this[type](file); + total++; + } + } + } + } + + // Reset the loader settings + this.setBaseURL(currentBaseURL); + this.setPath(currentPath); + this.setPrefix(currentPrefix); + + return (total > 0); + }, + + /** + * Remove the resources listed in an Asset Pack. + * + * This removes Animations from the Animation Manager, Textures from the Texture Manager, and all other assets from their respective caches. + * It doesn't remove the Pack itself from the JSON cache, if it exists there. + * If the Pack includes another Pack, its resources will be removed too. + * + * @method Phaser.Loader.LoaderPlugin#removePack + * @since 3.85.0 + * + * @param {(string|object)} packKey - The key of an Asset Pack in the JSON cache, or a Pack File data. + * @param {string} [dataKey] - A key in the Pack data, if you want to process only a section of it. + */ + removePack: function (packKey, dataKey) + { + var animationManager = this.systems.anims; + var cacheManager = this.cacheManager; + var textureManager = this.textureManager; + + var cacheMap = { + animation: 'json', + aseprite: 'json', + audio: 'audio', + audioSprite: 'audio', + binary: 'binary', + bitmapFont: 'bitmapFont', + css: null, + glsl: 'shader', + html: 'html', + json: 'json', + obj: 'obj', + plugin: null, + scenePlugin: null, + script: null, + spine: 'json', + text: 'text', + tilemapCSV: 'tilemap', + tilemapImpact: 'tilemap', + tilemapTiledJSON: 'tilemap', + video: 'video', + xml: 'xml' + }; + + var pack; + + if (IsPlainObject(packKey)) + { + pack = packKey; + } + else + { + pack = cacheManager.json.get(packKey); + + if (!pack) + { + console.warn('Asset Pack not found in JSON cache:', packKey); + + return; + } + } + + if (dataKey) + { + pack = { _: pack[dataKey] }; + } + + for (var configKey in pack) + { + var config = pack[configKey]; + var prefix = GetFastValue(config, 'prefix', ''); + var files = GetFastValue(config, 'files'); + var defaultType = GetFastValue(config, 'defaultType'); + + if (Array.isArray(files)) + { + for (var i = 0; i < files.length; i++) + { + var file = files[i]; + var type = (file.hasOwnProperty('type')) ? file.type : defaultType; + + if (!type) + { + console.warn('No type:', file); + + continue; + } + + var fileKey = prefix + file.key; + + if (type === 'animation') + { + animationManager.remove(fileKey); + } + + if (type === 'aseprite' || type === 'atlas' || type === 'atlasXML' || type === 'htmlTexture' || type === 'image' || type === 'multiatlas' || type === 'spritesheet' || type === 'svg' || type === 'texture' || type === 'unityAtlas') + { + textureManager.remove(fileKey); + + if (!cacheMap[type]) + { + continue; + } + } + + if (type === 'pack') + { + this.removePack(fileKey, file.dataKey); + + continue; + } + + if (type === 'spine') + { + var spineAtlas = cacheManager.custom.spine.get(fileKey); + + if (!spineAtlas) + { + continue; + } + + var spinePrefix = (spineAtlas.prefix === undefined) ? '' : spineAtlas.prefix; + + cacheManager.custom.spine.remove(fileKey); + + var spineTexture = cacheManager.custom.spineTextures.get(fileKey); + + if (!spineTexture) + { + continue; + } + + cacheManager.custom.spineTextures.remove(fileKey); + + for (var j = 0; j < spineTexture.pages.length; j++) + { + var page = spineTexture.pages[j]; + var textureKey = spinePrefix + page.name; + var altTextureKey = fileKey + ':' + textureKey; + + if (textureManager.exists(altTextureKey)) + { + textureManager.remove(altTextureKey); + } + else + { + textureManager.remove(textureKey); + } + } + } + + var cacheName = cacheMap[type]; + + if (cacheName === null) + { + // Nothing to remove. + + continue; + } + + if (!cacheName) + { + console.warn('Unknown type:', type); + + continue; + } + + var cache = cacheManager[cacheName]; + + cache.remove(fileKey); + } + } + } + }, + + /** + * Is the Loader actively loading, or processing loaded files? + * + * @method Phaser.Loader.LoaderPlugin#isLoading + * @since 3.0.0 + * + * @return {boolean} `true` if the Loader is busy loading or processing, otherwise `false`. + */ + isLoading: function () + { + return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING); + }, + + /** + * Is the Loader ready to start a new load? + * + * @method Phaser.Loader.LoaderPlugin#isReady + * @since 3.0.0 + * + * @return {boolean} `true` if the Loader is ready to start a new load, otherwise `false`. + */ + isReady: function () + { + return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE); + }, + + /** + * Starts the Loader running. This will reset the progress and totals and then emit a `start` event. + * If there is nothing in the queue the Loader will immediately complete, otherwise it will start + * loading the first batch of files. + * + * The Loader is started automatically if the queue is populated within your Scenes `preload` method. + * + * However, outside of this, you need to call this method to start it. + * + * If the Loader is already running this method will simply return. + * + * @method Phaser.Loader.LoaderPlugin#start + * @fires Phaser.Loader.Events#START + * @since 3.0.0 + */ + start: function () + { + if (!this.isReady()) + { + return; + } + + this.progress = 0; + + this.totalFailed = 0; + this.totalComplete = 0; + this.totalToLoad = this.list.size; + + this.emit(Events.START, this); + + if (this.list.size === 0) + { + this.loadComplete(); + } + else + { + this.state = CONST.LOADER_LOADING; + + this.inflight.clear(); + this.queue.clear(); + + this.updateProgress(); + + this.checkLoadQueue(); + + this.systems.events.on(SceneEvents.UPDATE, this.update, this); + } + }, + + /** + * Called automatically during the load process. + * It updates the `progress` value and then emits a progress event, which you can use to + * display a loading bar in your game. + * + * @method Phaser.Loader.LoaderPlugin#updateProgress + * @fires Phaser.Loader.Events#PROGRESS + * @since 3.0.0 + */ + updateProgress: function () + { + this.progress = 1 - ((this.list.size + this.inflight.size) / this.totalToLoad); + + this.emit(Events.PROGRESS, this.progress); + }, + + /** + * Called automatically once per game step while the Loader is in the LOADING state. + * Checks whether there is capacity in the inflight queue and, if so, calls `checkLoadQueue` + * to move more files from the pending list into active loading. + * + * @method Phaser.Loader.LoaderPlugin#update + * @since 3.10.0 + */ + update: function () + { + if (this.state === CONST.LOADER_LOADING && this.list.size > 0 && this.inflight.size < this.maxParallelDownloads) + { + this.checkLoadQueue(); + } + }, + + /** + * An internal method called by the Loader. + * + * It will check to see if there are any more files in the pending list that need loading, and if so it will move + * them from the list Set into the inflight Set, set their CORs flag and start them loading. + * + * It will carry on doing this for each file in the pending list until it runs out, or hits the max allowed parallel downloads. + * + * @method Phaser.Loader.LoaderPlugin#checkLoadQueue + * @private + * @since 3.7.0 + */ + checkLoadQueue: function () + { + this.list.forEach(function (file) + { + if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads)) + { + this.inflight.add(file); + + this.list.delete(file); + + // If the file doesn't have its own crossOrigin set, we'll use the Loaders (which is undefined by default) + if (!file.crossOrigin) + { + file.crossOrigin = this.crossOrigin; + } + + file.load(); + } + + if (this.inflight.size === this.maxParallelDownloads) + { + // Tells the Set iterator to abort + return false; + } + + }, this); + }, + + /** + * An internal method called automatically by the XHRLoader belonging to a File. + * + * This method will remove the given file from the inflight Set and update the load progress. + * If the file was successful its `onProcess` method is called, otherwise it is added to the delete queue. + * + * @method Phaser.Loader.LoaderPlugin#nextFile + * @fires Phaser.Loader.Events#FILE_LOAD + * @fires Phaser.Loader.Events#FILE_LOAD_ERROR + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File that just finished loading, or errored during load. + * @param {boolean} success - `true` if the file loaded successfully, otherwise `false`. + */ + nextFile: function (file, success) + { + // Has the game been destroyed during load? If so, bail out now. + if (!this.inflight) + { + return; + } + + this.inflight.delete(file); + + this.updateProgress(); + + if (success) + { + this.totalComplete++; + + this.queue.add(file); + + this.emit(Events.FILE_LOAD, file); + + file.onProcess(); + } + else + { + this.totalFailed++; + + this._deleteQueue.add(file); + + this.emit(Events.FILE_LOAD_ERROR, file); + + this.fileProcessComplete(file); + } + }, + + /** + * An internal method that is called automatically by the File when it has finished processing. + * + * If the process was successful, and the File isn't part of a MultiFile, its `addToCache` method is called. + * + * It is then removed from the queue. If there are no more files to load `loadComplete` is called. + * + * @method Phaser.Loader.LoaderPlugin#fileProcessComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The file that has finished processing. + */ + fileProcessComplete: function (file) + { + // Has the game been destroyed during load? If so, bail out now. + if (!this.scene || !this.systems || !this.systems.game || this.systems.game.pendingDestroy) + { + return; + } + + // This file has failed, so move it to the failed Set + if (file.state === CONST.FILE_ERRORED) + { + if (file.multiFile) + { + file.multiFile.onFileFailed(file); + } + } + else if (file.state === CONST.FILE_COMPLETE) + { + if (file.multiFile) + { + if (file.multiFile.isReadyToProcess()) + { + // If we got here then all files the link file needs are ready to add to the cache + file.multiFile.addToCache(); + file.multiFile.pendingDestroy(); + } + } + else + { + // If we got here, then the file processed, so let it add itself to its cache + file.addToCache(); + file.pendingDestroy(); + } + } + + // Remove it from the queue + this.queue.delete(file); + + // Nothing left to do? + + if (this.list.size === 0 && this.inflight.size === 0 && this.queue.size === 0) + { + this.loadComplete(); + } + }, + + /** + * Called at the end when the load queue is exhausted and all files have either loaded or errored. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Also clears down the Sets, puts progress to 1 and clears the deletion queue. + * + * @method Phaser.Loader.LoaderPlugin#loadComplete + * @fires Phaser.Loader.Events#COMPLETE + * @fires Phaser.Loader.Events#POST_PROCESS + * @since 3.7.0 + */ + loadComplete: function () + { + this.emit(Events.POST_PROCESS, this); + + this.list.clear(); + this.inflight.clear(); + this.queue.clear(); + + this.progress = 1; + + this.state = CONST.LOADER_COMPLETE; + + this.systems.events.off(SceneEvents.UPDATE, this.update, this); + + // Call 'destroy' on each file ready for deletion + this._deleteQueue.forEach(function (file) + { + file.destroy(); + }); + + this._deleteQueue.clear(); + + this.emit(Events.COMPLETE, this, this.totalComplete, this.totalFailed); + }, + + /** + * Adds a File into the pending-deletion queue. + * + * @method Phaser.Loader.LoaderPlugin#flagForRemoval + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File to be queued for deletion when the Loader completes. + */ + flagForRemoval: function (file) + { + this._deleteQueue.add(file); + }, + + /** + * Converts the given JavaScript object into JSON and triggers a browser download so you can save it locally. + * + * The data must be a plain JavaScript object that can be serialized via `JSON.stringify`. Do not pass a pre-stringified JSON string. + * + * @method Phaser.Loader.LoaderPlugin#saveJSON + * @since 3.0.0 + * + * @param {*} data - The JSON data, ready parsed. + * @param {string} [filename=file.json] - The name to save the JSON file as. + * + * @return {this} This Loader plugin. + */ + saveJSON: function (data, filename) + { + return this.save(JSON.stringify(data), filename); + }, + + /** + * Causes the browser to save the given data as a file to its default Downloads folder. + * + * Creates a DOM level anchor link, assigns it as being a `download` anchor, sets the href + * to be an ObjectURL based on the given data, and then invokes a click event. + * + * @method Phaser.Loader.LoaderPlugin#save + * @since 3.0.0 + * + * @param {*} data - The data to be saved. Will be passed through URL.createObjectURL. + * @param {string} [filename=file.json] - The filename to save the file as. + * @param {string} [filetype=application/json] - The file type to use when saving the file. Defaults to JSON. + * + * @return {this} This Loader plugin. + */ + save: function (data, filename, filetype) + { + if (filename === undefined) { filename = 'file.json'; } + if (filetype === undefined) { filetype = 'application/json'; } + + var blob = new Blob([ data ], { type: filetype }); + + var url = URL.createObjectURL(blob); + + var a = document.createElement('a'); + + a.download = filename; + a.textContent = 'Download ' + filename; + a.href = url; + a.click(); + + return this; + }, + + /** + * Resets the Loader. + * + * This will clear all lists and reset the base URL, path and prefix. + * + * Warning: If the Loader is currently downloading files, or has files in its queue, they will be aborted. + * + * @method Phaser.Loader.LoaderPlugin#reset + * @since 3.0.0 + */ + reset: function () + { + this.list.clear(); + this.inflight.clear(); + this.queue.clear(); + + var gameConfig = this.systems.game.config; + var sceneConfig = this.systems.settings.loader; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + this.setPrefix(GetFastValue(sceneConfig, 'prefix', gameConfig.loaderPrefix)); + + this.state = CONST.LOADER_IDLE; + }, + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + * + * @method Phaser.Loader.LoaderPlugin#shutdown + * @private + * @since 3.0.0 + */ + shutdown: function () + { + this.reset(); + + this.state = CONST.LOADER_SHUTDOWN; + + this.removeAllListeners(); + + this.systems.events.off(SceneEvents.UPDATE, this.update, this); + this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Phaser.Loader.LoaderPlugin#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.state = CONST.LOADER_DESTROYED; + + this.systems.events.off(SceneEvents.UPDATE, this.update, this); + this.systems.events.off(SceneEvents.START, this.pluginStart, this); + + this.list = null; + this.inflight = null; + this.queue = null; + + this.scene = null; + this.systems = null; + this.textureManager = null; + this.cacheManager = null; + this.sceneManager = null; + } + +}); + +PluginCache.register('Loader', LoaderPlugin, 'load'); + +module.exports = LoaderPlugin; + + +/***/ }, + +/***/ 3374 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Extend = __webpack_require__(79291); +var XHRSettings = __webpack_require__(92638); + +/** + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * + * @function Phaser.Loader.MergeXHRSettings + * @since 3.0.0 + * + * @param {Phaser.Types.Loader.XHRSettingsObject} global - The global XHRSettings object. + * @param {Phaser.Types.Loader.XHRSettingsObject} local - The local XHRSettings object. + * + * @return {Phaser.Types.Loader.XHRSettingsObject} A newly formed XHRSettings object. + */ +var MergeXHRSettings = function (global, local) +{ + var output = (global === undefined) ? XHRSettings() : Extend({}, global); + + if (local) + { + for (var setting in local) + { + if (local[setting] !== undefined) + { + output[setting] = local[setting]; + } + } + } + + return output; +}; + +module.exports = MergeXHRSettings; + + +/***/ }, + +/***/ 26430 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var Events = __webpack_require__(54899); + +/** + * @classdesc + * A MultiFile is a composite file that groups two or more individual File objects as children and + * coordinates their loading and processing as a single unit. When all child files have loaded, the + * MultiFile's `addToCache` method is called to combine the results (e.g., associating a texture + * image with its JSON atlas data). It is commonly extended as a base class for file types such as + * AtlasJSON, BitmapFont, and AudioSprite. You should not create an instance directly, but extend + * it and override `addToCache`. + * + * @class MultiFile + * @memberof Phaser.Loader + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {string} type - The file type string for sorting within the Loader. + * @param {string} key - The key of the file within the loader. + * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. + */ +var MultiFile = new Class({ + + initialize: + + function MultiFile (loader, type, key, files) + { + var finalFiles = []; + + // Clean out any potential 'null' or 'undefined' file entries + files.forEach(function (file) + { + if (file) + { + finalFiles.push(file); + } + }); + + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.MultiFile#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.7.0 + */ + this.loader = loader; + + /** + * The file type string for sorting within the Loader. + * + * @name Phaser.Loader.MultiFile#type + * @type {string} + * @since 3.7.0 + */ + this.type = type; + + /** + * Unique cache key (unique within its file type). + * + * @name Phaser.Loader.MultiFile#key + * @type {string} + * @since 3.7.0 + */ + this.key = key; + + var loadKey = this.key; + + if (loader.prefix && loader.prefix !== '') + { + this.key = loader.prefix + loadKey; + } + + /** + * The current index being used by multi-file loaders to avoid key clashes. + * + * @name Phaser.Loader.MultiFile#multiKeyIndex + * @type {number} + * @private + * @since 3.20.0 + */ + this.multiKeyIndex = loader.multiKeyIndex++; + + /** + * Array of files that make up this MultiFile. + * + * @name Phaser.Loader.MultiFile#files + * @type {Phaser.Loader.File[]} + * @since 3.7.0 + */ + this.files = finalFiles; + + /** + * The current state of the file. One of the FILE_CONST values. + * + * @name Phaser.Loader.MultiFile#state + * @type {number} + * @since 3.60.0 + */ + this.state = CONST.FILE_PENDING; + + /** + * The completion status of this MultiFile. + * + * @name Phaser.Loader.MultiFile#complete + * @type {boolean} + * @default false + * @since 3.7.0 + */ + this.complete = false; + + /** + * The number of child files still pending completion. Starts at the total number of child + * files and is decremented each time a child file finishes loading. When it reaches zero, + * all children have finished and the MultiFile may be processed. + * + * @name Phaser.Loader.MultiFile#pending + * @type {number} + * @since 3.7.0 + */ + + this.pending = finalFiles.length; + + /** + * The number of files that failed to load. + * + * @name Phaser.Loader.MultiFile#failed + * @type {number} + * @default 0 + * @since 3.7.0 + */ + this.failed = 0; + + /** + * A storage container for transient data that the loading files need. + * + * @name Phaser.Loader.MultiFile#config + * @type {any} + * @since 3.7.0 + */ + this.config = {}; + + /** + * A reference to the Loaders baseURL at the time this MultiFile was created. + * Used to populate child-files. + * + * @name Phaser.Loader.MultiFile#baseURL + * @type {string} + * @since 3.20.0 + */ + this.baseURL = loader.baseURL; + + /** + * A reference to the Loaders path at the time this MultiFile was created. + * Used to populate child-files. + * + * @name Phaser.Loader.MultiFile#path + * @type {string} + * @since 3.20.0 + */ + this.path = loader.path; + + /** + * A reference to the Loaders prefix at the time this MultiFile was created. + * Used to populate child-files. + * + * @name Phaser.Loader.MultiFile#prefix + * @type {string} + * @since 3.20.0 + */ + this.prefix = loader.prefix; + + // Link the files + for (var i = 0; i < finalFiles.length; i++) + { + finalFiles[i].multiFile = this; + } + }, + + /** + * Checks if this MultiFile is ready to process its children or not. + * + * @method Phaser.Loader.MultiFile#isReadyToProcess + * @since 3.7.0 + * + * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. + */ + isReadyToProcess: function () + { + return (this.pending === 0 && this.failed === 0 && !this.complete); + }, + + /** + * Adds another child to this MultiFile, increases the pending count and resets the completion status. + * + * @method Phaser.Loader.MultiFile#addToMultiFile + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File to add to this MultiFile. + * + * @return {Phaser.Loader.MultiFile} This MultiFile instance. + */ + addToMultiFile: function (file) + { + this.files.push(file); + + file.multiFile = this; + + this.pending++; + + this.complete = false; + + return this; + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + } + }, + + /** + * Called by each File that fails to load. + * + * @method Phaser.Loader.MultiFile#onFileFailed + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has failed to load. + */ + onFileFailed: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.failed++; + + // eslint-disable-next-line no-console + console.error('File failed: %s "%s" (via %s "%s")', this.type, this.key, file.type, file.key); + } + }, + + /** + * Called once all children of this MultiFile have been added to their caches and the + * MultiFile is now ready for deletion from the Loader. + * + * It will emit a `filecomplete` event from the LoaderPlugin. + * + * @method Phaser.Loader.MultiFile#pendingDestroy + * @fires Phaser.Loader.Events#FILE_COMPLETE + * @fires Phaser.Loader.Events#FILE_KEY_COMPLETE + * @since 3.60.0 + */ + pendingDestroy: function () + { + if (this.state === CONST.FILE_PENDING_DESTROY) + { + return; + } + + var key = this.key; + var type = this.type; + + this.loader.emit(Events.FILE_COMPLETE, key, type); + this.loader.emit(Events.FILE_KEY_COMPLETE + type + '-' + key, key, type); + + this.loader.flagForRemoval(this); + + for (var i = 0; i < this.files.length; i++) + { + this.files[i].pendingDestroy(); + } + + this.state = CONST.FILE_PENDING_DESTROY; + }, + + /** + * Destroy this Multi File and any references it holds. + * + * @method Phaser.Loader.MultiFile#destroy + * @since 3.60.0 + */ + destroy: function () + { + this.loader = null; + this.files = null; + this.config = null; + } + +}); + +module.exports = MultiFile; + + +/***/ }, + +/***/ 84376 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var MergeXHRSettings = __webpack_require__(3374); + +/** + * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings + * and starts the download of it. It uses the File's own XHRSettings and merges them + * with the global XHRSettings object to set the xhr values before download. + * + * @function Phaser.Loader.XHRLoader + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File to download. + * @param {Phaser.Types.Loader.XHRSettingsObject} globalXHRSettings - The global XHRSettings object. + * + * @return {XMLHttpRequest} The XHR object. For base64 files, `file.onBase64Load` is called directly and this function returns `undefined`. + */ +var XHRLoader = function (file, globalXHRSettings) +{ + var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); + + if (file.base64) + { + var base64Data = file.url.split(';base64,').pop() || file.url.split(',').pop(); + + var fakeXHR; + + if (file.xhrSettings.responseType === 'arraybuffer') + { + fakeXHR = { + response: Uint8Array.from(atob(base64Data), function (c) + { + return c.charCodeAt(0); + }).buffer + }; + } + else + { + fakeXHR = { + responseText: atob(base64Data) + }; + } + + file.onBase64Load(fakeXHR); + + return; + } + + var xhr = new XMLHttpRequest(); + + xhr.open('GET', file.src, config.async, config.user, config.password); + + xhr.responseType = file.xhrSettings.responseType; + xhr.timeout = config.timeout; + + if (config.headers) + { + for (var key in config.headers) + { + xhr.setRequestHeader(key, config.headers[key]); + } + } + + if (config.header && config.headerValue) + { + xhr.setRequestHeader(config.header, config.headerValue); + } + + if (config.requestedWith) + { + xhr.setRequestHeader('X-Requested-With', config.requestedWith); + } + + if (config.overrideMimeType) + { + xhr.overrideMimeType(config.overrideMimeType); + } + + if (config.withCredentials) + { + xhr.withCredentials = true; + } + + // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) + + xhr.onload = file.onLoad.bind(file, xhr); + xhr.onerror = file.onError.bind(file, xhr); + xhr.onprogress = file.onProgress.bind(file); + xhr.ontimeout = file.onError.bind(file, xhr); + + // This is the only standard method, the ones above are browser additions (maybe not universal?) + // xhr.onreadystatechange + + xhr.send(); + + return xhr; +}; + +module.exports = XHRLoader; + + +/***/ }, + +/***/ 92638 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Creates an XHRSettings Object with default values. + * + * The XHRSettings object is used by the Phaser Loader when making XMLHttpRequest calls + * to fetch external assets such as images, audio, JSON, and other files. You can pass a + * custom XHRSettings object to individual file load calls (e.g., `this.load.image`) to + * override the default request configuration on a per-file basis, or set global defaults + * via the Loader's `xhr` property. This is useful when loading from servers that require + * authentication credentials, custom headers, a specific MIME type override, or a + * non-default response type. + * + * @function Phaser.Loader.XHRSettings + * @since 3.0.0 + * + * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. + * @param {boolean} [async=true] - Should the XHR request use async or not? + * @param {string} [user=''] - Optional username for the XHR request. + * @param {string} [password=''] - Optional password for the XHR request. + * @param {number} [timeout=0] - Optional XHR timeout value, in milliseconds. A value of 0 disables the timeout. + * @param {boolean} [withCredentials=false] - Optional XHR withCredentials value. + * + * @return {Phaser.Types.Loader.XHRSettingsObject} The XHRSettings object as used by the Loader. + */ +var XHRSettings = function (responseType, async, user, password, timeout, withCredentials) +{ + if (responseType === undefined) { responseType = ''; } + if (async === undefined) { async = true; } + if (user === undefined) { user = ''; } + if (password === undefined) { password = ''; } + if (timeout === undefined) { timeout = 0; } + if (withCredentials === undefined) { withCredentials = false; } + + // Before sending a request, set the xhr.responseType to "text", + // "arraybuffer", "blob", or "document", depending on your data needs. + // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". + + return { + + // Ignored by the Loader, only used by File. + responseType: responseType, + + async: async, + + // credentials + user: user, + password: password, + + // timeout in ms (0 = no timeout) + timeout: timeout, + + // setRequestHeader + headers: undefined, + header: undefined, + headerValue: undefined, + requestedWith: false, + + // overrideMimeType + overrideMimeType: undefined, + + // withCredentials + withCredentials: withCredentials + + }; +}; + +module.exports = XHRSettings; + + +/***/ }, + +/***/ 23906 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var FILE_CONST = { + + /** + * The Loader is idle. + * + * @name Phaser.Loader.LOADER_IDLE + * @type {number} + * @since 3.0.0 + */ + LOADER_IDLE: 0, + + /** + * The Loader is actively loading. + * + * @name Phaser.Loader.LOADER_LOADING + * @type {number} + * @since 3.0.0 + */ + LOADER_LOADING: 1, + + /** + * The Loader is processing files it has loaded. + * + * @name Phaser.Loader.LOADER_PROCESSING + * @type {number} + * @since 3.0.0 + */ + LOADER_PROCESSING: 2, + + /** + * The Loader has completed loading and processing. + * + * @name Phaser.Loader.LOADER_COMPLETE + * @type {number} + * @since 3.0.0 + */ + LOADER_COMPLETE: 3, + + /** + * The Loader is shutting down. + * + * @name Phaser.Loader.LOADER_SHUTDOWN + * @type {number} + * @since 3.0.0 + */ + LOADER_SHUTDOWN: 4, + + /** + * The Loader has been destroyed. + * + * @name Phaser.Loader.LOADER_DESTROYED + * @type {number} + * @since 3.0.0 + */ + LOADER_DESTROYED: 5, + + /** + * File is in the load queue but not yet started. + * + * @name Phaser.Loader.FILE_PENDING + * @type {number} + * @since 3.0.0 + */ + FILE_PENDING: 10, + + /** + * File has started loading by the loader (onLoad called). + * + * @name Phaser.Loader.FILE_LOADING + * @type {number} + * @since 3.0.0 + */ + FILE_LOADING: 11, + + /** + * File has loaded successfully, awaiting processing. + * + * @name Phaser.Loader.FILE_LOADED + * @type {number} + * @since 3.0.0 + */ + FILE_LOADED: 12, + + /** + * File failed to load. + * + * @name Phaser.Loader.FILE_FAILED + * @type {number} + * @since 3.0.0 + */ + FILE_FAILED: 13, + + /** + * File is being processed (onProcess callback). + * + * @name Phaser.Loader.FILE_PROCESSING + * @type {number} + * @since 3.0.0 + */ + FILE_PROCESSING: 14, + + /** + * The file encountered an error during processing. + * + * @name Phaser.Loader.FILE_ERRORED + * @type {number} + * @since 3.0.0 + */ + FILE_ERRORED: 16, + + /** + * File has finished processing. + * + * @name Phaser.Loader.FILE_COMPLETE + * @type {number} + * @since 3.0.0 + */ + FILE_COMPLETE: 17, + + /** + * File has been destroyed. + * + * @name Phaser.Loader.FILE_DESTROYED + * @type {number} + * @since 3.0.0 + */ + FILE_DESTROYED: 18, + + /** + * File was populated from local data and doesn't need an HTTP request. + * + * @name Phaser.Loader.FILE_POPULATED + * @type {number} + * @since 3.0.0 + */ + FILE_POPULATED: 19, + + /** + * File is pending destruction. + * + * @name Phaser.Loader.FILE_PENDING_DESTROY + * @type {number} + * @since 3.60.0 + */ + FILE_PENDING_DESTROY: 20 + +}; + +module.exports = FILE_CONST; + + +/***/ }, + +/***/ 42155 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Loader Plugin Add File Event. + * + * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. + * + * Listen to it from a Scene using: `this.load.on('addfile', listener)`. + * + * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. + * + * @event Phaser.Loader.Events#ADD + * @type {string} + * @since 3.0.0 + * + * @param {string} key - The unique key of the file that was added to the Loader. + * @param {string} type - The [file type]{@link Phaser.Loader.File#type} string of the file that was added to the Loader, i.e. `image`. + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader Plugin that dispatched this event. + * @param {Phaser.Loader.File} file - A reference to the File which was added to the Loader. + */ +module.exports = 'addfile'; + + +/***/ }, + +/***/ 38991 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Loader Plugin Complete Event. + * + * This event is dispatched when the Loader has fully processed everything in the load queue. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Listen to it from a Scene using: `this.load.on('complete', listener)`. + * + * @event Phaser.Loader.Events#COMPLETE + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader Plugin that dispatched this event. + * @param {number} totalComplete - The total number of files that successfully loaded. + * @param {number} totalFailed - The total number of files that failed to load. + */ +module.exports = 'complete'; + + +/***/ }, + +/***/ 27540 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The File Load Complete Event. + * + * This event is dispatched by the Loader Plugin when _any_ file in the queue finishes loading. + * + * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. + * + * Make sure you remove this listener when you have finished, or it will continue to fire if the Scene reloads. + * + * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. + * + * @event Phaser.Loader.Events#FILE_COMPLETE + * @type {string} + * @since 3.0.0 + * + * @param {string} key - The key of the file that just loaded and finished processing. + * @param {string} type - The [file type]{@link Phaser.Loader.File#type} of the file that just loaded, i.e. `image`. + * @param {any} [data] - The raw data the file contained. If the file was a multi-file, like an atlas or bitmap font, this parameter will be undefined. + */ +module.exports = 'filecomplete'; + + +/***/ }, + +/***/ 87464 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The File Load Complete Event. + * + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * It uses a special dynamic event name constructed from the key and type of the file. + * + * For example, if you have loaded an `image` with a key of `monster`, you can listen for it + * using the following: + * + * ```javascript + * this.load.on('filecomplete-image-monster', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a texture `atlas` with a key of `Level1`: + * + * ```javascript + * this.load.on('filecomplete-atlasjson-Level1', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: + * + * ```javascript + * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Make sure you remove your listeners when you have finished, or they will continue to fire if the Scene reloads. + * + * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. + * + * @event Phaser.Loader.Events#FILE_KEY_COMPLETE + * @type {string} + * @since 3.0.0 + * + * @param {string} key - The key of the file that just loaded and finished processing. + * @param {string} type - The [file type]{@link Phaser.Loader.File#type} of the file that just loaded, i.e. `image`. + * @param {any} [data] - The raw data the file contained. If the file was a multi-file, like an atlas or bitmap font, this parameter will be undefined. + */ +module.exports = 'filecomplete-'; + + +/***/ }, + +/***/ 94486 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The File Load Error Event. + * + * This event is dispatched by the Loader Plugin when a file fails to load. + * + * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. + * + * @event Phaser.Loader.Events#FILE_LOAD_ERROR + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - A reference to the File which errored during load. + */ +module.exports = 'loaderror'; + + +/***/ }, + +/***/ 13035 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The File Load Event. + * + * This event is dispatched by the Loader Plugin when a file finishes loading, + * but _before_ it is processed and added to the internal Phaser caches. + * + * Listen to it from a Scene using: `this.load.on('load', listener)`. + * + * @event Phaser.Loader.Events#FILE_LOAD + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - A reference to the File which just finished loading. + */ +module.exports = 'load'; + + +/***/ }, + +/***/ 38144 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The File Load Progress Event. + * + * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and + * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. + * + * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. + * + * @event Phaser.Loader.Events#FILE_PROGRESS + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - A reference to the File for which progress has been updated. + * @param {number} percentComplete - A value between 0 and 1 indicating how 'complete' this file is. + */ +module.exports = 'fileprogress'; + + +/***/ }, + +/***/ 97520 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Loader Plugin Post Process Event. + * + * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. + * It is dispatched before the internal lists are cleared and each File is destroyed. + * + * Use this hook to perform any last minute processing of files that can only happen once the + * Loader has completed, but prior to it emitting the `complete` event. + * + * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. + * + * @event Phaser.Loader.Events#POST_PROCESS + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader Plugin that dispatched this event. + */ +module.exports = 'postprocess'; + + +/***/ }, + +/***/ 85595 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Loader Plugin Progress Event. + * + * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. + * + * Listen to it from a Scene using: `this.load.on('progress', listener)`. + * + * @event Phaser.Loader.Events#PROGRESS + * @type {string} + * @since 3.0.0 + * + * @param {number} progress - The current progress of the load. A value between 0 and 1. + */ +module.exports = 'progress'; + + +/***/ }, + +/***/ 55680 +(module) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Loader Plugin Start Event. + * + * This event is dispatched when the Loader starts running. At this point load progress is zero. + * + * This event is dispatched even if there aren't any files in the load queue. + * + * Listen to it from a Scene using: `this.load.on('start', listener)`. + * + * @event Phaser.Loader.Events#START + * @type {string} + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader Plugin that dispatched this event. + */ +module.exports = 'start'; + + +/***/ }, + +/***/ 54899 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Loader.Events + */ + +module.exports = { + + ADD: __webpack_require__(42155), + COMPLETE: __webpack_require__(38991), + FILE_COMPLETE: __webpack_require__(27540), + FILE_KEY_COMPLETE: __webpack_require__(87464), + FILE_LOAD_ERROR: __webpack_require__(94486), + FILE_LOAD: __webpack_require__(13035), + FILE_PROGRESS: __webpack_require__(38144), + POST_PROCESS: __webpack_require__(97520), + PROGRESS: __webpack_require__(85595), + START: __webpack_require__(55680) + +}; + + +/***/ }, + +/***/ 14135 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var JSONFile = __webpack_require__(518); +var LoaderEvents = __webpack_require__(54899); + +/** + * @classdesc + * A single Animation JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#animation method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#animation. + * + * @class AnimationJSONFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + */ +var AnimationJSONFile = new Class({ + + Extends: JSONFile, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing + + function AnimationJSONFile (loader, key, url, xhrSettings, dataKey) + { + JSONFile.call(this, loader, key, url, xhrSettings, dataKey); + + this.type = 'animationJSON'; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.AnimationJSONFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + // We need to hook into this event: + this.loader.once(LoaderEvents.POST_PROCESS, this.onLoadComplete, this); + + // But the rest is the same as a normal JSON file + JSONFile.prototype.onProcess.call(this); + }, + + /** + * Called at the end of the load process, after the Loader has finished all files in its queue. + * + * @method Phaser.Loader.FileTypes.AnimationJSONFile#onLoadComplete + * @since 3.7.0 + */ + onLoadComplete: function () + { + this.loader.systems.anims.fromJSON(this.data); + } + +}); + +/** + * Adds an Animation JSON Data file, or array of Animation JSON files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.animation({ + * key: 'baddieAnims', + * url: 'files/BaddieAnims.json' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.JSONFileConfig` for more details. + * + * Once the file has finished loading it will automatically be passed to the global Animation Manager's `fromJSON` method. + * This will parse all of the JSON data and create animation data from it. This process happens at the very end + * of the Loader, once every other file in the load queue has finished. The reason for this is to allow you to load + * both animation data and the images it relies upon in the same load call. + * + * Once the animation data has been parsed you will be able to play animations using that data. + * Please see the Animation Manager `fromJSON` method for more details about the format and playback. + * + * You can also access the raw animation data from its Cache using its key: + * + * ```javascript + * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); + * // and later in your game ... + * var data = this.cache.json.get('baddieAnims'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And if you only wanted to create animations from the `boss` data, then you could pass `level1.baddies.boss` as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#animation + * @fires Phaser.Loader.Events#ADD + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.JSONFileConfig|Phaser.Types.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [dataKey] - When the Animation JSON file loads only this property will be stored in the Cache and used to create animation data. + * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader instance. + */ +FileTypesManager.register('animation', function (key, url, dataKey, xhrSettings) +{ + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.addFile(new AnimationJSONFile(this, key[i])); + } + } + else + { + this.addFile(new AnimationJSONFile(this, key, url, xhrSettings, dataKey)); + } + + return this; +}); + +module.exports = AnimationJSONFile; + + +/***/ }, + +/***/ 76272 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var MultiFile = __webpack_require__(26430); + +/** + * @classdesc + * A single Aseprite Animation File suitable for loading by the Loader. + * + * Aseprite is an animated sprite editor and pixel art tool. This file type handles loading both + * the Aseprite sprite sheet image and its accompanying JSON data file, which contains frame and + * animation tag information. Once loaded, the texture and animation data are added to the Texture + * Manager and can be used to create animations via `AnimationManager.createFromAseprite`. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#aseprite method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#aseprite. + * + * @class AsepriteFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.50.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.AsepriteFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {object|string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ +var AsepriteFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AsepriteFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new JSONFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'json'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new JSONFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'atlasjson', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'atlasjson', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.AsepriteFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var json = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addAtlas(image.key, image.data, json.data, normalMap); + + json.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Aseprite is a powerful animated sprite editor and pixel art tool. + * + * You can find more details at https://www.aseprite.org/ + * + * Adds a JSON based Aseprite Animation, or array of animations, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.aseprite('gladiator', 'images/Gladiator.png', 'images/Gladiator.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * To export a compatible JSON file in Aseprite, please do the following: + * + * 1. Go to "File - Export Sprite Sheet" + * + * 2. On the **Layout** tab: + * 2a. Set the "Sheet type" to "Packed" + * 2b. Set the "Constraints" to "None" + * 2c. Check the "Merge Duplicates" checkbox + * + * 3. On the **Sprite** tab: + * 3a. Set "Layers" to "Visible layers" + * 3b. Set "Frames" to "All frames", unless you only wish to export a sub-set of tags + * + * 4. On the **Borders** tab: + * 4a. Check the "Trim Sprite" and "Trim Cells" options + * 4b. Ensure "Border Padding", "Spacing" and "Inner Padding" are all > 0 (1 is usually enough) + * + * 5. On the **Output** tab: + * 5a. Check "Output File", give your image a name and make sure you choose "png files" as the file type + * 5b. Check "JSON Data" and give your json file a name + * 5c. The JSON Data type can be either a Hash or Array, Phaser doesn't mind. + * 5d. Make sure "Tags" is checked in the Meta options + * 5e. In the "Item Filename" input box, make sure it says just "{frame}" and nothing more. + * + * 6. Click export + * + * This was tested with Aseprite 1.2.25. + * + * This will export a png and json file which you can load using the Aseprite Loader. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.aseprite({ + * key: 'gladiator', + * textureURL: 'images/Gladiator.png', + * atlasURL: 'images/Gladiator.json' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.AsepriteFileConfig` for more details. + * + * Instead of passing a URL for the JSON data you can also pass in a well formed JSON object instead. + * + * Once loaded, you can call this method from within a Scene with the 'atlas' key: + * + * ```javascript + * this.anims.createFromAseprite('paladin'); + * ``` + * + * Any animations defined in the JSON will now be available to use in Phaser and you play them + * via their Tag name. For example, if you have an animation called 'War Cry' on your Aseprite timeline, + * you can play it in Phaser using that Tag name: + * + * ```javascript + * this.add.sprite(400, 300).play('War Cry'); + * ``` + * + * When calling this method you can optionally provide an array of tag names, and only those animations + * will be created. For example: + * + * ```javascript + * this.anims.createFromAseprite('paladin', [ 'step', 'War Cry', 'Magnum Break' ]); + * ``` + * + * This will only create the 3 animations defined. Note that the tag names are case-sensitive. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Aseprite File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#aseprite + * @fires Phaser.Loader.Events#ADD + * @since 3.50.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.AsepriteFileConfig|Phaser.Types.Loader.FileTypes.AsepriteFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {object|string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader instance. + */ +FileTypesManager.register('aseprite', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AsepriteFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new AsepriteFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = AsepriteFile; + + +/***/ }, + +/***/ 38734 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var MultiFile = __webpack_require__(26430); + +/** + * @classdesc + * A single JSON based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. + * + * {@link https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm|Texture Packer - How to create sprite sheets for Phaser} + * + * @class AtlasJSONFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {object|string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ +var AtlasJSONFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AtlasJSONFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new JSONFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'json'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new JSONFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'atlasjson', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'atlasjson', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.AtlasJSONFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var json = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addAtlas(image.key, image.data, json.data, normalMap); + + this.complete = true; + } + } + +}); + +/** + * Adds a JSON based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a JSON file, using either the JSON Hash or JSON Array format. + * + * These files are created by software such as: + * + * * [Texture Packer](https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm) + * * [Shoebox](https://renderhjs.net/shoebox/) + * * [Gamma Texture Packer](https://gammafp.com/tool/atlas-packer/) + * * [Adobe Flash / Animate](https://www.adobe.com/uk/products/animate.html) + * * [Free Texture Packer](http://free-tex-packer.com/) + * * [Leshy SpriteSheet Tool](https://www.leshylabs.com/apps/sstool/) + * + * If you are using Texture Packer and have enabled multi-atlas support, then please use the Phaser Multi Atlas loader + * instead of this one. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.atlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.json' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig` for more details. + * + * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.json'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.json' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORS and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#atlas + * @fires Phaser.Loader.Events#ADD + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig|Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {object|string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader instance. + */ +FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AtlasJSONFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new AtlasJSONFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = AtlasJSONFile; + + +/***/ }, + +/***/ 74599 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var MultiFile = __webpack_require__(26430); +var XMLFile = __webpack_require__(57318); + +/** + * @classdesc + * An XML-based Texture Atlas File that coordinates the loading of both a texture image and its associated XML data + * file as a single unit. Both files must load successfully before the atlas is registered with the Texture Manager. + * Once registered, individual frames defined in the XML can be used as textures for Game Objects throughout your game. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. + * + * @class AtlasXMLFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + */ +var AtlasXMLFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AtlasXMLFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'xml'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'atlasxml', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'atlasxml', key, [ image, data ]); + } + }, + + /** + * Checks whether both the image and XML data files have finished loading, and if so, registers the texture atlas + * with the Texture Manager. An optional normal map (the third file in the set) is also passed through if present. + * Sets `complete` to `true` once the atlas has been added. + * + * @method Phaser.Loader.FileTypes.AtlasXMLFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addAtlasXML(image.key, image.data, xml.data, normalMap); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in an XML file format. + * These files are created by software such as Shoebox and Adobe Flash / Animate. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORS and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#atlasXML + * @fires Phaser.Loader.Events#ADD + * @since 3.7.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig|Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader instance. + */ +FileTypesManager.register('atlasXML', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AtlasXMLFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new AtlasXMLFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = AtlasXMLFile; + + +/***/ }, + +/***/ 21097 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var HTML5AudioFile = __webpack_require__(89749); +var IsPlainObject = __webpack_require__(41212); + +/** + * @classdesc + * A single Audio File suitable for loading by the Loader via the Web Audio API. + * + * This file type loads audio data as an ArrayBuffer over XHR and then decodes it into an AudioBuffer + * using the Web Audio API's `decodeAudioData` method. The resulting AudioBuffer is stored in the + * Phaser Audio Cache, ready for use by the Sound Manager. + * + * If the device does not support the Web Audio API, or if Web Audio has been disabled in the game + * configuration, an `HTML5AudioFile` will be created instead. You do not need to choose between them + * manually — use `Phaser.Loader.LoaderPlugin#audio` and Phaser will select the correct file type + * automatically based on device capabilities. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. + * + * @class AudioFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.AudioFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {Phaser.Types.Loader.FileTypes.AudioFileURLConfig} [urlConfig] - The absolute or relative URL to load this file from in a config object. + * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {AudioContext} [audioContext] - The AudioContext this file will use to process itself. + */ +var AudioFile = new Class({ + + Extends: File, + + initialize: + + // URL is an object created by AudioFile.findAudioURL + function AudioFile (loader, key, urlConfig, xhrSettings, audioContext) + { + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + audioContext = GetFastValue(config, 'context', audioContext); + } + + var fileConfig = { + type: 'audio', + cache: loader.cacheManager.audio, + extension: urlConfig.type, + responseType: 'arraybuffer', + key: key, + url: urlConfig.url, + xhrSettings: xhrSettings, + config: { context: audioContext } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method decodes the raw audio ArrayBuffer loaded via XHR using the Web Audio API's + * `decodeAudioData` method. On success, the resulting AudioBuffer is stored in `this.data` + * and `onProcessComplete` is called to advance the load queue. On failure, an error is logged + * to the console and `onProcessError` is called. The AudioContext reference is released after + * decoding begins to avoid retaining it unnecessarily. + * + * @method Phaser.Loader.FileTypes.AudioFile#onProcess + * @since 3.0.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var _this = this; + + // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 + this.config.context.decodeAudioData(this.xhrLoader.response, + function (audioBuffer) + { + _this.data = audioBuffer; + + _this.onProcessComplete(); + }, + function (e) + { + // eslint-disable-next-line no-console + console.error('Error decoding audio: ' + _this.key + ' - ', e ? e.message : null); + + _this.onProcessError(); + } + ); + + this.config.context = null; + } + +}); + +/** + * Static factory method that creates the correct type of audio file for the current device. + * + * Inspects the game's audio configuration and device capabilities to decide whether to return + * a Web Audio API-based `AudioFile` or a fallback `HTML5AudioFile`. It first calls + * `AudioFile.getAudioURL` to find a suitable URL from the provided list that the browser can + * play. If no compatible URL is found, a warning is logged and `null` is returned. + * + * @function Phaser.Loader.FileTypes.AudioFile.create + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.AudioFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {(string|string[]|Phaser.Types.Loader.FileTypes.AudioFileURLConfig|Phaser.Types.Loader.FileTypes.AudioFileURLConfig[])} [urls] - The absolute or relative URL(s) to load the audio from. + * @param {any} [config] - An object containing an `instances` property for HTML5Audio. Defaults to 1. + * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * + * @return {?(Phaser.Loader.FileTypes.AudioFile|Phaser.Loader.FileTypes.HTML5AudioFile)} The created audio file instance, or `null` if no supported URL was found. + */ +AudioFile.create = function (loader, key, urls, config, xhrSettings) +{ + var game = loader.systems.game; + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + // url may be inside key, which may be an object + if (IsPlainObject(key)) + { + urls = GetFastValue(key, 'url', []); + config = GetFastValue(key, 'config', {}); + } + + var urlConfig = AudioFile.getAudioURL(game, urls); + + if (!urlConfig) + { + console.warn('No audio URLs for "%s" can play on this device', key); + + return null; + } + + // https://developers.google.com/web/updates/2012/02/HTML5-audio-and-the-Web-Audio-API-are-BFFs + // var stream = GetFastValue(config, 'stream', false); + + if (deviceAudio.webAudio && !audioConfig.disableWebAudio) + { + return new AudioFile(loader, key, urlConfig, xhrSettings, game.sound.context); + } + else + { + return new HTML5AudioFile(loader, key, urlConfig, config); + } +}; + +/** + * Takes an array of audio URLs and returns a URL config object for the first entry that + * the current device is capable of playing, based on the audio format indicated by the + * file extension or an explicit `type` property on the URL config object. + * + * Blob and data URIs are always accepted and returned immediately regardless of format. + * For regular URLs, the extension is extracted from the filename and checked against + * `game.device.audio`. If no supported URL is found, `null` is returned. + * + * @function Phaser.Loader.FileTypes.AudioFile.getAudioURL + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser Game instance. + * @param {(string|string[]|Phaser.Types.Loader.FileTypes.AudioFileURLConfig|Phaser.Types.Loader.FileTypes.AudioFileURLConfig[])} urls - One or more audio URLs to test for browser support. + * + * @return {?Phaser.Types.Loader.FileTypes.AudioFileURLConfig} A URL config object with `url` and `type` properties for the first supported audio URL, or `null` if none are supported. + */ +AudioFile.getAudioURL = function (game, urls) +{ + if (!Array.isArray(urls)) + { + urls = [ urls ]; + } + + for (var i = 0; i < urls.length; i++) + { + var url = GetFastValue(urls[i], 'url', urls[i]); + + if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0) + { + return { + url: url, + type: '' + }; + } + + var audioType = url.match(/\.([a-zA-Z0-9]+)($|\?)/); + + audioType = GetFastValue(urls[i], 'type', (audioType) ? audioType[1] : '').toLowerCase(); + + if (game.device.audio[audioType]) + { + return { + url: url, + type: audioType + }; + } + } + + return null; +}; + +/** + * Adds an Audio or HTML5Audio file, or array of audio files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.audio('title', [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ]); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Audio Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.audio({ + * key: 'title', + * url: [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ] + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.AudioFileConfig` for more details. + * + * The URLs can be relative or absolute. If the URLs are relative the `Loader.baseURL` and `Loader.path` values will be prepended to them. + * + * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. + * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on + * browser support. + * + * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. + * + * Note: The ability to load this type of file will only be available if the Audio File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#audio + * @fires Phaser.Loader.Events#ADD + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.AudioFileConfig|Phaser.Types.Loader.FileTypes.AudioFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {(string|string[]|Phaser.Types.Loader.FileTypes.AudioFileURLConfig|Phaser.Types.Loader.FileTypes.AudioFileURLConfig[])} [urls] - The absolute or relative URL to load the audio files from. + * @param {any} [config] - An object containing an `instances` property for HTML5Audio. Defaults to 1. + * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader instance. + */ +FileTypesManager.register('audio', function (key, urls, config, xhrSettings) +{ + var game = this.systems.game; + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if (audioConfig.noAudio || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + // Sounds are disabled, so skip loading audio + return this; + } + + var audioFile; + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + audioFile = AudioFile.create(this, key[i]); + + if (audioFile) + { + this.addFile(audioFile); + } + } + } + else + { + audioFile = AudioFile.create(this, key, urls, config, xhrSettings); + + if (audioFile) + { + this.addFile(audioFile); + } + } + + return this; +}); + +module.exports = AudioFile; + + +/***/ }, + +/***/ 89524 +(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var AudioFile = __webpack_require__(21097); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var MultiFile = __webpack_require__(26430); + +/** + * @classdesc + * An Audio Sprite File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audioSprite method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audioSprite. + * + * @class AudioSpriteFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + * @param {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {any} [audioConfig] - The audio configuration options. + * @param {Phaser.Types.Loader.XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. + */ +var AudioSpriteFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AudioSpriteFile (loader, key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings) + { + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + jsonURL = GetFastValue(config, 'jsonURL'); + audioURL = GetFastValue(config, 'audioURL'); + audioConfig = GetFastValue(config, 'audioConfig'); + audioXhrSettings = GetFastValue(config, 'audioXhrSettings'); + jsonXhrSettings = GetFastValue(config, 'jsonXhrSettings'); + } + + var data; + + // No url? then we're going to do a json load and parse it from that + if (!audioURL) + { + data = new JSONFile(loader, key, jsonURL, jsonXhrSettings); + + MultiFile.call(this, loader, 'audiosprite', key, [ data ]); + + this.config.resourceLoad = true; + this.config.audioConfig = audioConfig; + this.config.audioXhrSettings = audioXhrSettings; + } + else + { + var audio = AudioFile.create(loader, key, audioURL, audioConfig, audioXhrSettings); + + if (audio) + { + data = new JSONFile(loader, key, jsonURL, jsonXhrSettings); + + MultiFile.call(this, loader, 'audiosprite', key, [ audio, data ]); + + this.config.resourceLoad = false; + } + } + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.FileTypes.AudioSpriteFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + + if (this.config.resourceLoad && file.type === 'json' && file.data.hasOwnProperty('resources')) + { + // Inspect the data for the files to now load + var urls = file.data.resources; + + var audioConfig = GetFastValue(this.config, 'audioConfig'); + var audioXhrSettings = GetFastValue(this.config, 'audioXhrSettings'); + + var audio = AudioFile.create(this.loader, file.key, urls, audioConfig, audioXhrSettings); + + if (audio) + { + this.addToMultiFile(audio); + + this.loader.addFile(audio); + } + } + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.AudioSpriteFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var fileA = this.files[0]; + var fileB = this.files[1]; + + fileA.addToCache(); + fileB.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds a JSON based Audio Sprite, or array of audio sprites, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.audioSprite('kyobi', 'kyobi.json', [ + * 'kyobi.ogg', + * 'kyobi.mp3', + * 'kyobi.m4a' + * ]); + * } + * ``` + * + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * + * If the JSON file includes a 'resource' object then you can let Phaser parse it and load the audio + * files automatically based on its content. To do this exclude the audio URLs from the load: + * + * ```javascript + * function preload () + * { + * this.load.audioSprite('kyobi', 'kyobi.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Audio Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.audioSprite({ + * key: 'kyobi', + * jsonURL: 'audio/Kyobi.json', + * audioURL: [ + * 'audio/Kyobi.ogg', + * 'audio/Kyobi.mp3', + * 'audio/Kyobi.m4a' + * ] + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig` for more details. + * + * Instead of passing a URL for the audio JSON data you can also pass in a well formed JSON object instead. + * + * Once the audio has finished loading you can use it create an Audio Sprite by referencing its key: + * + * ```javascript + * this.load.audioSprite('kyobi', 'kyobi.json'); + * // and later in your game ... + * var music = this.sound.addAudioSprite('kyobi'); + * music.play('title'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this file's + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the audio sprite from the Audio Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. + * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on + * browser support. + * + * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. + * + * Note: The ability to load this type of file will only be available if the Audio Sprite File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#audioSprite + * @fires Phaser.Loader.Events#ADD + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig|Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig[])} key - The key to use for this file, or a file configuration object, or an array of objects. + * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + * @param {(string|string[])} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {any} [audioConfig] - The audio configuration options. + * @param {Phaser.Types.Loader.XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader. + */ +FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings) +{ + var game = this.systems.game; + var gameAudioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((gameAudioConfig && gameAudioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + // Sounds are disabled, so skip loading audio + return this; + } + + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AudioSpriteFile(this, key[i]); + + if (multifile.files) + { + this.addFile(multifile.files); + } + } + } + else + { + multifile = new AudioSpriteFile(this, key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings); + + if (multifile.files) + { + this.addFile(multifile.files); + } + } + + return this; +}); + + +/***/ }, + +/***/ 85722 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); + +/** + * @classdesc + * A single Binary File suitable for loading by the Loader. + * + * Binary files are used to load raw binary data, such as custom level formats, game data archives, or any file + * whose contents must be handled as an `ArrayBuffer` rather than parsed text or an image. Once loaded, the data + * is stored in the Binary Cache and can optionally be cast to a typed array (e.g. `Uint8Array`) automatically + * by providing a `dataType` constructor. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. + * + * @class BinaryFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.BinaryFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ +var BinaryFile = new Class({ + + Extends: File, + + initialize: + + function BinaryFile (loader, key, url, xhrSettings, dataType) + { + var extension = 'bin'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + dataType = GetFastValue(config, 'dataType', dataType); + } + + var fileConfig = { + type: 'binary', + cache: loader.cacheManager.binary, + extension: extension, + responseType: 'arraybuffer', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { dataType: dataType } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method processes the raw XHR response: if a `dataType` constructor was specified (e.g. `Uint8Array`), + * it wraps the `ArrayBuffer` response in a new instance of that type; otherwise the raw `ArrayBuffer` is + * stored directly as the file's data. + * + * @method Phaser.Loader.FileTypes.BinaryFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var ctor = this.config.dataType; + + this.data = (ctor) ? new ctor(this.xhrLoader.response) : this.xhrLoader.response; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Binary file, or array of Binary files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.binary('doom', 'files/Doom.wad'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Binary Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Binary Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.binary({ + * key: 'doom', + * url: 'files/Doom.wad', + * dataType: Uint8Array + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.BinaryFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.binary('doom', 'files/Doom.wad'); + * // and later in your game ... + * var data = this.cache.binary.get('doom'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and + * this is what you would use to retrieve the text from the Binary Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "doom" + * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Binary File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#binary + * @fires Phaser.Loader.Events#ADD + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.BinaryFileConfig|Phaser.Types.Loader.FileTypes.BinaryFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader instance. + */ +FileTypesManager.register('binary', function (key, url, dataType, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new BinaryFile(this, key[i])); + } + } + else + { + this.addFile(new BinaryFile(this, key, url, xhrSettings, dataType)); + } + + return this; +}); + +module.exports = BinaryFile; + + +/***/ }, + +/***/ 97025 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var MultiFile = __webpack_require__(26430); +var ParseXMLBitmapFont = __webpack_require__(21859); +var XMLFile = __webpack_require__(57318); + +/** + * @classdesc + * A single Bitmap Font based File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. + * + * @class BitmapFontFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Types.Loader.FileTypes.BitmapFontFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + */ +var BitmapFontFile = new Class({ + + Extends: MultiFile, + + initialize: + + function BitmapFontFile (loader, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'fontDataURL'), + extension: GetFastValue(config, 'fontDataExtension', 'xml'), + xhrSettings: GetFastValue(config, 'fontDataXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, fontDataURL, fontDataXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.BitmapFontFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + + image.addToCache(); + + var texture = image.cache.get(image.key); + + var data = ParseXMLBitmapFont(xml.data, image.cache.getFrame(image.key), 0, 0, texture); + + this.loader.cacheManager.bitmapFont.add(image.key, { data: data, texture: image.key, frame: null }); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Bitmap Font, or array of fonts, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the font data to be provided in an XML file format. + * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), + * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.BitmapFontFileConfig` for more details. + * + * Once the bitmap font has finished loading you can use the key of it when creating a Bitmap Text Game Object: + * + * ```javascript + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * // and later in your game ... + * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use when creating a Bitmap Text object. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * normalMap: 'images/GoldFont-n.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Bitmap Font File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#bitmapFont + * @fires Phaser.Loader.Events#ADD + * @since 3.0.0 + * + * @param {(string|Phaser.Types.Loader.FileTypes.BitmapFontFileConfig|Phaser.Types.Loader.FileTypes.BitmapFontFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {Phaser.Types.Loader.XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {this} The Loader instance. + */ +FileTypesManager.register('bitmapFont', function (key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new BitmapFontFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new BitmapFontFile(this, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = BitmapFontFile; + + +/***/ }, + +/***/ 16024 +(module, __unused_webpack_exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2013-2026 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); + +/** + * @classdesc + * A single CSS File suitable for loading by the Loader. When loaded, the CSS is injected into the + * document by creating a `