@energy8platform/game-engine 0.14.10 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1278,16 +1278,35 @@ interface FlexItemConfig {
1278
1278
  layoutHeight?: number | string;
1279
1279
  /** Override parent's alignItems for this child */
1280
1280
  alignSelf?: AlignSelf;
1281
- /** Exclude from flex layout (acts like position: absolute) */
1281
+ /**
1282
+ * Exclude from flex layout (acts like position: absolute).
1283
+ *
1284
+ * Positioning props (`top`/`right`/`bottom`/`left`/`centerX`/`centerY`) describe
1285
+ * the **visual bounding rectangle**, so children with a centered internal
1286
+ * origin (Button, Label — `anchor = 0.5`) are positioned intuitively.
1287
+ * `left: 100` places the visible left edge at 100px, regardless of origin.
1288
+ */
1282
1289
  flexExclude?: boolean;
1283
- /** Absolute positioning for flexExclude children (distance from top edge) */
1290
+ /** Distance from top edge of parent content area to the child's visual top */
1284
1291
  top?: number;
1285
- /** Absolute positioning for flexExclude children (distance from right edge) */
1292
+ /** Distance from right edge of parent content area to the child's visual right */
1286
1293
  right?: number;
1287
- /** Absolute positioning for flexExclude children (distance from bottom edge) */
1294
+ /** Distance from bottom edge of parent content area to the child's visual bottom */
1288
1295
  bottom?: number;
1289
- /** Absolute positioning for flexExclude children (distance from left edge) */
1296
+ /** Distance from left edge of parent content area to the child's visual left */
1290
1297
  left?: number;
1298
+ /**
1299
+ * X coordinate of the child's visual center within parent content area.
1300
+ * Accepts pixels (`200`) or a percentage of parent content width (`'50%'`).
1301
+ * Takes precedence over `left`/`right`.
1302
+ */
1303
+ centerX?: number | string;
1304
+ /**
1305
+ * Y coordinate of the child's visual center within parent content area.
1306
+ * Accepts pixels or a percentage of parent content height (`'50%'`).
1307
+ * Takes precedence over `top`/`bottom`.
1308
+ */
1309
+ centerY?: number | string;
1291
1310
  }
1292
1311
  interface FlexContainerConfig {
1293
1312
  /** Layout direction (default: 'row') */
package/dist/index.esm.js CHANGED
@@ -768,6 +768,9 @@ class AudioManager {
768
768
  this._soundModule = await import('@pixi/sound');
769
769
  this._initialized = true;
770
770
  this.applyVolumes();
771
+ if (this._globalMuted) {
772
+ this._soundModule.sound.muteAll();
773
+ }
771
774
  this.setupMobileUnlock();
772
775
  }
773
776
  catch {
@@ -1025,7 +1028,9 @@ class AudioManager {
1025
1028
  if (!this._soundModule)
1026
1029
  return;
1027
1030
  const { sound } = this._soundModule;
1028
- sound.volumeAll = this._globalMuted ? 0 : 1;
1031
+ // Global mute is owned by sound.muteAll()/unmuteAll() (context.muted),
1032
+ // not by volumeAll — mixing both leaves mute un-undoable after reload.
1033
+ sound.volumeAll = 1;
1029
1034
  }
1030
1035
  setupMobileUnlock() {
1031
1036
  if (this._unlocked)
@@ -3444,22 +3449,31 @@ class FlexContainer extends Container {
3444
3449
  this._computedWidth = this._explicitWidth > 0 ? this._explicitWidth : (pl + totalCrossNatural + pr);
3445
3450
  this._computedHeight = this._explicitHeight > 0 ? this._explicitHeight : (pt + naturalMainSize + pb);
3446
3451
  }
3447
- // Position flexExclude children (absolute positioning)
3452
+ // Position flexExclude children (absolute positioning).
3453
+ // All position props describe the visual (bounds) rectangle, so we subtract
3454
+ // `ox/oy` to compensate for children with a centered origin (Button, Label).
3455
+ // `centerX/centerY` take precedence over `left/right` / `top/bottom` on each axis.
3448
3456
  for (const child of this._layoutChildren) {
3449
3457
  if (!child._flexConfig?.flexExclude)
3450
3458
  continue;
3451
3459
  const cfg = child._flexConfig;
3452
- const { w, h } = measureChild(child, pctRefW, pctRefH);
3460
+ const { w, h, ox, oy } = measureChild(child, pctRefW, pctRefH);
3453
3461
  const cw = this._computedWidth;
3454
3462
  const ch = this._computedHeight;
3455
- if (cfg.left !== undefined)
3456
- child.x = cfg.left;
3463
+ const centerX = resolveDimension(cfg.centerX, pctRefW);
3464
+ if (centerX !== undefined)
3465
+ child.x = centerX - w / 2 - ox;
3466
+ else if (cfg.left !== undefined)
3467
+ child.x = cfg.left - ox;
3457
3468
  else if (cfg.right !== undefined)
3458
- child.x = cw - w - cfg.right;
3459
- if (cfg.top !== undefined)
3460
- child.y = cfg.top;
3469
+ child.x = cw - w - cfg.right - ox;
3470
+ const centerY = resolveDimension(cfg.centerY, pctRefH);
3471
+ if (centerY !== undefined)
3472
+ child.y = centerY - h / 2 - oy;
3473
+ else if (cfg.top !== undefined)
3474
+ child.y = cfg.top - oy;
3461
3475
  else if (cfg.bottom !== undefined)
3462
- child.y = ch - h - cfg.bottom;
3476
+ child.y = ch - h - cfg.bottom - oy;
3463
3477
  }
3464
3478
  }
3465
3479
  /** Computed content size (after layout) */