@energy8platform/game-engine 0.2.1 → 0.4.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/README.md +400 -35
- package/dist/animation.cjs.js +191 -1
- package/dist/animation.cjs.js.map +1 -1
- package/dist/animation.d.ts +117 -1
- package/dist/animation.esm.js +192 -3
- package/dist/animation.esm.js.map +1 -1
- package/dist/audio.cjs.js +66 -16
- package/dist/audio.cjs.js.map +1 -1
- package/dist/audio.d.ts +4 -0
- package/dist/audio.esm.js +66 -16
- package/dist/audio.esm.js.map +1 -1
- package/dist/core.cjs.js +307 -85
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.d.ts +60 -1
- package/dist/core.esm.js +308 -86
- package/dist/core.esm.js.map +1 -1
- package/dist/debug.cjs.js +36 -68
- package/dist/debug.cjs.js.map +1 -1
- package/dist/debug.d.ts +4 -6
- package/dist/debug.esm.js +36 -68
- package/dist/debug.esm.js.map +1 -1
- package/dist/index.cjs.js +997 -475
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +356 -79
- package/dist/index.esm.js +983 -478
- package/dist/index.esm.js.map +1 -1
- package/dist/ui.cjs.js +816 -529
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.d.ts +179 -41
- package/dist/ui.esm.js +798 -531
- package/dist/ui.esm.js.map +1 -1
- package/dist/vite.cjs.js +85 -68
- package/dist/vite.cjs.js.map +1 -1
- package/dist/vite.d.ts +17 -23
- package/dist/vite.esm.js +86 -68
- package/dist/vite.esm.js.map +1 -1
- package/package.json +19 -5
- package/src/animation/SpriteAnimation.ts +210 -0
- package/src/animation/Tween.ts +27 -1
- package/src/animation/index.ts +2 -0
- package/src/audio/AudioManager.ts +64 -15
- package/src/core/EventEmitter.ts +7 -1
- package/src/core/GameApplication.ts +19 -7
- package/src/core/SceneManager.ts +3 -1
- package/src/debug/DevBridge.ts +49 -80
- package/src/index.ts +22 -0
- package/src/input/InputManager.ts +26 -0
- package/src/loading/CSSPreloader.ts +7 -33
- package/src/loading/LoadingScene.ts +17 -41
- package/src/loading/index.ts +1 -0
- package/src/loading/logo.ts +95 -0
- package/src/types.ts +4 -0
- package/src/ui/BalanceDisplay.ts +12 -1
- package/src/ui/Button.ts +71 -130
- package/src/ui/Layout.ts +286 -0
- package/src/ui/Modal.ts +6 -5
- package/src/ui/Panel.ts +52 -55
- package/src/ui/ProgressBar.ts +52 -57
- package/src/ui/ScrollContainer.ts +126 -0
- package/src/ui/Toast.ts +19 -13
- package/src/ui/index.ts +17 -0
- package/src/viewport/ViewportManager.ts +2 -0
- package/src/vite/index.ts +103 -83
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { Container, ApplicationOptions, Application, Texture, TextStyle } from 'pixi.js';
|
|
1
|
+
import { Container, ApplicationOptions, Application, Texture, AnimatedSprite, Spritesheet, TextStyle, ColorSource } from 'pixi.js';
|
|
2
2
|
import { CasinoGameSDK, InitData, GameConfigData, SessionData, PlayResultData } from '@energy8platform/game-sdk';
|
|
3
3
|
export { GameConfigData, InitData, PlayParams, PlayResultData, SessionData } from '@energy8platform/game-sdk';
|
|
4
|
+
export { LayoutStyles } from '@pixi/layout';
|
|
5
|
+
import { FancyButton, ScrollBox } from '@pixi/ui';
|
|
6
|
+
export { ButtonContainer, FancyButton, ScrollBox } from '@pixi/ui';
|
|
7
|
+
import { LayoutContainer } from '@pixi/layout/components';
|
|
8
|
+
export { LayoutContainer } from '@pixi/layout/components';
|
|
4
9
|
|
|
5
10
|
declare enum ScaleMode {
|
|
6
11
|
/** Fit inside container, maintain aspect ratio (letterbox/pillarbox) */
|
|
@@ -83,6 +88,8 @@ interface GameApplicationConfig {
|
|
|
83
88
|
parentOrigin?: string;
|
|
84
89
|
timeout?: number;
|
|
85
90
|
debug?: boolean;
|
|
91
|
+
/** Use in-memory channel instead of postMessage (no iframe required) */
|
|
92
|
+
devMode?: boolean;
|
|
86
93
|
} | false;
|
|
87
94
|
/** PixiJS Application options (pass-through) */
|
|
88
95
|
pixi?: Partial<ApplicationOptions>;
|
|
@@ -91,6 +98,7 @@ interface GameApplicationConfig {
|
|
|
91
98
|
}
|
|
92
99
|
interface SceneConstructor {
|
|
93
100
|
new (): IScene;
|
|
101
|
+
[key: string]: any;
|
|
94
102
|
}
|
|
95
103
|
interface IScene {
|
|
96
104
|
/** Root display container for this scene */
|
|
@@ -155,13 +163,16 @@ interface TweenOptions {
|
|
|
155
163
|
/**
|
|
156
164
|
* Minimal typed event emitter.
|
|
157
165
|
* Used internally by GameApplication, SceneManager, AudioManager, etc.
|
|
166
|
+
*
|
|
167
|
+
* Supports `void` event types — events that carry no data can be emitted
|
|
168
|
+
* without arguments: `emitter.emit('eventName')`.
|
|
158
169
|
*/
|
|
159
170
|
declare class EventEmitter<TEvents extends {}> {
|
|
160
171
|
private listeners;
|
|
161
172
|
on<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
162
173
|
once<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
163
174
|
off<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
164
|
-
emit<K extends keyof TEvents>(event: K, data: TEvents[K]): void;
|
|
175
|
+
emit<K extends keyof TEvents>(...args: TEvents[K] extends void ? [event: K] : [event: K, data: TEvents[K]]): void;
|
|
165
176
|
removeAllListeners(event?: keyof TEvents): this;
|
|
166
177
|
}
|
|
167
178
|
|
|
@@ -438,6 +449,10 @@ declare class AudioManager {
|
|
|
438
449
|
* Destroy the audio manager and free resources.
|
|
439
450
|
*/
|
|
440
451
|
destroy(): void;
|
|
452
|
+
/**
|
|
453
|
+
* Smoothly fade a sound's volume from `fromVol` to `toVol` over `durationMs`.
|
|
454
|
+
*/
|
|
455
|
+
private fadeVolume;
|
|
441
456
|
private applyVolumes;
|
|
442
457
|
private setupMobileUnlock;
|
|
443
458
|
private removeMobileUnlock;
|
|
@@ -505,6 +520,9 @@ declare class InputManager extends EventEmitter<InputEvents> {
|
|
|
505
520
|
private _locked;
|
|
506
521
|
private _keysDown;
|
|
507
522
|
private _destroyed;
|
|
523
|
+
private _viewportScale;
|
|
524
|
+
private _viewportOffsetX;
|
|
525
|
+
private _viewportOffsetY;
|
|
508
526
|
private _pointerStart;
|
|
509
527
|
private _swipeThreshold;
|
|
510
528
|
private _swipeMaxTime;
|
|
@@ -517,6 +535,19 @@ declare class InputManager extends EventEmitter<InputEvents> {
|
|
|
517
535
|
unlock(): void;
|
|
518
536
|
/** Check if a key is currently pressed */
|
|
519
537
|
isKeyDown(key: string): boolean;
|
|
538
|
+
/**
|
|
539
|
+
* Update the viewport transform used for DOM→world coordinate mapping.
|
|
540
|
+
* Called automatically by GameApplication when ViewportManager emits resize.
|
|
541
|
+
*/
|
|
542
|
+
setViewportTransform(scale: number, offsetX: number, offsetY: number): void;
|
|
543
|
+
/**
|
|
544
|
+
* Convert a DOM canvas position to game-world coordinates,
|
|
545
|
+
* accounting for viewport scaling and offset.
|
|
546
|
+
*/
|
|
547
|
+
getWorldPosition(canvasX: number, canvasY: number): {
|
|
548
|
+
x: number;
|
|
549
|
+
y: number;
|
|
550
|
+
};
|
|
520
551
|
/** Destroy the input manager */
|
|
521
552
|
destroy(): void;
|
|
522
553
|
private setupPointerEvents;
|
|
@@ -607,6 +638,37 @@ declare class ViewportManager extends EventEmitter<ViewportEvents> {
|
|
|
607
638
|
private debouncedRefresh;
|
|
608
639
|
}
|
|
609
640
|
|
|
641
|
+
/**
|
|
642
|
+
* FPS overlay for debugging performance.
|
|
643
|
+
*
|
|
644
|
+
* Shows FPS, frame time, and draw call count in the corner of the screen.
|
|
645
|
+
*
|
|
646
|
+
* @example
|
|
647
|
+
* ```ts
|
|
648
|
+
* const fps = new FPSOverlay(app);
|
|
649
|
+
* fps.show();
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
652
|
+
declare class FPSOverlay {
|
|
653
|
+
private _app;
|
|
654
|
+
private _container;
|
|
655
|
+
private _fpsText;
|
|
656
|
+
private _visible;
|
|
657
|
+
private _samples;
|
|
658
|
+
private _maxSamples;
|
|
659
|
+
private _lastUpdate;
|
|
660
|
+
private _tickFn;
|
|
661
|
+
constructor(app: Application);
|
|
662
|
+
/** Show the FPS overlay */
|
|
663
|
+
show(): void;
|
|
664
|
+
/** Hide the FPS overlay */
|
|
665
|
+
hide(): void;
|
|
666
|
+
/** Toggle visibility */
|
|
667
|
+
toggle(): void;
|
|
668
|
+
/** Destroy the overlay */
|
|
669
|
+
destroy(): void;
|
|
670
|
+
}
|
|
671
|
+
|
|
610
672
|
/**
|
|
611
673
|
* The main entry point for a game built on @energy8platform/game-engine.
|
|
612
674
|
*
|
|
@@ -653,6 +715,8 @@ declare class GameApplication extends EventEmitter<GameEngineEvents> {
|
|
|
653
715
|
viewport: ViewportManager;
|
|
654
716
|
/** SDK instance (null in offline mode) */
|
|
655
717
|
sdk: CasinoGameSDK | null;
|
|
718
|
+
/** FPS overlay instance (only when debug: true) */
|
|
719
|
+
fpsOverlay: FPSOverlay | null;
|
|
656
720
|
/** Data received from SDK initialization */
|
|
657
721
|
initData: InitData | null;
|
|
658
722
|
/** Configuration */
|
|
@@ -887,6 +951,7 @@ declare class Tween {
|
|
|
887
951
|
static fromTo(target: any, fromProps: Record<string, number>, toProps: Record<string, number>, duration: number, easing?: EasingFunction, onUpdate?: (progress: number) => void): Promise<void>;
|
|
888
952
|
/**
|
|
889
953
|
* Wait for a given duration (useful in timelines).
|
|
954
|
+
* Uses PixiJS Ticker for consistent timing with other tweens.
|
|
890
955
|
*/
|
|
891
956
|
static delay(ms: number): Promise<void>;
|
|
892
957
|
/**
|
|
@@ -899,6 +964,11 @@ declare class Tween {
|
|
|
899
964
|
static killAll(): void;
|
|
900
965
|
/** Number of active tweens */
|
|
901
966
|
static get activeTweens(): number;
|
|
967
|
+
/**
|
|
968
|
+
* Reset the tween system — kill all tweens and remove the ticker.
|
|
969
|
+
* Useful for cleanup between game instances, tests, or hot-reload.
|
|
970
|
+
*/
|
|
971
|
+
static reset(): void;
|
|
902
972
|
private static ensureTicker;
|
|
903
973
|
private static tick;
|
|
904
974
|
/**
|
|
@@ -1078,7 +1148,114 @@ declare class SpineHelper {
|
|
|
1078
1148
|
static setSkin(spine: any, skinName: string): void;
|
|
1079
1149
|
}
|
|
1080
1150
|
|
|
1081
|
-
|
|
1151
|
+
interface SpriteAnimationConfig {
|
|
1152
|
+
/** Frames per second (default: 24) */
|
|
1153
|
+
fps?: number;
|
|
1154
|
+
/** Whether to loop (default: true) */
|
|
1155
|
+
loop?: boolean;
|
|
1156
|
+
/** Start playing immediately (default: true) */
|
|
1157
|
+
autoPlay?: boolean;
|
|
1158
|
+
/** Callback when animation completes (non-looping) */
|
|
1159
|
+
onComplete?: () => void;
|
|
1160
|
+
/** Anchor point (default: 0.5 = center) */
|
|
1161
|
+
anchor?: number | {
|
|
1162
|
+
x: number;
|
|
1163
|
+
y: number;
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Helper for creating frame-based animations from spritesheets.
|
|
1168
|
+
*
|
|
1169
|
+
* Wraps PixiJS `AnimatedSprite` with a convenient API for
|
|
1170
|
+
* common iGaming effects: coin showers, symbol animations,
|
|
1171
|
+
* sparkle trails, win celebrations.
|
|
1172
|
+
*
|
|
1173
|
+
* Cheaper than Spine for simple frame sequences.
|
|
1174
|
+
*
|
|
1175
|
+
* @example
|
|
1176
|
+
* ```ts
|
|
1177
|
+
* // From an array of textures
|
|
1178
|
+
* const coinAnim = SpriteAnimation.create(coinTextures, {
|
|
1179
|
+
* fps: 30,
|
|
1180
|
+
* loop: true,
|
|
1181
|
+
* });
|
|
1182
|
+
* scene.addChild(coinAnim);
|
|
1183
|
+
*
|
|
1184
|
+
* // From a spritesheet with a naming pattern
|
|
1185
|
+
* const sheet = Assets.get('effects');
|
|
1186
|
+
* const sparkle = SpriteAnimation.fromSpritesheet(sheet, 'sparkle_');
|
|
1187
|
+
* sparkle.play();
|
|
1188
|
+
*
|
|
1189
|
+
* // From a numbered range
|
|
1190
|
+
* const explosion = SpriteAnimation.fromRange(sheet, 'explosion_{i}', 0, 24, {
|
|
1191
|
+
* fps: 60,
|
|
1192
|
+
* loop: false,
|
|
1193
|
+
* onComplete: () => explosion.destroy(),
|
|
1194
|
+
* });
|
|
1195
|
+
* ```
|
|
1196
|
+
*/
|
|
1197
|
+
declare class SpriteAnimation {
|
|
1198
|
+
/**
|
|
1199
|
+
* Create an animated sprite from an array of textures.
|
|
1200
|
+
*
|
|
1201
|
+
* @param textures - Array of PixiJS Textures
|
|
1202
|
+
* @param config - Animation options
|
|
1203
|
+
* @returns Configured AnimatedSprite
|
|
1204
|
+
*/
|
|
1205
|
+
static create(textures: Texture[], config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1206
|
+
/**
|
|
1207
|
+
* Create an animated sprite from a spritesheet using a name prefix.
|
|
1208
|
+
*
|
|
1209
|
+
* Collects all textures whose keys start with `prefix`, sorted alphabetically.
|
|
1210
|
+
*
|
|
1211
|
+
* @param sheet - PixiJS Spritesheet instance
|
|
1212
|
+
* @param prefix - Texture name prefix (e.g., 'coin_')
|
|
1213
|
+
* @param config - Animation options
|
|
1214
|
+
* @returns Configured AnimatedSprite
|
|
1215
|
+
*/
|
|
1216
|
+
static fromSpritesheet(sheet: Spritesheet, prefix: string, config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1217
|
+
/**
|
|
1218
|
+
* Create an animated sprite from a numbered range of frames.
|
|
1219
|
+
*
|
|
1220
|
+
* The `pattern` string should contain `{i}` as a placeholder for the frame number.
|
|
1221
|
+
* Numbers are zero-padded to match the length of `start`.
|
|
1222
|
+
*
|
|
1223
|
+
* @param sheet - PixiJS Spritesheet instance
|
|
1224
|
+
* @param pattern - Frame name pattern, e.g. 'explosion_{i}'
|
|
1225
|
+
* @param start - Start frame index (inclusive)
|
|
1226
|
+
* @param end - End frame index (inclusive)
|
|
1227
|
+
* @param config - Animation options
|
|
1228
|
+
* @returns Configured AnimatedSprite
|
|
1229
|
+
*/
|
|
1230
|
+
static fromRange(sheet: Spritesheet, pattern: string, start: number, end: number, config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1231
|
+
/**
|
|
1232
|
+
* Create an AnimatedSprite from texture aliases (loaded via AssetManager).
|
|
1233
|
+
*
|
|
1234
|
+
* @param aliases - Array of texture aliases
|
|
1235
|
+
* @param config - Animation options
|
|
1236
|
+
* @returns Configured AnimatedSprite
|
|
1237
|
+
*/
|
|
1238
|
+
static fromAliases(aliases: string[], config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1239
|
+
/**
|
|
1240
|
+
* Play a one-shot animation and auto-destroy when complete.
|
|
1241
|
+
* Useful for fire-and-forget effects like coin bursts.
|
|
1242
|
+
*
|
|
1243
|
+
* @param textures - Array of textures
|
|
1244
|
+
* @param config - Animation options (loop will be forced to false)
|
|
1245
|
+
* @returns Promise that resolves when animation completes
|
|
1246
|
+
*/
|
|
1247
|
+
static playOnce(textures: Texture[], config?: SpriteAnimationConfig): {
|
|
1248
|
+
sprite: AnimatedSprite;
|
|
1249
|
+
finished: Promise<void>;
|
|
1250
|
+
};
|
|
1251
|
+
/**
|
|
1252
|
+
* Get all textures from a spritesheet that start with a given prefix.
|
|
1253
|
+
* Results are sorted alphabetically by key.
|
|
1254
|
+
*/
|
|
1255
|
+
static getTexturesByPrefix(sheet: Spritesheet, prefix: string): Texture[];
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
type ButtonState = 'default' | 'hover' | 'pressed' | 'disabled';
|
|
1082
1259
|
interface ButtonConfig {
|
|
1083
1260
|
/** Default texture/sprite for each state (optional — uses Graphics if not provided) */
|
|
1084
1261
|
textures?: Partial<Record<ButtonState, string | Texture>>;
|
|
@@ -1096,48 +1273,38 @@ interface ButtonConfig {
|
|
|
1096
1273
|
animationDuration?: number;
|
|
1097
1274
|
/** Start disabled */
|
|
1098
1275
|
disabled?: boolean;
|
|
1276
|
+
/** Button text */
|
|
1277
|
+
text?: string;
|
|
1278
|
+
/** Button text style */
|
|
1279
|
+
textStyle?: Record<string, unknown>;
|
|
1099
1280
|
}
|
|
1100
1281
|
/**
|
|
1101
|
-
* Interactive button component
|
|
1282
|
+
* Interactive button component powered by `@pixi/ui` FancyButton.
|
|
1102
1283
|
*
|
|
1103
|
-
* Supports both texture-based and Graphics-based rendering
|
|
1284
|
+
* Supports both texture-based and Graphics-based rendering with
|
|
1285
|
+
* per-state views, press animation, and text.
|
|
1104
1286
|
*
|
|
1105
1287
|
* @example
|
|
1106
1288
|
* ```ts
|
|
1107
1289
|
* const btn = new Button({
|
|
1108
1290
|
* width: 200, height: 60, borderRadius: 12,
|
|
1109
|
-
* colors: {
|
|
1291
|
+
* colors: { default: 0x22aa22, hover: 0x33cc33 },
|
|
1292
|
+
* text: 'SPIN',
|
|
1110
1293
|
* });
|
|
1111
1294
|
*
|
|
1112
|
-
* btn.
|
|
1295
|
+
* btn.onPress.connect(() => console.log('Clicked!'));
|
|
1113
1296
|
* scene.container.addChild(btn);
|
|
1114
1297
|
* ```
|
|
1115
1298
|
*/
|
|
1116
|
-
declare class Button extends
|
|
1117
|
-
private
|
|
1118
|
-
private _bg;
|
|
1119
|
-
private _sprites;
|
|
1120
|
-
private _config;
|
|
1121
|
-
/** Called when the button is tapped/clicked */
|
|
1122
|
-
onTap?: () => void;
|
|
1123
|
-
/** Called when the button state changes */
|
|
1124
|
-
onStateChange?: (state: ButtonState) => void;
|
|
1299
|
+
declare class Button extends FancyButton {
|
|
1300
|
+
private _buttonConfig;
|
|
1125
1301
|
constructor(config?: ButtonConfig);
|
|
1126
|
-
/** Current button state */
|
|
1127
|
-
get state(): ButtonState;
|
|
1128
1302
|
/** Enable the button */
|
|
1129
1303
|
enable(): void;
|
|
1130
1304
|
/** Disable the button */
|
|
1131
1305
|
disable(): void;
|
|
1132
1306
|
/** Whether the button is disabled */
|
|
1133
1307
|
get disabled(): boolean;
|
|
1134
|
-
private setState;
|
|
1135
|
-
private render;
|
|
1136
|
-
private onPointerOver;
|
|
1137
|
-
private onPointerOut;
|
|
1138
|
-
private onPointerDown;
|
|
1139
|
-
private onPointerUp;
|
|
1140
|
-
private onPointerTap;
|
|
1141
1308
|
}
|
|
1142
1309
|
|
|
1143
1310
|
interface ProgressBarConfig {
|
|
@@ -1154,7 +1321,9 @@ interface ProgressBarConfig {
|
|
|
1154
1321
|
animationSpeed?: number;
|
|
1155
1322
|
}
|
|
1156
1323
|
/**
|
|
1157
|
-
* Horizontal progress bar
|
|
1324
|
+
* Horizontal progress bar powered by `@pixi/ui` ProgressBar.
|
|
1325
|
+
*
|
|
1326
|
+
* Provides optional smooth animated fill via per-frame `update()`.
|
|
1158
1327
|
*
|
|
1159
1328
|
* @example
|
|
1160
1329
|
* ```ts
|
|
@@ -1164,9 +1333,8 @@ interface ProgressBarConfig {
|
|
|
1164
1333
|
* ```
|
|
1165
1334
|
*/
|
|
1166
1335
|
declare class ProgressBar extends Container {
|
|
1167
|
-
private
|
|
1168
|
-
private
|
|
1169
|
-
private _border;
|
|
1336
|
+
private _bar;
|
|
1337
|
+
private _borderGfx;
|
|
1170
1338
|
private _config;
|
|
1171
1339
|
private _progress;
|
|
1172
1340
|
private _displayedProgress;
|
|
@@ -1177,10 +1345,7 @@ declare class ProgressBar extends Container {
|
|
|
1177
1345
|
/**
|
|
1178
1346
|
* Call each frame if animated is true.
|
|
1179
1347
|
*/
|
|
1180
|
-
update(
|
|
1181
|
-
private drawTrack;
|
|
1182
|
-
private drawBorder;
|
|
1183
|
-
private drawFill;
|
|
1348
|
+
update(_dt: number): void;
|
|
1184
1349
|
}
|
|
1185
1350
|
|
|
1186
1351
|
interface LabelConfig {
|
|
@@ -1254,7 +1419,10 @@ interface PanelConfig {
|
|
|
1254
1419
|
padding?: number;
|
|
1255
1420
|
}
|
|
1256
1421
|
/**
|
|
1257
|
-
* Background panel
|
|
1422
|
+
* Background panel powered by `@pixi/layout` LayoutContainer.
|
|
1423
|
+
*
|
|
1424
|
+
* Supports both Graphics-based (color + border) and 9-slice sprite backgrounds.
|
|
1425
|
+
* Children added to `content` participate in flexbox layout automatically.
|
|
1258
1426
|
*
|
|
1259
1427
|
* @example
|
|
1260
1428
|
* ```ts
|
|
@@ -1269,16 +1437,13 @@ interface PanelConfig {
|
|
|
1269
1437
|
* });
|
|
1270
1438
|
* ```
|
|
1271
1439
|
*/
|
|
1272
|
-
declare class Panel extends
|
|
1273
|
-
private
|
|
1274
|
-
private _content;
|
|
1275
|
-
private _config;
|
|
1440
|
+
declare class Panel extends LayoutContainer {
|
|
1441
|
+
private _panelConfig;
|
|
1276
1442
|
constructor(config?: PanelConfig);
|
|
1277
|
-
/**
|
|
1443
|
+
/** Access the content container (children added here participate in layout) */
|
|
1278
1444
|
get content(): Container;
|
|
1279
1445
|
/** Resize the panel */
|
|
1280
1446
|
setSize(width: number, height: number): void;
|
|
1281
|
-
private drawGraphicsBg;
|
|
1282
1447
|
}
|
|
1283
1448
|
|
|
1284
1449
|
interface BalanceDisplayConfig {
|
|
@@ -1319,6 +1484,7 @@ declare class BalanceDisplay extends Container {
|
|
|
1319
1484
|
private _currentValue;
|
|
1320
1485
|
private _displayedValue;
|
|
1321
1486
|
private _animating;
|
|
1487
|
+
private _animationCancelled;
|
|
1322
1488
|
constructor(config?: BalanceDisplayConfig);
|
|
1323
1489
|
/** Current displayed value */
|
|
1324
1490
|
get value(): number;
|
|
@@ -1398,6 +1564,8 @@ interface ModalConfig {
|
|
|
1398
1564
|
* Modal overlay component.
|
|
1399
1565
|
* Shows content on top of a dark overlay with enter/exit animations.
|
|
1400
1566
|
*
|
|
1567
|
+
* The content container uses `@pixi/layout` for automatic centering.
|
|
1568
|
+
*
|
|
1401
1569
|
* @example
|
|
1402
1570
|
* ```ts
|
|
1403
1571
|
* const modal = new Modal({ closeOnOverlay: true });
|
|
@@ -1438,6 +1606,8 @@ interface ToastConfig {
|
|
|
1438
1606
|
/**
|
|
1439
1607
|
* Toast notification component for displaying transient messages.
|
|
1440
1608
|
*
|
|
1609
|
+
* Uses `@pixi/layout` LayoutContainer for auto-sized background.
|
|
1610
|
+
*
|
|
1441
1611
|
* @example
|
|
1442
1612
|
* ```ts
|
|
1443
1613
|
* const toast = new Toast();
|
|
@@ -1461,6 +1631,146 @@ declare class Toast extends Container {
|
|
|
1461
1631
|
dismiss(): Promise<void>;
|
|
1462
1632
|
}
|
|
1463
1633
|
|
|
1634
|
+
type LayoutDirection = 'horizontal' | 'vertical' | 'grid' | 'wrap';
|
|
1635
|
+
type LayoutAlignment = 'start' | 'center' | 'end' | 'stretch';
|
|
1636
|
+
type LayoutAnchor = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
1637
|
+
interface LayoutConfig {
|
|
1638
|
+
/** Layout direction (default: 'vertical') */
|
|
1639
|
+
direction?: LayoutDirection;
|
|
1640
|
+
/** Gap between children in pixels (default: 0) */
|
|
1641
|
+
gap?: number;
|
|
1642
|
+
/** Padding inside the layout container [top, right, bottom, left] or a single number */
|
|
1643
|
+
padding?: number | [number, number, number, number];
|
|
1644
|
+
/** Alignment of children on the cross axis (default: 'start') */
|
|
1645
|
+
alignment?: LayoutAlignment;
|
|
1646
|
+
/** Anchor point determining where the layout is positioned relative to its coordinates */
|
|
1647
|
+
anchor?: LayoutAnchor;
|
|
1648
|
+
/** Number of columns (only for 'grid' direction) */
|
|
1649
|
+
columns?: number;
|
|
1650
|
+
/** Maximum width for 'wrap' direction before wrapping to next line */
|
|
1651
|
+
maxWidth?: number;
|
|
1652
|
+
/** Whether to auto-layout when children change (default: true) */
|
|
1653
|
+
autoLayout?: boolean;
|
|
1654
|
+
/** Breakpoints: map of max viewport widths to override configs */
|
|
1655
|
+
breakpoints?: Record<number, Partial<LayoutConfig>>;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Responsive layout container powered by `@pixi/layout` (Yoga flexbox engine).
|
|
1659
|
+
*
|
|
1660
|
+
* Supports horizontal, vertical, grid, and wrap layout modes with
|
|
1661
|
+
* alignment, padding, gap, and viewport-anchor positioning.
|
|
1662
|
+
* Breakpoints allow different layouts for different screen sizes.
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```ts
|
|
1666
|
+
* const toolbar = new Layout({
|
|
1667
|
+
* direction: 'horizontal',
|
|
1668
|
+
* gap: 20,
|
|
1669
|
+
* alignment: 'center',
|
|
1670
|
+
* anchor: 'bottom-center',
|
|
1671
|
+
* padding: 16,
|
|
1672
|
+
* breakpoints: {
|
|
1673
|
+
* 768: { direction: 'vertical', gap: 10 },
|
|
1674
|
+
* },
|
|
1675
|
+
* });
|
|
1676
|
+
*
|
|
1677
|
+
* toolbar.addItem(spinButton);
|
|
1678
|
+
* toolbar.addItem(betLabel);
|
|
1679
|
+
* scene.container.addChild(toolbar);
|
|
1680
|
+
*
|
|
1681
|
+
* toolbar.updateViewport(width, height);
|
|
1682
|
+
* ```
|
|
1683
|
+
*/
|
|
1684
|
+
declare class Layout extends Container {
|
|
1685
|
+
private _layoutConfig;
|
|
1686
|
+
private _padding;
|
|
1687
|
+
private _anchor;
|
|
1688
|
+
private _maxWidth;
|
|
1689
|
+
private _breakpoints;
|
|
1690
|
+
private _items;
|
|
1691
|
+
private _viewportWidth;
|
|
1692
|
+
private _viewportHeight;
|
|
1693
|
+
constructor(config?: LayoutConfig);
|
|
1694
|
+
/** Add an item to the layout */
|
|
1695
|
+
addItem(child: Container): this;
|
|
1696
|
+
/** Remove an item from the layout */
|
|
1697
|
+
removeItem(child: Container): this;
|
|
1698
|
+
/** Remove all items */
|
|
1699
|
+
clearItems(): this;
|
|
1700
|
+
/** Get all layout items */
|
|
1701
|
+
get items(): readonly Container[];
|
|
1702
|
+
/**
|
|
1703
|
+
* Update the viewport size and recalculate layout.
|
|
1704
|
+
* Should be called from `Scene.onResize()`.
|
|
1705
|
+
*/
|
|
1706
|
+
updateViewport(width: number, height: number): void;
|
|
1707
|
+
private applyLayoutStyles;
|
|
1708
|
+
private applyGridChildWidth;
|
|
1709
|
+
private applyAnchor;
|
|
1710
|
+
private resolveConfig;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
1714
|
+
interface ScrollContainerConfig {
|
|
1715
|
+
/** Visible viewport width */
|
|
1716
|
+
width: number;
|
|
1717
|
+
/** Visible viewport height */
|
|
1718
|
+
height: number;
|
|
1719
|
+
/** Scroll direction (default: 'vertical') */
|
|
1720
|
+
direction?: ScrollDirection;
|
|
1721
|
+
/** Background color (undefined = transparent) */
|
|
1722
|
+
backgroundColor?: ColorSource;
|
|
1723
|
+
/** Border radius for the mask (default: 0) */
|
|
1724
|
+
borderRadius?: number;
|
|
1725
|
+
/** Gap between items (default: 0) */
|
|
1726
|
+
elementsMargin?: number;
|
|
1727
|
+
/** Padding */
|
|
1728
|
+
padding?: number;
|
|
1729
|
+
/** Disable dynamic rendering (render all items even when offscreen) */
|
|
1730
|
+
disableDynamicRendering?: boolean;
|
|
1731
|
+
/** Disable easing/inertia */
|
|
1732
|
+
disableEasing?: boolean;
|
|
1733
|
+
/** Global scroll — scroll even when mouse is not over the component */
|
|
1734
|
+
globalScroll?: boolean;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Scrollable container powered by `@pixi/ui` ScrollBox.
|
|
1738
|
+
*
|
|
1739
|
+
* Provides touch/drag scrolling, mouse wheel support, inertia, and
|
|
1740
|
+
* dynamic rendering optimization for off-screen items.
|
|
1741
|
+
*
|
|
1742
|
+
* @example
|
|
1743
|
+
* ```ts
|
|
1744
|
+
* const scroll = new ScrollContainer({
|
|
1745
|
+
* width: 600,
|
|
1746
|
+
* height: 400,
|
|
1747
|
+
* direction: 'vertical',
|
|
1748
|
+
* elementsMargin: 8,
|
|
1749
|
+
* });
|
|
1750
|
+
*
|
|
1751
|
+
* for (let i = 0; i < 50; i++) {
|
|
1752
|
+
* scroll.addItem(createRow(i));
|
|
1753
|
+
* }
|
|
1754
|
+
*
|
|
1755
|
+
* scene.container.addChild(scroll);
|
|
1756
|
+
* ```
|
|
1757
|
+
*/
|
|
1758
|
+
declare class ScrollContainer extends ScrollBox {
|
|
1759
|
+
private _scrollConfig;
|
|
1760
|
+
constructor(config: ScrollContainerConfig);
|
|
1761
|
+
/** Set scrollable content. Replaces any existing content. */
|
|
1762
|
+
setContent(content: Container): void;
|
|
1763
|
+
/** Add a single item */
|
|
1764
|
+
addItem(...items: Container[]): Container;
|
|
1765
|
+
/** Scroll to make a specific item/child visible */
|
|
1766
|
+
scrollToItem(index: number): void;
|
|
1767
|
+
/** Current scroll position */
|
|
1768
|
+
get scrollPosition(): {
|
|
1769
|
+
x: number;
|
|
1770
|
+
y: number;
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1464
1774
|
/**
|
|
1465
1775
|
* Built-in loading screen using the Energy8 SVG logo with animated loader bar.
|
|
1466
1776
|
*
|
|
@@ -1521,8 +1831,9 @@ interface DevBridgeConfig {
|
|
|
1521
1831
|
/**
|
|
1522
1832
|
* Mock host bridge for local development.
|
|
1523
1833
|
*
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1834
|
+
* Uses the SDK's `Bridge` class in `devMode` to communicate with
|
|
1835
|
+
* `CasinoGameSDK` via a shared in-memory `MemoryChannel`, removing
|
|
1836
|
+
* the need for postMessage and iframes.
|
|
1526
1837
|
*
|
|
1527
1838
|
* This allows games to be developed and tested without a real backend.
|
|
1528
1839
|
*
|
|
@@ -1550,8 +1861,7 @@ declare class DevBridge {
|
|
|
1550
1861
|
private _config;
|
|
1551
1862
|
private _balance;
|
|
1552
1863
|
private _roundCounter;
|
|
1553
|
-
private
|
|
1554
|
-
private _handler;
|
|
1864
|
+
private _bridge;
|
|
1555
1865
|
constructor(config?: DevBridgeConfig);
|
|
1556
1866
|
/** Current mock balance */
|
|
1557
1867
|
get balance(): number;
|
|
@@ -1563,7 +1873,6 @@ declare class DevBridge {
|
|
|
1563
1873
|
setBalance(balance: number): void;
|
|
1564
1874
|
/** Destroy the dev bridge */
|
|
1565
1875
|
destroy(): void;
|
|
1566
|
-
private handleMessage;
|
|
1567
1876
|
private handleGameReady;
|
|
1568
1877
|
private handlePlayRequest;
|
|
1569
1878
|
private handlePlayAck;
|
|
@@ -1571,39 +1880,7 @@ declare class DevBridge {
|
|
|
1571
1880
|
private handleGetState;
|
|
1572
1881
|
private handleOpenDeposit;
|
|
1573
1882
|
private delayedSend;
|
|
1574
|
-
private sendMessage;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
/**
|
|
1578
|
-
* FPS overlay for debugging performance.
|
|
1579
|
-
*
|
|
1580
|
-
* Shows FPS, frame time, and draw call count in the corner of the screen.
|
|
1581
|
-
*
|
|
1582
|
-
* @example
|
|
1583
|
-
* ```ts
|
|
1584
|
-
* const fps = new FPSOverlay(app);
|
|
1585
|
-
* fps.show();
|
|
1586
|
-
* ```
|
|
1587
|
-
*/
|
|
1588
|
-
declare class FPSOverlay {
|
|
1589
|
-
private _app;
|
|
1590
|
-
private _container;
|
|
1591
|
-
private _fpsText;
|
|
1592
|
-
private _visible;
|
|
1593
|
-
private _samples;
|
|
1594
|
-
private _maxSamples;
|
|
1595
|
-
private _lastUpdate;
|
|
1596
|
-
private _tickFn;
|
|
1597
|
-
constructor(app: Application);
|
|
1598
|
-
/** Show the FPS overlay */
|
|
1599
|
-
show(): void;
|
|
1600
|
-
/** Hide the FPS overlay */
|
|
1601
|
-
hide(): void;
|
|
1602
|
-
/** Toggle visibility */
|
|
1603
|
-
toggle(): void;
|
|
1604
|
-
/** Destroy the overlay */
|
|
1605
|
-
destroy(): void;
|
|
1606
1883
|
}
|
|
1607
1884
|
|
|
1608
|
-
export { AssetManager, AudioManager, BalanceDisplay, Button, DevBridge, Easing, EventEmitter, FPSOverlay, GameApplication, InputManager, Label, LoadingScene, Modal, Orientation, Panel, ProgressBar, ScaleMode, Scene, SceneManager, SpineHelper, StateMachine, Timeline, Toast, TransitionType, Tween, ViewportManager, WinDisplay };
|
|
1609
|
-
export type { AssetBundle, AssetEntry, AssetManifest, AudioConfig, DevBridgeConfig, EasingFunction, GameApplicationConfig, GameEngineEvents, IScene, LoadingScreenConfig, SceneConstructor, TransitionConfig, TweenOptions };
|
|
1885
|
+
export { AssetManager, AudioManager, BalanceDisplay, Button, DevBridge, Easing, EventEmitter, FPSOverlay, GameApplication, InputManager, Label, Layout, LoadingScene, Modal, Orientation, Panel, ProgressBar, ScaleMode, Scene, SceneManager, ScrollContainer, SpineHelper, SpriteAnimation, StateMachine, Timeline, Toast, TransitionType, Tween, ViewportManager, WinDisplay };
|
|
1886
|
+
export type { AssetBundle, AssetEntry, AssetManifest, AudioConfig, BalanceDisplayConfig, ButtonConfig, ButtonState, DevBridgeConfig, EasingFunction, GameApplicationConfig, GameEngineEvents, IScene, LabelConfig, LayoutAlignment, LayoutAnchor, LayoutConfig, LayoutDirection, LoadingScreenConfig, ModalConfig, PanelConfig, ProgressBarConfig, SceneConstructor, ScrollContainerConfig, ScrollDirection, SpriteAnimationConfig, ToastConfig, ToastType, TransitionConfig, TweenOptions, WinDisplayConfig };
|