@duyquangnvx/pixi-game-engine 0.1.1 → 0.1.2
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.cjs +28 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2374,6 +2374,14 @@ var Engine = class _Engine {
|
|
|
2374
2374
|
static onResize = new Signal();
|
|
2375
2375
|
/** Signal emitted when engine is updated */
|
|
2376
2376
|
static onUpdate = new Signal();
|
|
2377
|
+
/** Signal emitted at the end of init() after all managers are constructed */
|
|
2378
|
+
static onReady = new Signal();
|
|
2379
|
+
/** Signal emitted at the start of destroy() before any teardown */
|
|
2380
|
+
static onDestroy = new Signal();
|
|
2381
|
+
/** Signal emitted when browser tab visibility changes (true = visible, false = hidden) */
|
|
2382
|
+
static onVisibilityChange = new Signal();
|
|
2383
|
+
/** Signal emitted when browser window gains/loses focus (true = focused, false = blurred) */
|
|
2384
|
+
static onFocusChange = new Signal();
|
|
2377
2385
|
/** Design resolution width (original config width) */
|
|
2378
2386
|
static _designWidth;
|
|
2379
2387
|
/** Design resolution height (original config height) */
|
|
@@ -2384,6 +2392,9 @@ var Engine = class _Engine {
|
|
|
2384
2392
|
static _scale = 1;
|
|
2385
2393
|
static _isRunning = false;
|
|
2386
2394
|
static _resizeHandler;
|
|
2395
|
+
static _visibilityHandler;
|
|
2396
|
+
static _focusHandler;
|
|
2397
|
+
static _blurHandler;
|
|
2387
2398
|
static _initialized = false;
|
|
2388
2399
|
/** Logger instance for consistent logging across the engine */
|
|
2389
2400
|
static logger = Logger;
|
|
@@ -2494,6 +2505,15 @@ var Engine = class _Engine {
|
|
|
2494
2505
|
}
|
|
2495
2506
|
_Engine._app.ticker.add(_Engine.update);
|
|
2496
2507
|
_Engine._isRunning = true;
|
|
2508
|
+
_Engine._visibilityHandler = () => {
|
|
2509
|
+
_Engine.onVisibilityChange.emit(!document.hidden);
|
|
2510
|
+
};
|
|
2511
|
+
_Engine._focusHandler = () => _Engine.onFocusChange.emit(true);
|
|
2512
|
+
_Engine._blurHandler = () => _Engine.onFocusChange.emit(false);
|
|
2513
|
+
document.addEventListener("visibilitychange", _Engine._visibilityHandler);
|
|
2514
|
+
window.addEventListener("focus", _Engine._focusHandler);
|
|
2515
|
+
window.addEventListener("blur", _Engine._blurHandler);
|
|
2516
|
+
_Engine.onReady.emit();
|
|
2497
2517
|
}
|
|
2498
2518
|
static update(delta) {
|
|
2499
2519
|
_Engine.onUpdate.emit(delta);
|
|
@@ -2569,6 +2589,10 @@ var Engine = class _Engine {
|
|
|
2569
2589
|
}
|
|
2570
2590
|
static destroy() {
|
|
2571
2591
|
if (!_Engine._initialized) return;
|
|
2592
|
+
_Engine.onDestroy.emit();
|
|
2593
|
+
document.removeEventListener("visibilitychange", _Engine._visibilityHandler);
|
|
2594
|
+
window.removeEventListener("focus", _Engine._focusHandler);
|
|
2595
|
+
window.removeEventListener("blur", _Engine._blurHandler);
|
|
2572
2596
|
window.removeEventListener("resize", _Engine._resizeHandler);
|
|
2573
2597
|
_Engine._app.ticker.remove(_Engine.update);
|
|
2574
2598
|
_Engine._input.destroy();
|
|
@@ -2582,6 +2606,10 @@ var Engine = class _Engine {
|
|
|
2582
2606
|
_Engine.onPause.clear();
|
|
2583
2607
|
_Engine.onResume.clear();
|
|
2584
2608
|
_Engine.onResize.clear();
|
|
2609
|
+
_Engine.onReady.clear();
|
|
2610
|
+
_Engine.onDestroy.clear();
|
|
2611
|
+
_Engine.onVisibilityChange.clear();
|
|
2612
|
+
_Engine.onFocusChange.clear();
|
|
2585
2613
|
_Engine._app.destroy(true, { children: true, texture: true });
|
|
2586
2614
|
_Engine._isRunning = false;
|
|
2587
2615
|
_Engine._initialized = false;
|