@energy8platform/game-engine 0.2.1 → 0.3.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 +298 -28
- 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 +306 -85
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.d.ts +60 -1
- package/dist/core.esm.js +307 -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 +1247 -253
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +386 -41
- package/dist/index.esm.js +1247 -256
- package/dist/index.esm.js.map +1 -1
- package/dist/ui.cjs.js +757 -1
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.d.ts +208 -2
- package/dist/ui.esm.js +756 -2
- package/dist/ui.esm.js.map +1 -1
- package/dist/vite.cjs.js +65 -68
- package/dist/vite.cjs.js.map +1 -1
- package/dist/vite.d.ts +17 -23
- package/dist/vite.esm.js +66 -68
- package/dist/vite.esm.js.map +1 -1
- package/package.json +4 -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 +18 -7
- package/src/core/SceneManager.ts +3 -1
- package/src/debug/DevBridge.ts +49 -80
- package/src/index.ts +6 -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 +14 -0
- package/src/ui/Button.ts +1 -1
- package/src/ui/Layout.ts +364 -0
- package/src/ui/ScrollContainer.ts +557 -0
- package/src/ui/index.ts +4 -0
- package/src/viewport/ViewportManager.ts +2 -0
- package/src/vite/index.ts +83 -83
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Container, ApplicationOptions, Application, Texture, TextStyle } from 'pixi.js';
|
|
1
|
+
import { Container, ApplicationOptions, Application, Texture, AnimatedSprite, Spritesheet, TextStyle } 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
4
|
|
|
@@ -83,6 +83,8 @@ interface GameApplicationConfig {
|
|
|
83
83
|
parentOrigin?: string;
|
|
84
84
|
timeout?: number;
|
|
85
85
|
debug?: boolean;
|
|
86
|
+
/** Use in-memory channel instead of postMessage (no iframe required) */
|
|
87
|
+
devMode?: boolean;
|
|
86
88
|
} | false;
|
|
87
89
|
/** PixiJS Application options (pass-through) */
|
|
88
90
|
pixi?: Partial<ApplicationOptions>;
|
|
@@ -91,6 +93,7 @@ interface GameApplicationConfig {
|
|
|
91
93
|
}
|
|
92
94
|
interface SceneConstructor {
|
|
93
95
|
new (): IScene;
|
|
96
|
+
[key: string]: any;
|
|
94
97
|
}
|
|
95
98
|
interface IScene {
|
|
96
99
|
/** Root display container for this scene */
|
|
@@ -155,13 +158,16 @@ interface TweenOptions {
|
|
|
155
158
|
/**
|
|
156
159
|
* Minimal typed event emitter.
|
|
157
160
|
* Used internally by GameApplication, SceneManager, AudioManager, etc.
|
|
161
|
+
*
|
|
162
|
+
* Supports `void` event types — events that carry no data can be emitted
|
|
163
|
+
* without arguments: `emitter.emit('eventName')`.
|
|
158
164
|
*/
|
|
159
165
|
declare class EventEmitter<TEvents extends {}> {
|
|
160
166
|
private listeners;
|
|
161
167
|
on<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
162
168
|
once<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
163
169
|
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;
|
|
170
|
+
emit<K extends keyof TEvents>(...args: TEvents[K] extends void ? [event: K] : [event: K, data: TEvents[K]]): void;
|
|
165
171
|
removeAllListeners(event?: keyof TEvents): this;
|
|
166
172
|
}
|
|
167
173
|
|
|
@@ -438,6 +444,10 @@ declare class AudioManager {
|
|
|
438
444
|
* Destroy the audio manager and free resources.
|
|
439
445
|
*/
|
|
440
446
|
destroy(): void;
|
|
447
|
+
/**
|
|
448
|
+
* Smoothly fade a sound's volume from `fromVol` to `toVol` over `durationMs`.
|
|
449
|
+
*/
|
|
450
|
+
private fadeVolume;
|
|
441
451
|
private applyVolumes;
|
|
442
452
|
private setupMobileUnlock;
|
|
443
453
|
private removeMobileUnlock;
|
|
@@ -505,6 +515,9 @@ declare class InputManager extends EventEmitter<InputEvents> {
|
|
|
505
515
|
private _locked;
|
|
506
516
|
private _keysDown;
|
|
507
517
|
private _destroyed;
|
|
518
|
+
private _viewportScale;
|
|
519
|
+
private _viewportOffsetX;
|
|
520
|
+
private _viewportOffsetY;
|
|
508
521
|
private _pointerStart;
|
|
509
522
|
private _swipeThreshold;
|
|
510
523
|
private _swipeMaxTime;
|
|
@@ -517,6 +530,19 @@ declare class InputManager extends EventEmitter<InputEvents> {
|
|
|
517
530
|
unlock(): void;
|
|
518
531
|
/** Check if a key is currently pressed */
|
|
519
532
|
isKeyDown(key: string): boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Update the viewport transform used for DOM→world coordinate mapping.
|
|
535
|
+
* Called automatically by GameApplication when ViewportManager emits resize.
|
|
536
|
+
*/
|
|
537
|
+
setViewportTransform(scale: number, offsetX: number, offsetY: number): void;
|
|
538
|
+
/**
|
|
539
|
+
* Convert a DOM canvas position to game-world coordinates,
|
|
540
|
+
* accounting for viewport scaling and offset.
|
|
541
|
+
*/
|
|
542
|
+
getWorldPosition(canvasX: number, canvasY: number): {
|
|
543
|
+
x: number;
|
|
544
|
+
y: number;
|
|
545
|
+
};
|
|
520
546
|
/** Destroy the input manager */
|
|
521
547
|
destroy(): void;
|
|
522
548
|
private setupPointerEvents;
|
|
@@ -607,6 +633,37 @@ declare class ViewportManager extends EventEmitter<ViewportEvents> {
|
|
|
607
633
|
private debouncedRefresh;
|
|
608
634
|
}
|
|
609
635
|
|
|
636
|
+
/**
|
|
637
|
+
* FPS overlay for debugging performance.
|
|
638
|
+
*
|
|
639
|
+
* Shows FPS, frame time, and draw call count in the corner of the screen.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```ts
|
|
643
|
+
* const fps = new FPSOverlay(app);
|
|
644
|
+
* fps.show();
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
declare class FPSOverlay {
|
|
648
|
+
private _app;
|
|
649
|
+
private _container;
|
|
650
|
+
private _fpsText;
|
|
651
|
+
private _visible;
|
|
652
|
+
private _samples;
|
|
653
|
+
private _maxSamples;
|
|
654
|
+
private _lastUpdate;
|
|
655
|
+
private _tickFn;
|
|
656
|
+
constructor(app: Application);
|
|
657
|
+
/** Show the FPS overlay */
|
|
658
|
+
show(): void;
|
|
659
|
+
/** Hide the FPS overlay */
|
|
660
|
+
hide(): void;
|
|
661
|
+
/** Toggle visibility */
|
|
662
|
+
toggle(): void;
|
|
663
|
+
/** Destroy the overlay */
|
|
664
|
+
destroy(): void;
|
|
665
|
+
}
|
|
666
|
+
|
|
610
667
|
/**
|
|
611
668
|
* The main entry point for a game built on @energy8platform/game-engine.
|
|
612
669
|
*
|
|
@@ -653,6 +710,8 @@ declare class GameApplication extends EventEmitter<GameEngineEvents> {
|
|
|
653
710
|
viewport: ViewportManager;
|
|
654
711
|
/** SDK instance (null in offline mode) */
|
|
655
712
|
sdk: CasinoGameSDK | null;
|
|
713
|
+
/** FPS overlay instance (only when debug: true) */
|
|
714
|
+
fpsOverlay: FPSOverlay | null;
|
|
656
715
|
/** Data received from SDK initialization */
|
|
657
716
|
initData: InitData | null;
|
|
658
717
|
/** Configuration */
|
|
@@ -887,6 +946,7 @@ declare class Tween {
|
|
|
887
946
|
static fromTo(target: any, fromProps: Record<string, number>, toProps: Record<string, number>, duration: number, easing?: EasingFunction, onUpdate?: (progress: number) => void): Promise<void>;
|
|
888
947
|
/**
|
|
889
948
|
* Wait for a given duration (useful in timelines).
|
|
949
|
+
* Uses PixiJS Ticker for consistent timing with other tweens.
|
|
890
950
|
*/
|
|
891
951
|
static delay(ms: number): Promise<void>;
|
|
892
952
|
/**
|
|
@@ -899,6 +959,11 @@ declare class Tween {
|
|
|
899
959
|
static killAll(): void;
|
|
900
960
|
/** Number of active tweens */
|
|
901
961
|
static get activeTweens(): number;
|
|
962
|
+
/**
|
|
963
|
+
* Reset the tween system — kill all tweens and remove the ticker.
|
|
964
|
+
* Useful for cleanup between game instances, tests, or hot-reload.
|
|
965
|
+
*/
|
|
966
|
+
static reset(): void;
|
|
902
967
|
private static ensureTicker;
|
|
903
968
|
private static tick;
|
|
904
969
|
/**
|
|
@@ -1078,6 +1143,113 @@ declare class SpineHelper {
|
|
|
1078
1143
|
static setSkin(spine: any, skinName: string): void;
|
|
1079
1144
|
}
|
|
1080
1145
|
|
|
1146
|
+
interface SpriteAnimationConfig {
|
|
1147
|
+
/** Frames per second (default: 24) */
|
|
1148
|
+
fps?: number;
|
|
1149
|
+
/** Whether to loop (default: true) */
|
|
1150
|
+
loop?: boolean;
|
|
1151
|
+
/** Start playing immediately (default: true) */
|
|
1152
|
+
autoPlay?: boolean;
|
|
1153
|
+
/** Callback when animation completes (non-looping) */
|
|
1154
|
+
onComplete?: () => void;
|
|
1155
|
+
/** Anchor point (default: 0.5 = center) */
|
|
1156
|
+
anchor?: number | {
|
|
1157
|
+
x: number;
|
|
1158
|
+
y: number;
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Helper for creating frame-based animations from spritesheets.
|
|
1163
|
+
*
|
|
1164
|
+
* Wraps PixiJS `AnimatedSprite` with a convenient API for
|
|
1165
|
+
* common iGaming effects: coin showers, symbol animations,
|
|
1166
|
+
* sparkle trails, win celebrations.
|
|
1167
|
+
*
|
|
1168
|
+
* Cheaper than Spine for simple frame sequences.
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```ts
|
|
1172
|
+
* // From an array of textures
|
|
1173
|
+
* const coinAnim = SpriteAnimation.create(coinTextures, {
|
|
1174
|
+
* fps: 30,
|
|
1175
|
+
* loop: true,
|
|
1176
|
+
* });
|
|
1177
|
+
* scene.addChild(coinAnim);
|
|
1178
|
+
*
|
|
1179
|
+
* // From a spritesheet with a naming pattern
|
|
1180
|
+
* const sheet = Assets.get('effects');
|
|
1181
|
+
* const sparkle = SpriteAnimation.fromSpritesheet(sheet, 'sparkle_');
|
|
1182
|
+
* sparkle.play();
|
|
1183
|
+
*
|
|
1184
|
+
* // From a numbered range
|
|
1185
|
+
* const explosion = SpriteAnimation.fromRange(sheet, 'explosion_{i}', 0, 24, {
|
|
1186
|
+
* fps: 60,
|
|
1187
|
+
* loop: false,
|
|
1188
|
+
* onComplete: () => explosion.destroy(),
|
|
1189
|
+
* });
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
declare class SpriteAnimation {
|
|
1193
|
+
/**
|
|
1194
|
+
* Create an animated sprite from an array of textures.
|
|
1195
|
+
*
|
|
1196
|
+
* @param textures - Array of PixiJS Textures
|
|
1197
|
+
* @param config - Animation options
|
|
1198
|
+
* @returns Configured AnimatedSprite
|
|
1199
|
+
*/
|
|
1200
|
+
static create(textures: Texture[], config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1201
|
+
/**
|
|
1202
|
+
* Create an animated sprite from a spritesheet using a name prefix.
|
|
1203
|
+
*
|
|
1204
|
+
* Collects all textures whose keys start with `prefix`, sorted alphabetically.
|
|
1205
|
+
*
|
|
1206
|
+
* @param sheet - PixiJS Spritesheet instance
|
|
1207
|
+
* @param prefix - Texture name prefix (e.g., 'coin_')
|
|
1208
|
+
* @param config - Animation options
|
|
1209
|
+
* @returns Configured AnimatedSprite
|
|
1210
|
+
*/
|
|
1211
|
+
static fromSpritesheet(sheet: Spritesheet, prefix: string, config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1212
|
+
/**
|
|
1213
|
+
* Create an animated sprite from a numbered range of frames.
|
|
1214
|
+
*
|
|
1215
|
+
* The `pattern` string should contain `{i}` as a placeholder for the frame number.
|
|
1216
|
+
* Numbers are zero-padded to match the length of `start`.
|
|
1217
|
+
*
|
|
1218
|
+
* @param sheet - PixiJS Spritesheet instance
|
|
1219
|
+
* @param pattern - Frame name pattern, e.g. 'explosion_{i}'
|
|
1220
|
+
* @param start - Start frame index (inclusive)
|
|
1221
|
+
* @param end - End frame index (inclusive)
|
|
1222
|
+
* @param config - Animation options
|
|
1223
|
+
* @returns Configured AnimatedSprite
|
|
1224
|
+
*/
|
|
1225
|
+
static fromRange(sheet: Spritesheet, pattern: string, start: number, end: number, config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1226
|
+
/**
|
|
1227
|
+
* Create an AnimatedSprite from texture aliases (loaded via AssetManager).
|
|
1228
|
+
*
|
|
1229
|
+
* @param aliases - Array of texture aliases
|
|
1230
|
+
* @param config - Animation options
|
|
1231
|
+
* @returns Configured AnimatedSprite
|
|
1232
|
+
*/
|
|
1233
|
+
static fromAliases(aliases: string[], config?: SpriteAnimationConfig): AnimatedSprite;
|
|
1234
|
+
/**
|
|
1235
|
+
* Play a one-shot animation and auto-destroy when complete.
|
|
1236
|
+
* Useful for fire-and-forget effects like coin bursts.
|
|
1237
|
+
*
|
|
1238
|
+
* @param textures - Array of textures
|
|
1239
|
+
* @param config - Animation options (loop will be forced to false)
|
|
1240
|
+
* @returns Promise that resolves when animation completes
|
|
1241
|
+
*/
|
|
1242
|
+
static playOnce(textures: Texture[], config?: SpriteAnimationConfig): {
|
|
1243
|
+
sprite: AnimatedSprite;
|
|
1244
|
+
finished: Promise<void>;
|
|
1245
|
+
};
|
|
1246
|
+
/**
|
|
1247
|
+
* Get all textures from a spritesheet that start with a given prefix.
|
|
1248
|
+
* Results are sorted alphabetically by key.
|
|
1249
|
+
*/
|
|
1250
|
+
static getTexturesByPrefix(sheet: Spritesheet, prefix: string): Texture[];
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1081
1253
|
type ButtonState = 'normal' | 'hover' | 'pressed' | 'disabled';
|
|
1082
1254
|
interface ButtonConfig {
|
|
1083
1255
|
/** Default texture/sprite for each state (optional — uses Graphics if not provided) */
|
|
@@ -1319,6 +1491,7 @@ declare class BalanceDisplay extends Container {
|
|
|
1319
1491
|
private _currentValue;
|
|
1320
1492
|
private _displayedValue;
|
|
1321
1493
|
private _animating;
|
|
1494
|
+
private _animationCancelled;
|
|
1322
1495
|
constructor(config?: BalanceDisplayConfig);
|
|
1323
1496
|
/** Current displayed value */
|
|
1324
1497
|
get value(): number;
|
|
@@ -1461,6 +1634,211 @@ declare class Toast extends Container {
|
|
|
1461
1634
|
dismiss(): Promise<void>;
|
|
1462
1635
|
}
|
|
1463
1636
|
|
|
1637
|
+
type LayoutDirection = 'horizontal' | 'vertical' | 'grid' | 'wrap';
|
|
1638
|
+
type LayoutAlignment = 'start' | 'center' | 'end' | 'stretch';
|
|
1639
|
+
type LayoutAnchor = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
1640
|
+
interface LayoutConfig {
|
|
1641
|
+
/** Layout direction (default: 'vertical') */
|
|
1642
|
+
direction?: LayoutDirection;
|
|
1643
|
+
/** Gap between children in pixels (default: 0) */
|
|
1644
|
+
gap?: number;
|
|
1645
|
+
/** Padding inside the layout container [top, right, bottom, left] or a single number */
|
|
1646
|
+
padding?: number | [number, number, number, number];
|
|
1647
|
+
/** Alignment of children on the cross axis (default: 'start') */
|
|
1648
|
+
alignment?: LayoutAlignment;
|
|
1649
|
+
/** Anchor point determining where the layout is positioned relative to its coordinates */
|
|
1650
|
+
anchor?: LayoutAnchor;
|
|
1651
|
+
/** Number of columns (only for 'grid' direction) */
|
|
1652
|
+
columns?: number;
|
|
1653
|
+
/** Maximum width for 'wrap' direction before wrapping to next line */
|
|
1654
|
+
maxWidth?: number;
|
|
1655
|
+
/** Whether to auto-layout when children change (default: true) */
|
|
1656
|
+
autoLayout?: boolean;
|
|
1657
|
+
/** Breakpoints: map of max viewport widths to override configs */
|
|
1658
|
+
breakpoints?: Record<number, Partial<LayoutConfig>>;
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Responsive layout container that automatically arranges its children.
|
|
1662
|
+
*
|
|
1663
|
+
* Supports horizontal, vertical, grid, and wrap layout modes with
|
|
1664
|
+
* alignment, padding, gap, and viewport-anchor positioning.
|
|
1665
|
+
* Breakpoints allow different layouts for different screen sizes.
|
|
1666
|
+
*
|
|
1667
|
+
* @example
|
|
1668
|
+
* ```ts
|
|
1669
|
+
* const toolbar = new Layout({
|
|
1670
|
+
* direction: 'horizontal',
|
|
1671
|
+
* gap: 20,
|
|
1672
|
+
* alignment: 'center',
|
|
1673
|
+
* anchor: 'bottom-center',
|
|
1674
|
+
* padding: 16,
|
|
1675
|
+
* breakpoints: {
|
|
1676
|
+
* 768: { direction: 'vertical', gap: 10 },
|
|
1677
|
+
* },
|
|
1678
|
+
* });
|
|
1679
|
+
*
|
|
1680
|
+
* toolbar.addItem(spinButton);
|
|
1681
|
+
* toolbar.addItem(betLabel);
|
|
1682
|
+
* scene.container.addChild(toolbar);
|
|
1683
|
+
*
|
|
1684
|
+
* // On resize, update layout position relative to viewport
|
|
1685
|
+
* toolbar.updateViewport(width, height);
|
|
1686
|
+
* ```
|
|
1687
|
+
*/
|
|
1688
|
+
declare class Layout extends Container {
|
|
1689
|
+
private _config;
|
|
1690
|
+
private _padding;
|
|
1691
|
+
private _anchor;
|
|
1692
|
+
private _maxWidth;
|
|
1693
|
+
private _breakpoints;
|
|
1694
|
+
private _content;
|
|
1695
|
+
private _items;
|
|
1696
|
+
private _viewportWidth;
|
|
1697
|
+
private _viewportHeight;
|
|
1698
|
+
constructor(config?: LayoutConfig);
|
|
1699
|
+
/** Add an item to the layout */
|
|
1700
|
+
addItem(child: Container): this;
|
|
1701
|
+
/** Remove an item from the layout */
|
|
1702
|
+
removeItem(child: Container): this;
|
|
1703
|
+
/** Remove all items */
|
|
1704
|
+
clearItems(): this;
|
|
1705
|
+
/** Get all layout items */
|
|
1706
|
+
get items(): readonly Container[];
|
|
1707
|
+
/**
|
|
1708
|
+
* Update the viewport size and recalculate layout.
|
|
1709
|
+
* Should be called from `Scene.onResize()`.
|
|
1710
|
+
*/
|
|
1711
|
+
updateViewport(width: number, height: number): void;
|
|
1712
|
+
/**
|
|
1713
|
+
* Recalculate layout positions of all children.
|
|
1714
|
+
*/
|
|
1715
|
+
layout(): void;
|
|
1716
|
+
private layoutLinear;
|
|
1717
|
+
private layoutGrid;
|
|
1718
|
+
private layoutWrap;
|
|
1719
|
+
private applyAnchor;
|
|
1720
|
+
private resolveConfig;
|
|
1721
|
+
private getItemSize;
|
|
1722
|
+
private static normalizePadding;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
1726
|
+
interface ScrollContainerConfig {
|
|
1727
|
+
/** Visible viewport width */
|
|
1728
|
+
width: number;
|
|
1729
|
+
/** Visible viewport height */
|
|
1730
|
+
height: number;
|
|
1731
|
+
/** Scroll direction (default: 'vertical') */
|
|
1732
|
+
direction?: ScrollDirection;
|
|
1733
|
+
/** Show scrollbar(s) (default: true) */
|
|
1734
|
+
showScrollbar?: boolean;
|
|
1735
|
+
/** Scrollbar width in pixels (default: 6) */
|
|
1736
|
+
scrollbarWidth?: number;
|
|
1737
|
+
/** Scrollbar color (default: 0xffffff) */
|
|
1738
|
+
scrollbarColor?: number;
|
|
1739
|
+
/** Scrollbar opacity (default: 0.4) */
|
|
1740
|
+
scrollbarAlpha?: number;
|
|
1741
|
+
/** Elasticity factor for overscroll bounce (0 = none, 1 = infinite, default: 0.3) */
|
|
1742
|
+
elasticity?: number;
|
|
1743
|
+
/** Inertia deceleration factor (0 = instant stop, 1 = infinite drift, default: 0.92) */
|
|
1744
|
+
inertia?: number;
|
|
1745
|
+
/** Snap to items of fixed height/width (0 = no snap) */
|
|
1746
|
+
snapSize?: number;
|
|
1747
|
+
/** Background color (undefined = transparent) */
|
|
1748
|
+
backgroundColor?: number;
|
|
1749
|
+
/** Background alpha (default: 1) */
|
|
1750
|
+
backgroundAlpha?: number;
|
|
1751
|
+
/** Border radius for the mask (default: 0) */
|
|
1752
|
+
borderRadius?: number;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Scrollable container with touch/drag, mouse wheel, inertia, and optional scrollbar.
|
|
1756
|
+
*
|
|
1757
|
+
* Perfect for paytables, settings panels, bet history, and any scrollable content
|
|
1758
|
+
* that doesn't fit on screen.
|
|
1759
|
+
*
|
|
1760
|
+
* @example
|
|
1761
|
+
* ```ts
|
|
1762
|
+
* const scroll = new ScrollContainer({
|
|
1763
|
+
* width: 600,
|
|
1764
|
+
* height: 400,
|
|
1765
|
+
* direction: 'vertical',
|
|
1766
|
+
* showScrollbar: true,
|
|
1767
|
+
* elasticity: 0.3,
|
|
1768
|
+
* });
|
|
1769
|
+
*
|
|
1770
|
+
* // Add content taller than 400px
|
|
1771
|
+
* const list = new Container();
|
|
1772
|
+
* for (let i = 0; i < 50; i++) {
|
|
1773
|
+
* const row = createRow(i);
|
|
1774
|
+
* row.y = i * 40;
|
|
1775
|
+
* list.addChild(row);
|
|
1776
|
+
* }
|
|
1777
|
+
* scroll.setContent(list);
|
|
1778
|
+
*
|
|
1779
|
+
* scene.container.addChild(scroll);
|
|
1780
|
+
* ```
|
|
1781
|
+
*/
|
|
1782
|
+
declare class ScrollContainer extends Container {
|
|
1783
|
+
private _config;
|
|
1784
|
+
private _viewport;
|
|
1785
|
+
private _content;
|
|
1786
|
+
private _mask;
|
|
1787
|
+
private _bg;
|
|
1788
|
+
private _scrollbarV;
|
|
1789
|
+
private _scrollbarH;
|
|
1790
|
+
private _scrollbarFadeTimeout;
|
|
1791
|
+
private _scrollX;
|
|
1792
|
+
private _scrollY;
|
|
1793
|
+
private _velocityX;
|
|
1794
|
+
private _velocityY;
|
|
1795
|
+
private _isDragging;
|
|
1796
|
+
private _dragStart;
|
|
1797
|
+
private _scrollStart;
|
|
1798
|
+
private _lastDragPos;
|
|
1799
|
+
private _lastDragTime;
|
|
1800
|
+
private _isAnimating;
|
|
1801
|
+
private _animationFrame;
|
|
1802
|
+
constructor(config: ScrollContainerConfig);
|
|
1803
|
+
/** Set scrollable content. Replaces any existing content. */
|
|
1804
|
+
setContent(content: Container): void;
|
|
1805
|
+
/** Get the content container */
|
|
1806
|
+
get content(): Container | null;
|
|
1807
|
+
/** Scroll to a specific position (in content coordinates) */
|
|
1808
|
+
scrollTo(x: number, y: number, animate?: boolean): void;
|
|
1809
|
+
/** Scroll to make a specific item/child visible */
|
|
1810
|
+
scrollToItem(index: number): void;
|
|
1811
|
+
/** Current scroll position */
|
|
1812
|
+
get scrollPosition(): {
|
|
1813
|
+
x: number;
|
|
1814
|
+
y: number;
|
|
1815
|
+
};
|
|
1816
|
+
/** Resize the scroll viewport */
|
|
1817
|
+
resize(width: number, height: number): void;
|
|
1818
|
+
/** Destroy and clean up */
|
|
1819
|
+
destroy(options?: any): void;
|
|
1820
|
+
private get contentWidth();
|
|
1821
|
+
private get contentHeight();
|
|
1822
|
+
private get maxScrollX();
|
|
1823
|
+
private get maxScrollY();
|
|
1824
|
+
private canScrollX;
|
|
1825
|
+
private canScrollY;
|
|
1826
|
+
private clampScroll;
|
|
1827
|
+
private applyScroll;
|
|
1828
|
+
private onPointerDown;
|
|
1829
|
+
private onPointerMove;
|
|
1830
|
+
private onPointerUp;
|
|
1831
|
+
private onWheel;
|
|
1832
|
+
private startInertia;
|
|
1833
|
+
private snapAndBounce;
|
|
1834
|
+
private animateScrollTo;
|
|
1835
|
+
private stopAnimation;
|
|
1836
|
+
private updateScrollbars;
|
|
1837
|
+
private showScrollbars;
|
|
1838
|
+
private scheduleScrollbarFade;
|
|
1839
|
+
private fadeScrollbars;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1464
1842
|
/**
|
|
1465
1843
|
* Built-in loading screen using the Energy8 SVG logo with animated loader bar.
|
|
1466
1844
|
*
|
|
@@ -1521,8 +1899,9 @@ interface DevBridgeConfig {
|
|
|
1521
1899
|
/**
|
|
1522
1900
|
* Mock host bridge for local development.
|
|
1523
1901
|
*
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1902
|
+
* Uses the SDK's `Bridge` class in `devMode` to communicate with
|
|
1903
|
+
* `CasinoGameSDK` via a shared in-memory `MemoryChannel`, removing
|
|
1904
|
+
* the need for postMessage and iframes.
|
|
1526
1905
|
*
|
|
1527
1906
|
* This allows games to be developed and tested without a real backend.
|
|
1528
1907
|
*
|
|
@@ -1550,8 +1929,7 @@ declare class DevBridge {
|
|
|
1550
1929
|
private _config;
|
|
1551
1930
|
private _balance;
|
|
1552
1931
|
private _roundCounter;
|
|
1553
|
-
private
|
|
1554
|
-
private _handler;
|
|
1932
|
+
private _bridge;
|
|
1555
1933
|
constructor(config?: DevBridgeConfig);
|
|
1556
1934
|
/** Current mock balance */
|
|
1557
1935
|
get balance(): number;
|
|
@@ -1563,7 +1941,6 @@ declare class DevBridge {
|
|
|
1563
1941
|
setBalance(balance: number): void;
|
|
1564
1942
|
/** Destroy the dev bridge */
|
|
1565
1943
|
destroy(): void;
|
|
1566
|
-
private handleMessage;
|
|
1567
1944
|
private handleGameReady;
|
|
1568
1945
|
private handlePlayRequest;
|
|
1569
1946
|
private handlePlayAck;
|
|
@@ -1571,39 +1948,7 @@ declare class DevBridge {
|
|
|
1571
1948
|
private handleGetState;
|
|
1572
1949
|
private handleOpenDeposit;
|
|
1573
1950
|
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
1951
|
}
|
|
1607
1952
|
|
|
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 };
|
|
1953
|
+
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 };
|
|
1954
|
+
export type { AssetBundle, AssetEntry, AssetManifest, AudioConfig, DevBridgeConfig, EasingFunction, GameApplicationConfig, GameEngineEvents, IScene, LayoutAlignment, LayoutAnchor, LayoutConfig, LayoutDirection, LoadingScreenConfig, SceneConstructor, ScrollContainerConfig, ScrollDirection, SpriteAnimationConfig, TransitionConfig, TweenOptions };
|