@energy8platform/game-engine 0.21.0 → 0.22.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/host.d.ts +3 -5
- package/dist/index.cjs.js +0 -2532
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -1020
- package/dist/index.esm.js +2 -2522
- package/dist/index.esm.js.map +1 -1
- package/dist/slot.cjs.js +0 -30
- package/dist/slot.cjs.js.map +1 -1
- package/dist/slot.d.ts +2 -25
- package/dist/slot.esm.js +1 -30
- package/dist/slot.esm.js.map +1 -1
- package/dist/vite.cjs.js +0 -5
- package/dist/vite.cjs.js.map +1 -1
- package/dist/vite.esm.js +0 -5
- package/dist/vite.esm.js.map +1 -1
- package/package.json +2 -35
- package/src/host/index.ts +0 -1
- package/src/host/types.ts +0 -3
- package/src/index.ts +0 -28
- package/src/slot/index.ts +0 -2
- package/src/vite/index.ts +0 -5
- package/dist/react-jsx.cjs.js +0 -3
- package/dist/react-jsx.cjs.js.map +0 -1
- package/dist/react-jsx.d.ts +0 -602
- package/dist/react-jsx.esm.js +0 -2
- package/dist/react-jsx.esm.js.map +0 -1
- package/dist/react.cjs.js +0 -3802
- package/dist/react.cjs.js.map +0 -1
- package/dist/react.d.ts +0 -1467
- package/dist/react.esm.js +0 -3786
- package/dist/react.esm.js.map +0 -1
- package/dist/ui.cjs.js +0 -3014
- package/dist/ui.cjs.js.map +0 -1
- package/dist/ui.d.ts +0 -1116
- package/dist/ui.esm.js +0 -2998
- package/dist/ui.esm.js.map +0 -1
- package/src/react/EngineContext.ts +0 -26
- package/src/react/ReactScene.ts +0 -88
- package/src/react/applyProps.ts +0 -271
- package/src/react/catalogue.ts +0 -17
- package/src/react/createPixiRoot.ts +0 -31
- package/src/react/extendAll.ts +0 -74
- package/src/react/hooks.ts +0 -46
- package/src/react/index.ts +0 -29
- package/src/react/jsx-runtime.ts +0 -346
- package/src/react/reconciler.ts +0 -338
- package/src/slot/freeSpins/FreeSpinsSession.ts +0 -40
- package/src/state/StateMachine.ts +0 -231
- package/src/state/index.ts +0 -1
- package/src/ui/BalanceDisplay.ts +0 -159
- package/src/ui/Button.ts +0 -304
- package/src/ui/FlexContainer.ts +0 -775
- package/src/ui/Label.ts +0 -124
- package/src/ui/LabelValue.ts +0 -122
- package/src/ui/Layout.ts +0 -291
- package/src/ui/Modal.ts +0 -170
- package/src/ui/Panel.ts +0 -204
- package/src/ui/ProgressBar.ts +0 -170
- package/src/ui/ScrollContainer.ts +0 -478
- package/src/ui/Slider.ts +0 -241
- package/src/ui/Toast.ts +0 -150
- package/src/ui/Toggle.ts +0 -201
- package/src/ui/WinDisplay.ts +0 -145
- package/src/ui/index.ts +0 -33
- package/src/ui/view.ts +0 -28
package/dist/react.d.ts
DELETED
|
@@ -1,1467 +0,0 @@
|
|
|
1
|
-
import { Texture, Container, TextStyle, ColorSource, ApplicationOptions, Application } from 'pixi.js';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { ReactElement } from 'react';
|
|
4
|
-
import * as _energy8platform_platform_core_shell from '@energy8platform/platform-core/shell';
|
|
5
|
-
import { LoadingScreenConfig, AssetManifest, PlatformSession } from '@energy8platform/platform-core';
|
|
6
|
-
import { CasinoGameSDK, InitData, GameConfigData, SessionData } from '@energy8platform/game-sdk';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Universal view input type for UI component visual slots.
|
|
10
|
-
*
|
|
11
|
-
* - `string` — texture name, resolved via `Sprite.from()`
|
|
12
|
-
* - `Texture` — wrapped in a `Sprite`
|
|
13
|
-
* - `Container` — used as-is (Sprite, Graphics, NineSliceSprite, AnimatedSprite, custom...)
|
|
14
|
-
*/
|
|
15
|
-
type ViewInput = string | Texture | Container;
|
|
16
|
-
|
|
17
|
-
type ButtonState = 'default' | 'hover' | 'pressed' | 'disabled';
|
|
18
|
-
interface ButtonConfig {
|
|
19
|
-
/** Custom view for default state (string texture name, Texture, or Container) */
|
|
20
|
-
defaultView?: ViewInput;
|
|
21
|
-
/** Custom view for hover state */
|
|
22
|
-
hoverView?: ViewInput;
|
|
23
|
-
/** Custom view for pressed state */
|
|
24
|
-
pressedView?: ViewInput;
|
|
25
|
-
/** Custom view for disabled state */
|
|
26
|
-
disabledView?: ViewInput;
|
|
27
|
-
/** Width (for Graphics-based button, ignored when custom views provided) */
|
|
28
|
-
width?: number;
|
|
29
|
-
/** Height (for Graphics-based button) */
|
|
30
|
-
height?: number;
|
|
31
|
-
/** Corner radius (for Graphics-based button) */
|
|
32
|
-
borderRadius?: number;
|
|
33
|
-
/** Colors for each state (for Graphics-based button) */
|
|
34
|
-
colors?: Partial<Record<ButtonState, number>>;
|
|
35
|
-
/** Scale on press */
|
|
36
|
-
pressScale?: number;
|
|
37
|
-
/** Scale animation duration (ms) */
|
|
38
|
-
animationDuration?: number;
|
|
39
|
-
/** Start disabled */
|
|
40
|
-
disabled?: boolean;
|
|
41
|
-
/** Button text (rendered on top of the view) */
|
|
42
|
-
text?: string;
|
|
43
|
-
/** Button text style */
|
|
44
|
-
textStyle?: Record<string, unknown>;
|
|
45
|
-
/** Press callback */
|
|
46
|
-
onPress?: () => void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface LabelConfig {
|
|
50
|
-
text?: string;
|
|
51
|
-
style?: Partial<TextStyle>;
|
|
52
|
-
/** Maximum width — text will be scaled down to fit */
|
|
53
|
-
maxWidth?: number;
|
|
54
|
-
/** Auto-fit: scale text to fit maxWidth */
|
|
55
|
-
autoFit?: boolean;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type FlexDirection = 'row' | 'column';
|
|
59
|
-
type JustifyContent = 'start' | 'center' | 'end' | 'space-between' | 'space-around';
|
|
60
|
-
type AlignItems = 'start' | 'center' | 'end' | 'stretch';
|
|
61
|
-
type AlignContent = 'start' | 'center' | 'end' | 'space-between' | 'stretch';
|
|
62
|
-
type AlignSelf = 'auto' | 'start' | 'center' | 'end' | 'stretch';
|
|
63
|
-
interface FlexContainerConfig {
|
|
64
|
-
/** Layout direction (default: 'row') */
|
|
65
|
-
direction?: FlexDirection;
|
|
66
|
-
/** Main-axis distribution (default: 'start') */
|
|
67
|
-
justifyContent?: JustifyContent;
|
|
68
|
-
/** Cross-axis alignment (default: 'start') */
|
|
69
|
-
alignItems?: AlignItems;
|
|
70
|
-
/** Gap between children in pixels (default: 0) */
|
|
71
|
-
gap?: number;
|
|
72
|
-
/** Padding [top, right, bottom, left] or single number (default: 0) */
|
|
73
|
-
padding?: number | [number, number, number, number];
|
|
74
|
-
/** Individual padding overrides (take priority over `padding`) */
|
|
75
|
-
paddingTop?: number;
|
|
76
|
-
paddingRight?: number;
|
|
77
|
-
paddingBottom?: number;
|
|
78
|
-
paddingLeft?: number;
|
|
79
|
-
/** Enable wrapping to next line (default: false) */
|
|
80
|
-
flexWrap?: boolean;
|
|
81
|
-
/** Distribution of lines along the cross axis when wrapping (default: 'start') */
|
|
82
|
-
alignContent?: AlignContent;
|
|
83
|
-
/** Maximum width before wrapping (only with flexWrap) */
|
|
84
|
-
maxWidth?: number;
|
|
85
|
-
/** Maximum height before wrapping (only with flexWrap + column) */
|
|
86
|
-
maxHeight?: number;
|
|
87
|
-
/** Explicit container width — number in pixels, or string percentage (e.g. "50%") resolved against parent */
|
|
88
|
-
width?: number | string;
|
|
89
|
-
/** Explicit container height — number in pixels, or string percentage (e.g. "50%") resolved against parent */
|
|
90
|
-
height?: number | string;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
type LabelValueAlign = 'start' | 'center' | 'end';
|
|
94
|
-
interface LabelValueConfig {
|
|
95
|
-
/** Caption text (top row, typically smaller/muted) */
|
|
96
|
-
label?: string;
|
|
97
|
-
/** Value text (bottom row, typically larger/prominent) */
|
|
98
|
-
value?: string;
|
|
99
|
-
/** Style for the caption Label */
|
|
100
|
-
labelStyle?: Partial<TextStyle>;
|
|
101
|
-
/** Style for the value Label */
|
|
102
|
-
valueStyle?: Partial<TextStyle>;
|
|
103
|
-
/** Gap in pixels between caption and value (default: 4) */
|
|
104
|
-
gap?: number;
|
|
105
|
-
/** Horizontal alignment of both rows (default: 'center') */
|
|
106
|
-
align?: LabelValueAlign;
|
|
107
|
-
/** Maximum width — value will be auto-scaled to fit when exceeded */
|
|
108
|
-
maxWidth?: number;
|
|
109
|
-
/** Optional padding (forwarded to the underlying FlexContainer) */
|
|
110
|
-
padding?: FlexContainerConfig['padding'];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
interface PanelConfig {
|
|
114
|
-
/** Width */
|
|
115
|
-
width?: number;
|
|
116
|
-
/** Height */
|
|
117
|
-
height?: number;
|
|
118
|
-
/** Background color (for Graphics-based panel) */
|
|
119
|
-
backgroundColor?: number;
|
|
120
|
-
/** Background alpha */
|
|
121
|
-
backgroundAlpha?: number;
|
|
122
|
-
/** Corner radius */
|
|
123
|
-
borderRadius?: number;
|
|
124
|
-
/** Border color */
|
|
125
|
-
borderColor?: number;
|
|
126
|
-
/** Border width */
|
|
127
|
-
borderWidth?: number;
|
|
128
|
-
/** 9-slice texture (if provided, uses NineSliceSprite instead of Graphics) */
|
|
129
|
-
nineSliceTexture?: string | Texture;
|
|
130
|
-
/** 9-slice borders [left, top, right, bottom] */
|
|
131
|
-
nineSliceBorders?: [number, number, number, number];
|
|
132
|
-
/** Padding inside the panel */
|
|
133
|
-
padding?: number;
|
|
134
|
-
/** Flex layout config for content */
|
|
135
|
-
layout?: Partial<FlexContainerConfig>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
interface ProgressBarConfig {
|
|
139
|
-
/** Width of the bar */
|
|
140
|
-
width?: number;
|
|
141
|
-
/** Height of the bar */
|
|
142
|
-
height?: number;
|
|
143
|
-
/** Corner radius (for Graphics-based bar) */
|
|
144
|
-
borderRadius?: number;
|
|
145
|
-
/** Fill color (for Graphics-based bar, ignored when fillView provided) */
|
|
146
|
-
fillColor?: number;
|
|
147
|
-
/** Track background color (for Graphics-based bar, ignored when trackView provided) */
|
|
148
|
-
trackColor?: number;
|
|
149
|
-
/** Border color */
|
|
150
|
-
borderColor?: number;
|
|
151
|
-
/** Border width */
|
|
152
|
-
borderWidth?: number;
|
|
153
|
-
/** Animated fill (smoothly interpolate) */
|
|
154
|
-
animated?: boolean;
|
|
155
|
-
/** Animation speed (0..1 per frame, default: 0.1) */
|
|
156
|
-
animationSpeed?: number;
|
|
157
|
-
/** Custom track background (string texture name, Texture, or Container) */
|
|
158
|
-
trackView?: ViewInput;
|
|
159
|
-
/** Custom fill bar (string texture name, Texture, or Container) */
|
|
160
|
-
fillView?: ViewInput;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
164
|
-
interface ScrollContainerConfig {
|
|
165
|
-
/** Visible viewport width */
|
|
166
|
-
width: number;
|
|
167
|
-
/** Visible viewport height */
|
|
168
|
-
height: number;
|
|
169
|
-
/** Scroll direction (default: 'vertical') */
|
|
170
|
-
direction?: ScrollDirection;
|
|
171
|
-
/** Background color (undefined = transparent) */
|
|
172
|
-
backgroundColor?: ColorSource;
|
|
173
|
-
/** Border radius for the mask (default: 0) */
|
|
174
|
-
borderRadius?: number;
|
|
175
|
-
/** Gap between items (default: 0) */
|
|
176
|
-
elementsMargin?: number;
|
|
177
|
-
/** Padding */
|
|
178
|
-
padding?: number;
|
|
179
|
-
/** Disable easing/inertia */
|
|
180
|
-
disableEasing?: boolean;
|
|
181
|
-
/** Show scrollbar indicator (default: false) */
|
|
182
|
-
scrollbar?: boolean;
|
|
183
|
-
/** Custom scrollbar thumb view (string texture name, Texture, or Container) */
|
|
184
|
-
thumbView?: ViewInput;
|
|
185
|
-
/** Scrollbar width in px (default: 6) */
|
|
186
|
-
scrollbarWidth?: number;
|
|
187
|
-
/** Scrollbar padding from edge (default: 4) */
|
|
188
|
-
scrollbarPadding?: number;
|
|
189
|
-
/** Scrollbar color (when no thumbView, default: 0xaaaaaa) */
|
|
190
|
-
scrollbarColor?: number;
|
|
191
|
-
/** Scrollbar alpha (default: 0.5) */
|
|
192
|
-
scrollbarAlpha?: number;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
interface ModalConfig {
|
|
196
|
-
/** Overlay color */
|
|
197
|
-
overlayColor?: number;
|
|
198
|
-
/** Overlay alpha */
|
|
199
|
-
overlayAlpha?: number;
|
|
200
|
-
/** Close on overlay tap */
|
|
201
|
-
closeOnOverlay?: boolean;
|
|
202
|
-
/** Animation duration */
|
|
203
|
-
animationDuration?: number;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
interface ToastConfig {
|
|
207
|
-
/** Auto-dismiss after this many ms (0 = manual dismiss only) */
|
|
208
|
-
duration?: number;
|
|
209
|
-
/** Toast position from bottom */
|
|
210
|
-
bottomOffset?: number;
|
|
211
|
-
/** Custom background view (string texture name, Texture, or Container). Sized to fit text. */
|
|
212
|
-
backgroundView?: ViewInput;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
interface BalanceDisplayConfig {
|
|
216
|
-
/** Label prefix (e.g., "BALANCE") */
|
|
217
|
-
prefix?: string;
|
|
218
|
-
/** Text style overrides */
|
|
219
|
-
style?: Record<string, unknown>;
|
|
220
|
-
/** Currency code */
|
|
221
|
-
currency?: string;
|
|
222
|
-
/** Locale for number formatting */
|
|
223
|
-
locale?: string;
|
|
224
|
-
/** Max width */
|
|
225
|
-
maxWidth?: number;
|
|
226
|
-
/** Animate value changes */
|
|
227
|
-
animated?: boolean;
|
|
228
|
-
/** Animation duration in ms */
|
|
229
|
-
animationDuration?: number;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
interface WinDisplayConfig {
|
|
233
|
-
/** Text style overrides */
|
|
234
|
-
style?: Record<string, unknown>;
|
|
235
|
-
/** Currency code */
|
|
236
|
-
currency?: string;
|
|
237
|
-
/** Locale for number formatting */
|
|
238
|
-
locale?: string;
|
|
239
|
-
/** Countup duration in ms */
|
|
240
|
-
countupDuration?: number;
|
|
241
|
-
/** Scale pop animation on win */
|
|
242
|
-
popScale?: number;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
type LayoutDirection = 'horizontal' | 'vertical' | 'grid' | 'wrap';
|
|
246
|
-
type LayoutAlignment = 'start' | 'center' | 'end' | 'stretch';
|
|
247
|
-
type LayoutAnchor = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
248
|
-
interface LayoutConfig {
|
|
249
|
-
/** Layout direction (default: 'vertical') */
|
|
250
|
-
direction?: LayoutDirection;
|
|
251
|
-
/** Gap between children in pixels (default: 0) */
|
|
252
|
-
gap?: number;
|
|
253
|
-
/** Padding inside the layout container [top, right, bottom, left] or a single number */
|
|
254
|
-
padding?: number | [number, number, number, number];
|
|
255
|
-
/** Alignment of children on the cross axis (default: 'start') */
|
|
256
|
-
alignment?: LayoutAlignment;
|
|
257
|
-
/** Anchor point determining where the layout is positioned relative to its coordinates */
|
|
258
|
-
anchor?: LayoutAnchor;
|
|
259
|
-
/** Number of columns (only for 'grid' direction) */
|
|
260
|
-
columns?: number;
|
|
261
|
-
/** Maximum width for 'wrap' direction before wrapping to next line */
|
|
262
|
-
maxWidth?: number;
|
|
263
|
-
/** Whether to auto-layout when children change (default: true) */
|
|
264
|
-
autoLayout?: boolean;
|
|
265
|
-
/** Breakpoints: map of max viewport widths to override configs */
|
|
266
|
-
breakpoints?: Record<number, Partial<LayoutConfig>>;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
interface SliderConfig {
|
|
270
|
-
/** Minimum value (default: 0) */
|
|
271
|
-
min?: number;
|
|
272
|
-
/** Maximum value (default: 1) */
|
|
273
|
-
max?: number;
|
|
274
|
-
/** Step increment (0 = continuous, default: 0) */
|
|
275
|
-
step?: number;
|
|
276
|
-
/** Initial value (default: min) */
|
|
277
|
-
value?: number;
|
|
278
|
-
/** Track width in pixels (default: 200) */
|
|
279
|
-
width?: number;
|
|
280
|
-
/** Track height in pixels (default: 8) */
|
|
281
|
-
height?: number;
|
|
282
|
-
/** Corner radius for Graphics-based track/fill (default: 4) */
|
|
283
|
-
borderRadius?: number;
|
|
284
|
-
/** Track background color (ignored when trackView provided) */
|
|
285
|
-
trackColor?: number;
|
|
286
|
-
/** Fill bar color (ignored when fillView provided) */
|
|
287
|
-
fillColor?: number;
|
|
288
|
-
/** Handle radius (for Graphics-based handle, default: 12) */
|
|
289
|
-
handleRadius?: number;
|
|
290
|
-
/** Handle color (for Graphics-based handle, ignored when handleView provided) */
|
|
291
|
-
handleColor?: number;
|
|
292
|
-
/** Custom track background view */
|
|
293
|
-
trackView?: ViewInput;
|
|
294
|
-
/** Custom fill bar view */
|
|
295
|
-
fillView?: ViewInput;
|
|
296
|
-
/** Custom handle view */
|
|
297
|
-
handleView?: ViewInput;
|
|
298
|
-
/** Called when value changes during drag */
|
|
299
|
-
onUpdate?: (value: number) => void;
|
|
300
|
-
/** Called when drag ends */
|
|
301
|
-
onChange?: (value: number) => void;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
interface ToggleConfig {
|
|
305
|
-
/** Initial state (default: false) */
|
|
306
|
-
value?: boolean;
|
|
307
|
-
/** Custom view for the ON state */
|
|
308
|
-
onView?: ViewInput;
|
|
309
|
-
/** Custom view for the OFF state */
|
|
310
|
-
offView?: ViewInput;
|
|
311
|
-
/** Width (for Graphics-based toggle, default: 52) */
|
|
312
|
-
width?: number;
|
|
313
|
-
/** Height (for Graphics-based toggle, default: 28) */
|
|
314
|
-
height?: number;
|
|
315
|
-
/** Track color when ON (ignored when custom views provided) */
|
|
316
|
-
onColor?: number;
|
|
317
|
-
/** Track color when OFF (ignored when custom views provided) */
|
|
318
|
-
offColor?: number;
|
|
319
|
-
/** Handle color (for Graphics-based toggle) */
|
|
320
|
-
handleColor?: number;
|
|
321
|
-
/** Handle radius (for Graphics-based toggle, default: auto) */
|
|
322
|
-
handleRadius?: number;
|
|
323
|
-
/** Animation duration in ms (default: 200) */
|
|
324
|
-
animationDuration?: number;
|
|
325
|
-
/** Called when value changes */
|
|
326
|
-
onChange?: (value: boolean) => void;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* JSX prop types for the PixiJS React reconciler.
|
|
331
|
-
*
|
|
332
|
-
* The engine auto-augments `react`'s module-scoped `JSX.IntrinsicElements`
|
|
333
|
-
* with every registered element (`<flexContainer>`, `<button>`, `<label>`,
|
|
334
|
-
* `<labelValue>`, etc). Because the augmentation is scoped to the `react`
|
|
335
|
-
* module (not the legacy global `JSX` namespace), it reliably wins over
|
|
336
|
-
* `@types/react`'s HTML defaults for colliding names like `<button>` / `<label>`.
|
|
337
|
-
*
|
|
338
|
-
* **Consumers don't need any shim.** Any import from `@energy8platform/game-engine/react`
|
|
339
|
-
* (e.g. `createPixiRoot`, `extendUIElements`, `ReactScene` — you're already
|
|
340
|
-
* importing these to boot the reconciler) pulls this module in and the JSX
|
|
341
|
-
* types activate automatically.
|
|
342
|
-
*
|
|
343
|
-
* If a project imports only from `/ui` or `/core` and never touches `/react`,
|
|
344
|
-
* add a one-line side-effect import to trigger the augmentation:
|
|
345
|
-
*
|
|
346
|
-
* ```ts
|
|
347
|
-
* // app/src/pixi-jsx.d.ts
|
|
348
|
-
* import '@energy8platform/game-engine/react-jsx';
|
|
349
|
-
* ```
|
|
350
|
-
*
|
|
351
|
-
* Dash-notation for nested config objects is supported:
|
|
352
|
-
* <button colors-default={0xff0000} colors-hover={0x00ff00} />
|
|
353
|
-
*/
|
|
354
|
-
|
|
355
|
-
interface PixiEventProps {
|
|
356
|
-
onClick?: (e: any) => void;
|
|
357
|
-
onPointerDown?: (e: any) => void;
|
|
358
|
-
onPointerUp?: (e: any) => void;
|
|
359
|
-
onPointerMove?: (e: any) => void;
|
|
360
|
-
onPointerOver?: (e: any) => void;
|
|
361
|
-
onPointerOut?: (e: any) => void;
|
|
362
|
-
onPointerEnter?: (e: any) => void;
|
|
363
|
-
onPointerLeave?: (e: any) => void;
|
|
364
|
-
onPointerCancel?: (e: any) => void;
|
|
365
|
-
onPointerTap?: (e: any) => void;
|
|
366
|
-
onPointerUpOutside?: (e: any) => void;
|
|
367
|
-
onMouseDown?: (e: any) => void;
|
|
368
|
-
onMouseUp?: (e: any) => void;
|
|
369
|
-
onMouseMove?: (e: any) => void;
|
|
370
|
-
onMouseOver?: (e: any) => void;
|
|
371
|
-
onMouseOut?: (e: any) => void;
|
|
372
|
-
onWheel?: (e: any) => void;
|
|
373
|
-
onTap?: (e: any) => void;
|
|
374
|
-
onRightClick?: (e: any) => void;
|
|
375
|
-
}
|
|
376
|
-
interface BaseProps extends PixiEventProps {
|
|
377
|
-
key?: React.Key;
|
|
378
|
-
ref?: React.Ref<any>;
|
|
379
|
-
children?: React.ReactNode;
|
|
380
|
-
x?: number;
|
|
381
|
-
y?: number;
|
|
382
|
-
width?: number;
|
|
383
|
-
height?: number;
|
|
384
|
-
alpha?: number;
|
|
385
|
-
visible?: boolean;
|
|
386
|
-
rotation?: number;
|
|
387
|
-
angle?: number;
|
|
388
|
-
zIndex?: number;
|
|
389
|
-
label?: string;
|
|
390
|
-
cursor?: string;
|
|
391
|
-
eventMode?: 'auto' | 'none' | 'passive' | 'static' | 'dynamic';
|
|
392
|
-
'scale-x'?: number;
|
|
393
|
-
'scale-y'?: number;
|
|
394
|
-
'pivot-x'?: number;
|
|
395
|
-
'pivot-y'?: number;
|
|
396
|
-
'position-x'?: number;
|
|
397
|
-
'position-y'?: number;
|
|
398
|
-
'anchor-x'?: number;
|
|
399
|
-
'anchor-y'?: number;
|
|
400
|
-
scale?: number | {
|
|
401
|
-
x: number;
|
|
402
|
-
y: number;
|
|
403
|
-
};
|
|
404
|
-
flexGrow?: number;
|
|
405
|
-
flexShrink?: number;
|
|
406
|
-
layoutWidth?: number | string;
|
|
407
|
-
layoutHeight?: number | string;
|
|
408
|
-
alignSelf?: AlignSelf;
|
|
409
|
-
flexExclude?: boolean;
|
|
410
|
-
top?: number;
|
|
411
|
-
right?: number;
|
|
412
|
-
bottom?: number;
|
|
413
|
-
left?: number;
|
|
414
|
-
/** X coordinate of the visual center within parent (px or `'50%'`). Overrides left/right. */
|
|
415
|
-
centerX?: number | string;
|
|
416
|
-
/** Y coordinate of the visual center within parent (px or `'50%'`). Overrides top/bottom. */
|
|
417
|
-
centerY?: number | string;
|
|
418
|
-
}
|
|
419
|
-
interface SpriteProps extends BaseProps {
|
|
420
|
-
texture?: string | Texture;
|
|
421
|
-
anchor?: number | {
|
|
422
|
-
x: number;
|
|
423
|
-
y: number;
|
|
424
|
-
};
|
|
425
|
-
tint?: number;
|
|
426
|
-
}
|
|
427
|
-
interface TextProps extends BaseProps {
|
|
428
|
-
text?: string;
|
|
429
|
-
style?: Partial<TextStyle>;
|
|
430
|
-
anchor?: number | {
|
|
431
|
-
x: number;
|
|
432
|
-
y: number;
|
|
433
|
-
};
|
|
434
|
-
'style-fontSize'?: number;
|
|
435
|
-
'style-fill'?: number | string;
|
|
436
|
-
'style-fontFamily'?: string;
|
|
437
|
-
'style-fontWeight'?: string;
|
|
438
|
-
'style-letterSpacing'?: number;
|
|
439
|
-
}
|
|
440
|
-
interface GraphicsProps extends BaseProps {
|
|
441
|
-
/** Draw function: receives the Graphics instance, called on mount and updates */
|
|
442
|
-
draw?: (g: any) => void;
|
|
443
|
-
/**
|
|
444
|
-
* Layout size hint (pixels). For Graphics, `width`/`height` do NOT apply a scale
|
|
445
|
-
* transform (unlike Container.width). They're forwarded to the parent
|
|
446
|
-
* FlexContainer as `layoutWidth`/`layoutHeight` so layout measures the element
|
|
447
|
-
* at the requested size while the actual geometry stays in the `draw` callback.
|
|
448
|
-
*/
|
|
449
|
-
width?: number;
|
|
450
|
-
height?: number;
|
|
451
|
-
}
|
|
452
|
-
interface AnimatedSpriteProps extends BaseProps {
|
|
453
|
-
textures?: Texture[];
|
|
454
|
-
animationSpeed?: number;
|
|
455
|
-
loop?: boolean;
|
|
456
|
-
playing?: boolean;
|
|
457
|
-
}
|
|
458
|
-
interface NineSliceSpriteProps extends BaseProps {
|
|
459
|
-
texture?: string | Texture;
|
|
460
|
-
leftWidth?: number;
|
|
461
|
-
topHeight?: number;
|
|
462
|
-
rightWidth?: number;
|
|
463
|
-
bottomHeight?: number;
|
|
464
|
-
}
|
|
465
|
-
interface TilingSpriteProps extends BaseProps {
|
|
466
|
-
texture?: string | Texture;
|
|
467
|
-
tilePosition?: {
|
|
468
|
-
x: number;
|
|
469
|
-
y: number;
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
interface ButtonComponentProps extends BaseProps, Omit<ButtonConfig, 'colors' | 'textStyle'> {
|
|
473
|
-
colors?: Partial<Record<ButtonState, number>>;
|
|
474
|
-
textStyle?: Record<string, unknown>;
|
|
475
|
-
defaultView?: ViewInput;
|
|
476
|
-
hoverView?: ViewInput;
|
|
477
|
-
pressedView?: ViewInput;
|
|
478
|
-
disabledView?: ViewInput;
|
|
479
|
-
'colors-default'?: number;
|
|
480
|
-
'colors-hover'?: number;
|
|
481
|
-
'colors-pressed'?: number;
|
|
482
|
-
'colors-disabled'?: number;
|
|
483
|
-
'textStyle-fontSize'?: number;
|
|
484
|
-
'textStyle-fill'?: number | string;
|
|
485
|
-
'textStyle-fontFamily'?: string;
|
|
486
|
-
'textStyle-fontWeight'?: string;
|
|
487
|
-
'textStyle-fontStyle'?: string;
|
|
488
|
-
'textStyle-letterSpacing'?: number;
|
|
489
|
-
onPress?: () => void;
|
|
490
|
-
}
|
|
491
|
-
interface LabelComponentProps extends BaseProps, Omit<LabelConfig, 'style'> {
|
|
492
|
-
style?: Partial<TextStyle>;
|
|
493
|
-
'style-fontSize'?: number;
|
|
494
|
-
'style-fill'?: number | string;
|
|
495
|
-
'style-fontFamily'?: string;
|
|
496
|
-
'style-fontWeight'?: string;
|
|
497
|
-
'style-letterSpacing'?: number;
|
|
498
|
-
}
|
|
499
|
-
interface LabelValueComponentProps extends Omit<BaseProps, 'width' | 'height' | 'label'>, Omit<LabelValueConfig, 'labelStyle' | 'valueStyle'> {
|
|
500
|
-
labelStyle?: Partial<TextStyle>;
|
|
501
|
-
valueStyle?: Partial<TextStyle>;
|
|
502
|
-
width?: number | string;
|
|
503
|
-
height?: number | string;
|
|
504
|
-
'labelStyle-fontSize'?: number;
|
|
505
|
-
'labelStyle-fill'?: number | string;
|
|
506
|
-
'labelStyle-fontFamily'?: string;
|
|
507
|
-
'labelStyle-fontWeight'?: string;
|
|
508
|
-
'valueStyle-fontSize'?: number;
|
|
509
|
-
'valueStyle-fill'?: number | string;
|
|
510
|
-
'valueStyle-fontFamily'?: string;
|
|
511
|
-
'valueStyle-fontWeight'?: string;
|
|
512
|
-
}
|
|
513
|
-
interface PanelComponentProps extends BaseProps, Omit<PanelConfig, 'layout'> {
|
|
514
|
-
layout?: Partial<FlexContainerConfig>;
|
|
515
|
-
}
|
|
516
|
-
interface FlexContainerComponentProps extends Omit<BaseProps, 'width' | 'height'>, FlexContainerConfig {
|
|
517
|
-
padding?: number | [number, number, number, number];
|
|
518
|
-
paddingTop?: number;
|
|
519
|
-
paddingRight?: number;
|
|
520
|
-
paddingBottom?: number;
|
|
521
|
-
paddingLeft?: number;
|
|
522
|
-
alignContent?: AlignContent;
|
|
523
|
-
width?: number | string;
|
|
524
|
-
height?: number | string;
|
|
525
|
-
}
|
|
526
|
-
interface ProgressBarComponentProps extends BaseProps, ProgressBarConfig {
|
|
527
|
-
progress?: number;
|
|
528
|
-
/** Custom track background (string texture name, Texture, or Container) */
|
|
529
|
-
trackView?: ViewInput;
|
|
530
|
-
/** Custom fill bar */
|
|
531
|
-
fillView?: ViewInput;
|
|
532
|
-
}
|
|
533
|
-
interface ScrollContainerComponentProps extends BaseProps, Omit<ScrollContainerConfig, 'width' | 'height'> {
|
|
534
|
-
width: number;
|
|
535
|
-
height: number;
|
|
536
|
-
/** Show scrollbar indicator */
|
|
537
|
-
scrollbar?: boolean;
|
|
538
|
-
/** Custom scrollbar thumb view */
|
|
539
|
-
thumbView?: ViewInput;
|
|
540
|
-
scrollbarWidth?: number;
|
|
541
|
-
scrollbarPadding?: number;
|
|
542
|
-
scrollbarColor?: number;
|
|
543
|
-
scrollbarAlpha?: number;
|
|
544
|
-
}
|
|
545
|
-
interface ModalComponentProps extends BaseProps, ModalConfig {
|
|
546
|
-
onClose?: () => void;
|
|
547
|
-
}
|
|
548
|
-
interface ToastComponentProps extends BaseProps, ToastConfig {
|
|
549
|
-
/** Custom background view */
|
|
550
|
-
backgroundView?: ViewInput;
|
|
551
|
-
}
|
|
552
|
-
interface BalanceDisplayComponentProps extends BaseProps, BalanceDisplayConfig {
|
|
553
|
-
/** Current balance value */
|
|
554
|
-
value?: number;
|
|
555
|
-
}
|
|
556
|
-
interface WinDisplayComponentProps extends BaseProps, WinDisplayConfig {
|
|
557
|
-
}
|
|
558
|
-
interface LayoutComponentProps extends BaseProps, LayoutConfig {
|
|
559
|
-
}
|
|
560
|
-
interface SliderComponentProps extends BaseProps, Omit<SliderConfig, 'width' | 'height'> {
|
|
561
|
-
width?: number;
|
|
562
|
-
height?: number;
|
|
563
|
-
onUpdate?: (value: number) => void;
|
|
564
|
-
onChange?: (value: number) => void;
|
|
565
|
-
}
|
|
566
|
-
interface ToggleComponentProps extends BaseProps, Omit<ToggleConfig, 'width' | 'height'> {
|
|
567
|
-
width?: number;
|
|
568
|
-
height?: number;
|
|
569
|
-
onView?: ViewInput;
|
|
570
|
-
offView?: ViewInput;
|
|
571
|
-
onChange?: (value: boolean) => void;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Complete element → prop-type map for all engine-registered JSX elements.
|
|
575
|
-
* Also consumable directly for typing custom wrappers around engine elements.
|
|
576
|
-
*/
|
|
577
|
-
interface EngineIntrinsicElements {
|
|
578
|
-
container: BaseProps;
|
|
579
|
-
sprite: SpriteProps;
|
|
580
|
-
text: TextProps;
|
|
581
|
-
graphics: GraphicsProps;
|
|
582
|
-
animatedSprite: AnimatedSpriteProps;
|
|
583
|
-
nineSliceSprite: NineSliceSpriteProps;
|
|
584
|
-
tilingSprite: TilingSpriteProps;
|
|
585
|
-
button: ButtonComponentProps;
|
|
586
|
-
label: LabelComponentProps;
|
|
587
|
-
labelValue: LabelValueComponentProps;
|
|
588
|
-
panel: PanelComponentProps;
|
|
589
|
-
flexContainer: FlexContainerComponentProps;
|
|
590
|
-
progressBar: ProgressBarComponentProps;
|
|
591
|
-
scrollContainer: ScrollContainerComponentProps;
|
|
592
|
-
modal: ModalComponentProps;
|
|
593
|
-
toast: ToastComponentProps;
|
|
594
|
-
balanceDisplay: BalanceDisplayComponentProps;
|
|
595
|
-
winDisplay: WinDisplayComponentProps;
|
|
596
|
-
layout: LayoutComponentProps;
|
|
597
|
-
slider: SliderComponentProps;
|
|
598
|
-
toggle: ToggleComponentProps;
|
|
599
|
-
}
|
|
600
|
-
declare module 'react' {
|
|
601
|
-
namespace JSX {
|
|
602
|
-
interface IntrinsicElements extends EngineIntrinsicElements {
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
interface PixiRoot {
|
|
608
|
-
render(element: ReactElement): void;
|
|
609
|
-
unmount(): void;
|
|
610
|
-
}
|
|
611
|
-
declare function createPixiRoot(container: Container): PixiRoot;
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* Register PixiJS classes for use as JSX elements.
|
|
615
|
-
* Keys must be PascalCase; JSX uses the camelCase equivalent.
|
|
616
|
-
*
|
|
617
|
-
* @example
|
|
618
|
-
* ```ts
|
|
619
|
-
* import { Container, Sprite, Text } from 'pixi.js';
|
|
620
|
-
* extend({ Container, Sprite, Text });
|
|
621
|
-
* // Now <container>, <sprite>, <text> work in JSX
|
|
622
|
-
* ```
|
|
623
|
-
*/
|
|
624
|
-
declare function extend(components: Record<string, any>): void;
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Register all standard PixiJS display objects for JSX use.
|
|
628
|
-
* Call once at app startup before rendering any React scenes.
|
|
629
|
-
*/
|
|
630
|
-
declare function extendPixiElements(): void;
|
|
631
|
-
/**
|
|
632
|
-
* Register all engine UI components for JSX use.
|
|
633
|
-
* Call once at app startup before rendering React scenes that use UI components.
|
|
634
|
-
*
|
|
635
|
-
* @example
|
|
636
|
-
* ```ts
|
|
637
|
-
* extendPixiElements();
|
|
638
|
-
* extendUIElements();
|
|
639
|
-
*
|
|
640
|
-
* // Now you can use:
|
|
641
|
-
* // <button text="SPIN" onPress={handler} />
|
|
642
|
-
* // <flexContainer direction="row" gap={16}>...</flexContainer>
|
|
643
|
-
* // <label text="Hello" style-fontSize={24} />
|
|
644
|
-
* ```
|
|
645
|
-
*/
|
|
646
|
-
declare function extendUIElements(): void;
|
|
647
|
-
/**
|
|
648
|
-
* Register additional custom components for JSX use.
|
|
649
|
-
* Pass an object mapping component names to their constructors.
|
|
650
|
-
*/
|
|
651
|
-
declare function extendCustomElements(components: Record<string, any>): void;
|
|
652
|
-
|
|
653
|
-
declare enum ScaleMode {
|
|
654
|
-
/** Fit inside container, maintain aspect ratio (letterbox/pillarbox) */
|
|
655
|
-
FIT = "FIT",
|
|
656
|
-
/** Fill container, maintain aspect ratio (crop edges) */
|
|
657
|
-
FILL = "FILL",
|
|
658
|
-
/** Stretch to fill (distorts) */
|
|
659
|
-
STRETCH = "STRETCH"
|
|
660
|
-
}
|
|
661
|
-
declare enum Orientation {
|
|
662
|
-
LANDSCAPE = "landscape",
|
|
663
|
-
PORTRAIT = "portrait",
|
|
664
|
-
ANY = "any"
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
interface AudioConfig {
|
|
668
|
-
/** Default volumes per category (0..1) */
|
|
669
|
-
music?: number;
|
|
670
|
-
sfx?: number;
|
|
671
|
-
ui?: number;
|
|
672
|
-
ambient?: number;
|
|
673
|
-
/** Persist mute state in localStorage */
|
|
674
|
-
persist?: boolean;
|
|
675
|
-
/** LocalStorage key prefix */
|
|
676
|
-
storageKey?: string;
|
|
677
|
-
}
|
|
678
|
-
interface GameApplicationConfig {
|
|
679
|
-
/** Container element or CSS selector to mount canvas into */
|
|
680
|
-
container?: HTMLElement | string;
|
|
681
|
-
/** Reference design width (fallback: GameConfigData.viewport.width or 1920) */
|
|
682
|
-
designWidth?: number;
|
|
683
|
-
/** Reference design height (fallback: GameConfigData.viewport.height or 1080) */
|
|
684
|
-
designHeight?: number;
|
|
685
|
-
/** How to scale the game to fit the container */
|
|
686
|
-
scaleMode?: ScaleMode;
|
|
687
|
-
/** Preferred orientation */
|
|
688
|
-
orientation?: Orientation;
|
|
689
|
-
/** Loading screen configuration */
|
|
690
|
-
loading?: LoadingScreenConfig;
|
|
691
|
-
/** Asset manifest — what to load */
|
|
692
|
-
manifest?: AssetManifest;
|
|
693
|
-
/** Audio configuration */
|
|
694
|
-
audio?: AudioConfig;
|
|
695
|
-
/** SDK options. Set to false to disable SDK (offline/development mode) */
|
|
696
|
-
sdk?: {
|
|
697
|
-
parentOrigin?: string;
|
|
698
|
-
timeout?: number;
|
|
699
|
-
debug?: boolean;
|
|
700
|
-
/** Use in-memory channel instead of postMessage (no iframe required) */
|
|
701
|
-
devMode?: boolean;
|
|
702
|
-
} | false;
|
|
703
|
-
/** PixiJS Application options (pass-through) */
|
|
704
|
-
pixi?: Partial<ApplicationOptions>;
|
|
705
|
-
/** Enable debug overlay (FPS, draw calls) */
|
|
706
|
-
debug?: boolean;
|
|
707
|
-
/** When set, GameApplication mounts the branded game shell after the SDK handshake. */
|
|
708
|
-
shell?: _energy8platform_platform_core_shell.ShellConfig | false;
|
|
709
|
-
}
|
|
710
|
-
interface SceneConstructor {
|
|
711
|
-
new (): IScene;
|
|
712
|
-
[key: string]: any;
|
|
713
|
-
}
|
|
714
|
-
interface IScene {
|
|
715
|
-
/** Root display container for this scene */
|
|
716
|
-
readonly container: Container;
|
|
717
|
-
/** @internal GameApplication reference — set by SceneManager */
|
|
718
|
-
__engineApp?: any;
|
|
719
|
-
/** Called when the scene is entered */
|
|
720
|
-
onEnter?(data?: unknown): Promise<void> | void;
|
|
721
|
-
/** Called when the scene is exited */
|
|
722
|
-
onExit?(): Promise<void> | void;
|
|
723
|
-
/** Called every frame */
|
|
724
|
-
onUpdate?(dt: number): void;
|
|
725
|
-
/** Called when viewport resizes */
|
|
726
|
-
onResize?(width: number, height: number): void;
|
|
727
|
-
/** Called when the scene is destroyed */
|
|
728
|
-
onDestroy?(): void;
|
|
729
|
-
}
|
|
730
|
-
declare enum TransitionType {
|
|
731
|
-
NONE = "none",
|
|
732
|
-
FADE = "fade",
|
|
733
|
-
SLIDE_LEFT = "slide-left",
|
|
734
|
-
SLIDE_RIGHT = "slide-right"
|
|
735
|
-
}
|
|
736
|
-
interface TransitionConfig {
|
|
737
|
-
type: TransitionType;
|
|
738
|
-
duration?: number;
|
|
739
|
-
easing?: (t: number) => number;
|
|
740
|
-
}
|
|
741
|
-
interface GameEngineEvents {
|
|
742
|
-
/** Fired when engine initialization is complete */
|
|
743
|
-
initialized: void;
|
|
744
|
-
/** Fired when all assets are loaded */
|
|
745
|
-
loaded: void;
|
|
746
|
-
/** Fired when the engine starts running */
|
|
747
|
-
started: void;
|
|
748
|
-
/** Fired on viewport resize */
|
|
749
|
-
resize: {
|
|
750
|
-
width: number;
|
|
751
|
-
height: number;
|
|
752
|
-
};
|
|
753
|
-
/** Fired on orientation change */
|
|
754
|
-
orientationChange: Orientation;
|
|
755
|
-
/** Fired on scene change */
|
|
756
|
-
sceneChange: {
|
|
757
|
-
from: string | null;
|
|
758
|
-
to: string;
|
|
759
|
-
};
|
|
760
|
-
/** Fired when player balance changes (forwarded from SDK) */
|
|
761
|
-
balanceUpdate: {
|
|
762
|
-
balance: number;
|
|
763
|
-
};
|
|
764
|
-
/** Fired on error */
|
|
765
|
-
error: Error;
|
|
766
|
-
/** Fired when engine is destroyed */
|
|
767
|
-
destroyed: void;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* Base class for all scenes.
|
|
772
|
-
* Provides a root PixiJS Container and lifecycle hooks.
|
|
773
|
-
*
|
|
774
|
-
* @example
|
|
775
|
-
* ```ts
|
|
776
|
-
* class MenuScene extends Scene {
|
|
777
|
-
* async onEnter() {
|
|
778
|
-
* const bg = Sprite.from('menu-bg');
|
|
779
|
-
* this.container.addChild(bg);
|
|
780
|
-
* }
|
|
781
|
-
*
|
|
782
|
-
* onUpdate(dt: number) {
|
|
783
|
-
* // per-frame logic
|
|
784
|
-
* }
|
|
785
|
-
*
|
|
786
|
-
* onResize(width: number, height: number) {
|
|
787
|
-
* // reposition UI
|
|
788
|
-
* }
|
|
789
|
-
* }
|
|
790
|
-
* ```
|
|
791
|
-
*/
|
|
792
|
-
declare abstract class Scene implements IScene {
|
|
793
|
-
readonly container: Container;
|
|
794
|
-
constructor();
|
|
795
|
-
/** Called when this scene becomes active. Override in subclass. */
|
|
796
|
-
onEnter?(data?: unknown): Promise<void> | void;
|
|
797
|
-
/** Called when this scene is deactivated. Override in subclass. */
|
|
798
|
-
onExit?(): Promise<void> | void;
|
|
799
|
-
/** Called every frame with delta time (in seconds). Override in subclass. */
|
|
800
|
-
onUpdate?(dt: number): void;
|
|
801
|
-
/** Called when the viewport resizes. Override in subclass. */
|
|
802
|
-
onResize?(width: number, height: number): void;
|
|
803
|
-
/** Cleanup — called when the scene is permanently removed. */
|
|
804
|
-
onDestroy?(): void;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* Minimal typed event emitter.
|
|
809
|
-
* Used internally by GameApplication, SceneManager, AudioManager, etc.
|
|
810
|
-
*
|
|
811
|
-
* Supports `void` event types — events that carry no data can be emitted
|
|
812
|
-
* without arguments: `emitter.emit('eventName')`.
|
|
813
|
-
*/
|
|
814
|
-
declare class EventEmitter<TEvents extends {}> {
|
|
815
|
-
private listeners;
|
|
816
|
-
on<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
817
|
-
once<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
818
|
-
off<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
|
|
819
|
-
emit<K extends keyof TEvents>(...args: TEvents[K] extends void ? [event: K] : [event: K, data: TEvents[K]]): void;
|
|
820
|
-
removeAllListeners(event?: keyof TEvents): this;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
interface SceneEntry {
|
|
824
|
-
scene: IScene;
|
|
825
|
-
key: string;
|
|
826
|
-
}
|
|
827
|
-
interface SceneManagerEvents {
|
|
828
|
-
change: {
|
|
829
|
-
from: string | null;
|
|
830
|
-
to: string;
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
/**
|
|
834
|
-
* Manages the scene stack and transitions between scenes.
|
|
835
|
-
*
|
|
836
|
-
* @example
|
|
837
|
-
* ```ts
|
|
838
|
-
* const scenes = new SceneManager(app.stage);
|
|
839
|
-
* scenes.register('loading', LoadingScene);
|
|
840
|
-
* scenes.register('game', GameScene);
|
|
841
|
-
* await scenes.goto('loading');
|
|
842
|
-
* ```
|
|
843
|
-
*/
|
|
844
|
-
declare class SceneManager extends EventEmitter<SceneManagerEvents> {
|
|
845
|
-
private static MAX_TRANSITION_DEPTH;
|
|
846
|
-
/** Root container that scenes are added to */
|
|
847
|
-
root: Container;
|
|
848
|
-
private registry;
|
|
849
|
-
private stack;
|
|
850
|
-
private _transitionDepth;
|
|
851
|
-
/** Current viewport dimensions — set by ViewportManager */
|
|
852
|
-
private _width;
|
|
853
|
-
private _height;
|
|
854
|
-
/** @internal GameApplication reference — passed to scenes */
|
|
855
|
-
private _app;
|
|
856
|
-
constructor(root?: Container);
|
|
857
|
-
/** @internal Set the root container (called by GameApplication after PixiJS init) */
|
|
858
|
-
setRoot(root: Container): void;
|
|
859
|
-
/** @internal Set the app reference (called by GameApplication) */
|
|
860
|
-
setApp(app: any): void;
|
|
861
|
-
/** Register a scene class by key */
|
|
862
|
-
register(key: string, ctor: SceneConstructor): this;
|
|
863
|
-
/** Get the current (topmost) scene entry */
|
|
864
|
-
get current(): SceneEntry | null;
|
|
865
|
-
/** Get the current scene key */
|
|
866
|
-
get currentKey(): string | null;
|
|
867
|
-
/** Whether a scene transition is in progress */
|
|
868
|
-
get isTransitioning(): boolean;
|
|
869
|
-
/**
|
|
870
|
-
* Navigate to a scene, replacing the entire stack.
|
|
871
|
-
*/
|
|
872
|
-
goto(key: string, data?: unknown, transition?: TransitionConfig): Promise<void>;
|
|
873
|
-
/**
|
|
874
|
-
* Push a scene onto the stack (the previous scene stays underneath).
|
|
875
|
-
* Useful for overlays, modals, pause screens.
|
|
876
|
-
*/
|
|
877
|
-
push(key: string, data?: unknown, transition?: TransitionConfig): Promise<void>;
|
|
878
|
-
/**
|
|
879
|
-
* Pop the top scene from the stack.
|
|
880
|
-
*/
|
|
881
|
-
pop(transition?: TransitionConfig): Promise<void>;
|
|
882
|
-
/**
|
|
883
|
-
* Replace the top scene with a new one.
|
|
884
|
-
*/
|
|
885
|
-
replace(key: string, data?: unknown, transition?: TransitionConfig): Promise<void>;
|
|
886
|
-
/**
|
|
887
|
-
* Called every frame by GameApplication.
|
|
888
|
-
*/
|
|
889
|
-
update(dt: number): void;
|
|
890
|
-
/**
|
|
891
|
-
* Called on viewport resize.
|
|
892
|
-
*/
|
|
893
|
-
resize(width: number, height: number): void;
|
|
894
|
-
/**
|
|
895
|
-
* Destroy all scenes and clear the manager.
|
|
896
|
-
*/
|
|
897
|
-
destroy(): void;
|
|
898
|
-
private createScene;
|
|
899
|
-
private pushInternal;
|
|
900
|
-
private popInternal;
|
|
901
|
-
private transitionIn;
|
|
902
|
-
private transitionOut;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* Manages game asset loading with progress tracking, bundle support, and
|
|
907
|
-
* automatic base path resolution from SDK's assetsUrl.
|
|
908
|
-
*
|
|
909
|
-
* Wraps PixiJS Assets API with a typed, game-oriented interface.
|
|
910
|
-
*
|
|
911
|
-
* @example
|
|
912
|
-
* ```ts
|
|
913
|
-
* const assets = new AssetManager('https://cdn.example.com/game/', manifest);
|
|
914
|
-
* await assets.init();
|
|
915
|
-
* await assets.loadBundle('preload', (p) => console.log(p));
|
|
916
|
-
* const texture = assets.get<Texture>('hero');
|
|
917
|
-
* ```
|
|
918
|
-
*/
|
|
919
|
-
declare class AssetManager {
|
|
920
|
-
private _initialized;
|
|
921
|
-
private _basePath;
|
|
922
|
-
private _manifest;
|
|
923
|
-
private _loadedBundles;
|
|
924
|
-
constructor(basePath?: string, manifest?: AssetManifest);
|
|
925
|
-
/** Whether the asset system has been initialized */
|
|
926
|
-
get initialized(): boolean;
|
|
927
|
-
/** Base path for all assets (usually from SDK's assetsUrl) */
|
|
928
|
-
get basePath(): string;
|
|
929
|
-
/** Set of loaded bundle names */
|
|
930
|
-
get loadedBundles(): ReadonlySet<string>;
|
|
931
|
-
/**
|
|
932
|
-
* Initialize the asset system.
|
|
933
|
-
* Must be called before loading any assets.
|
|
934
|
-
*/
|
|
935
|
-
init(): Promise<void>;
|
|
936
|
-
/**
|
|
937
|
-
* Load a single bundle by name.
|
|
938
|
-
*
|
|
939
|
-
* @param name - Bundle name (must exist in the manifest)
|
|
940
|
-
* @param onProgress - Progress callback (0..1)
|
|
941
|
-
* @returns Loaded assets map
|
|
942
|
-
*/
|
|
943
|
-
loadBundle(name: string, onProgress?: (progress: number) => void): Promise<Record<string, unknown>>;
|
|
944
|
-
/**
|
|
945
|
-
* Load multiple bundles simultaneously.
|
|
946
|
-
* Progress is aggregated across all bundles.
|
|
947
|
-
*
|
|
948
|
-
* @param names - Bundle names
|
|
949
|
-
* @param onProgress - Progress callback (0..1)
|
|
950
|
-
*/
|
|
951
|
-
loadBundles(names: string[], onProgress?: (progress: number) => void): Promise<Record<string, unknown>>;
|
|
952
|
-
/**
|
|
953
|
-
* Load individual assets by URL or alias.
|
|
954
|
-
*
|
|
955
|
-
* @param urls - Asset URLs or aliases
|
|
956
|
-
* @param onProgress - Progress callback (0..1)
|
|
957
|
-
*/
|
|
958
|
-
load<T = unknown>(urls: string | string[], onProgress?: (progress: number) => void): Promise<T>;
|
|
959
|
-
/**
|
|
960
|
-
* Get a loaded asset synchronously from cache.
|
|
961
|
-
*
|
|
962
|
-
* @param alias - Asset alias
|
|
963
|
-
* @throws if not loaded
|
|
964
|
-
*/
|
|
965
|
-
get<T = unknown>(alias: string): T;
|
|
966
|
-
/**
|
|
967
|
-
* Unload a bundle to free memory.
|
|
968
|
-
*/
|
|
969
|
-
unloadBundle(name: string): Promise<void>;
|
|
970
|
-
/**
|
|
971
|
-
* Start background loading a bundle (low-priority preload).
|
|
972
|
-
* Useful for loading bonus round assets while player is in base game.
|
|
973
|
-
*/
|
|
974
|
-
backgroundLoad(name: string): Promise<void>;
|
|
975
|
-
/**
|
|
976
|
-
* Get all bundle names from the manifest.
|
|
977
|
-
*/
|
|
978
|
-
getBundleNames(): string[];
|
|
979
|
-
/**
|
|
980
|
-
* Check if a bundle is loaded.
|
|
981
|
-
*/
|
|
982
|
-
isBundleLoaded(name: string): boolean;
|
|
983
|
-
private ensureInitialized;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
type AudioCategoryName = 'music' | 'sfx' | 'ui' | 'ambient';
|
|
987
|
-
/**
|
|
988
|
-
* Manages all game audio: music, SFX, UI sounds, ambient.
|
|
989
|
-
*
|
|
990
|
-
* Optional dependency on @pixi/sound — if not installed, AudioManager
|
|
991
|
-
* operates as a silent no-op (graceful degradation).
|
|
992
|
-
*
|
|
993
|
-
* Features:
|
|
994
|
-
* - Per-category volume control (music, sfx, ui, ambient)
|
|
995
|
-
* - Music crossfade and looping
|
|
996
|
-
* - Mobile audio unlock on first interaction
|
|
997
|
-
* - Mute state persistence in localStorage
|
|
998
|
-
* - Global mute/unmute
|
|
999
|
-
*
|
|
1000
|
-
* @example
|
|
1001
|
-
* ```ts
|
|
1002
|
-
* const audio = new AudioManager({ music: 0.5, sfx: 0.8 });
|
|
1003
|
-
* await audio.init();
|
|
1004
|
-
* audio.playMusic('bg-music');
|
|
1005
|
-
* audio.play('spin-click', 'sfx');
|
|
1006
|
-
* ```
|
|
1007
|
-
*/
|
|
1008
|
-
declare class AudioManager {
|
|
1009
|
-
private _soundModule;
|
|
1010
|
-
private _initialized;
|
|
1011
|
-
private _globalMuted;
|
|
1012
|
-
private _persist;
|
|
1013
|
-
private _storageKey;
|
|
1014
|
-
private _categories;
|
|
1015
|
-
private _masterGain;
|
|
1016
|
-
private _currentMusic;
|
|
1017
|
-
private _unlocked;
|
|
1018
|
-
private _unlockHandler;
|
|
1019
|
-
constructor(config?: AudioConfig);
|
|
1020
|
-
/** Whether the audio system is initialized */
|
|
1021
|
-
get initialized(): boolean;
|
|
1022
|
-
/** Whether audio is globally muted */
|
|
1023
|
-
get muted(): boolean;
|
|
1024
|
-
/**
|
|
1025
|
-
* Initialize the audio system.
|
|
1026
|
-
* Dynamically imports @pixi/sound to keep it optional.
|
|
1027
|
-
*/
|
|
1028
|
-
init(): Promise<void>;
|
|
1029
|
-
/**
|
|
1030
|
-
* Play a sound effect.
|
|
1031
|
-
*
|
|
1032
|
-
* @param alias - Sound alias (must be loaded via AssetManager)
|
|
1033
|
-
* @param category - Audio category (default: 'sfx')
|
|
1034
|
-
* @param options - Additional play options
|
|
1035
|
-
*/
|
|
1036
|
-
play(alias: string, category?: AudioCategoryName, options?: {
|
|
1037
|
-
volume?: number;
|
|
1038
|
-
loop?: boolean;
|
|
1039
|
-
speed?: number;
|
|
1040
|
-
}): void;
|
|
1041
|
-
/**
|
|
1042
|
-
* Play background music with optional crossfade.
|
|
1043
|
-
*
|
|
1044
|
-
* @param alias - Music alias
|
|
1045
|
-
* @param fadeDuration - Crossfade duration in ms (default: 500)
|
|
1046
|
-
*/
|
|
1047
|
-
playMusic(alias: string, fadeDuration?: number): void;
|
|
1048
|
-
/**
|
|
1049
|
-
* Stop current music.
|
|
1050
|
-
*/
|
|
1051
|
-
stopMusic(): void;
|
|
1052
|
-
/**
|
|
1053
|
-
* Stop all sounds.
|
|
1054
|
-
*/
|
|
1055
|
-
stopAll(): void;
|
|
1056
|
-
/** Global gain (0..1) folded into every category's effective volume. Driven by the shell's
|
|
1057
|
-
* 'master' settingChange. Does not affect the persisted per-category volumes. */
|
|
1058
|
-
setMasterVolume(volume: number): void;
|
|
1059
|
-
getMasterVolume(): number;
|
|
1060
|
-
/**
|
|
1061
|
-
* Set volume for a category.
|
|
1062
|
-
*/
|
|
1063
|
-
setVolume(category: AudioCategoryName, volume: number): void;
|
|
1064
|
-
/**
|
|
1065
|
-
* Get volume for a category.
|
|
1066
|
-
*/
|
|
1067
|
-
getVolume(category: AudioCategoryName): number;
|
|
1068
|
-
/**
|
|
1069
|
-
* Mute a specific category.
|
|
1070
|
-
*/
|
|
1071
|
-
muteCategory(category: AudioCategoryName): void;
|
|
1072
|
-
/**
|
|
1073
|
-
* Unmute a specific category.
|
|
1074
|
-
*/
|
|
1075
|
-
unmuteCategory(category: AudioCategoryName): void;
|
|
1076
|
-
/**
|
|
1077
|
-
* Toggle mute for a category.
|
|
1078
|
-
*/
|
|
1079
|
-
toggleCategory(category: AudioCategoryName): boolean;
|
|
1080
|
-
/**
|
|
1081
|
-
* Mute all audio globally.
|
|
1082
|
-
*/
|
|
1083
|
-
muteAll(): void;
|
|
1084
|
-
/**
|
|
1085
|
-
* Unmute all audio globally.
|
|
1086
|
-
*/
|
|
1087
|
-
unmuteAll(): void;
|
|
1088
|
-
/**
|
|
1089
|
-
* Toggle global mute.
|
|
1090
|
-
*/
|
|
1091
|
-
toggleMute(): boolean;
|
|
1092
|
-
/**
|
|
1093
|
-
* Duck music volume (e.g., during big win presentation).
|
|
1094
|
-
*
|
|
1095
|
-
* @param factor - Volume multiplier (0..1), e.g. 0.3 = 30% of normal
|
|
1096
|
-
*/
|
|
1097
|
-
duckMusic(factor: number): void;
|
|
1098
|
-
/**
|
|
1099
|
-
* Restore music to normal volume after ducking.
|
|
1100
|
-
*/
|
|
1101
|
-
unduckMusic(): void;
|
|
1102
|
-
/**
|
|
1103
|
-
* Destroy the audio manager and free resources.
|
|
1104
|
-
*/
|
|
1105
|
-
destroy(): void;
|
|
1106
|
-
/**
|
|
1107
|
-
* Smoothly fade a sound's volume from `fromVol` to `toVol` over `durationMs`.
|
|
1108
|
-
*/
|
|
1109
|
-
private fadeVolume;
|
|
1110
|
-
private applyVolumes;
|
|
1111
|
-
private setupMobileUnlock;
|
|
1112
|
-
private removeMobileUnlock;
|
|
1113
|
-
private saveState;
|
|
1114
|
-
private restoreState;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
interface InputEvents {
|
|
1118
|
-
tap: {
|
|
1119
|
-
x: number;
|
|
1120
|
-
y: number;
|
|
1121
|
-
};
|
|
1122
|
-
press: {
|
|
1123
|
-
x: number;
|
|
1124
|
-
y: number;
|
|
1125
|
-
};
|
|
1126
|
-
release: {
|
|
1127
|
-
x: number;
|
|
1128
|
-
y: number;
|
|
1129
|
-
};
|
|
1130
|
-
move: {
|
|
1131
|
-
x: number;
|
|
1132
|
-
y: number;
|
|
1133
|
-
};
|
|
1134
|
-
swipe: {
|
|
1135
|
-
direction: 'up' | 'down' | 'left' | 'right';
|
|
1136
|
-
velocity: number;
|
|
1137
|
-
};
|
|
1138
|
-
keydown: {
|
|
1139
|
-
key: string;
|
|
1140
|
-
code: string;
|
|
1141
|
-
};
|
|
1142
|
-
keyup: {
|
|
1143
|
-
key: string;
|
|
1144
|
-
code: string;
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Unified input manager for touch, mouse, and keyboard.
|
|
1149
|
-
*
|
|
1150
|
-
* Features:
|
|
1151
|
-
* - Unified pointer events (works with touch + mouse)
|
|
1152
|
-
* - Swipe gesture detection
|
|
1153
|
-
* - Keyboard input with isKeyDown state
|
|
1154
|
-
* - Input locking (block input during animations)
|
|
1155
|
-
*
|
|
1156
|
-
* @example
|
|
1157
|
-
* ```ts
|
|
1158
|
-
* const input = new InputManager(app.canvas);
|
|
1159
|
-
*
|
|
1160
|
-
* input.on('tap', ({ x, y }) => console.log('Tapped at', x, y));
|
|
1161
|
-
* input.on('swipe', ({ direction }) => console.log('Swiped', direction));
|
|
1162
|
-
* input.on('keydown', ({ key }) => {
|
|
1163
|
-
* if (key === ' ') spin();
|
|
1164
|
-
* });
|
|
1165
|
-
*
|
|
1166
|
-
* // Block input during animations
|
|
1167
|
-
* input.lock();
|
|
1168
|
-
* await playAnimation();
|
|
1169
|
-
* input.unlock();
|
|
1170
|
-
* ```
|
|
1171
|
-
*/
|
|
1172
|
-
declare class InputManager extends EventEmitter<InputEvents> {
|
|
1173
|
-
private _canvas;
|
|
1174
|
-
private _locked;
|
|
1175
|
-
private _keysDown;
|
|
1176
|
-
private _destroyed;
|
|
1177
|
-
private _viewportScale;
|
|
1178
|
-
private _viewportOffsetX;
|
|
1179
|
-
private _viewportOffsetY;
|
|
1180
|
-
private _pointerStart;
|
|
1181
|
-
private _swipeThreshold;
|
|
1182
|
-
private _swipeMaxTime;
|
|
1183
|
-
constructor(canvas: HTMLCanvasElement);
|
|
1184
|
-
/** Whether input is currently locked */
|
|
1185
|
-
get locked(): boolean;
|
|
1186
|
-
/** Lock all input (e.g., during animations) */
|
|
1187
|
-
lock(): void;
|
|
1188
|
-
/** Unlock input */
|
|
1189
|
-
unlock(): void;
|
|
1190
|
-
/** Check if a key is currently pressed */
|
|
1191
|
-
isKeyDown(key: string): boolean;
|
|
1192
|
-
/**
|
|
1193
|
-
* Update the viewport transform used for DOM→world coordinate mapping.
|
|
1194
|
-
* Called automatically by GameApplication when ViewportManager emits resize.
|
|
1195
|
-
*/
|
|
1196
|
-
setViewportTransform(scale: number, offsetX: number, offsetY: number): void;
|
|
1197
|
-
/**
|
|
1198
|
-
* Convert a DOM canvas position to game-world coordinates,
|
|
1199
|
-
* accounting for viewport scaling and offset.
|
|
1200
|
-
*/
|
|
1201
|
-
getWorldPosition(canvasX: number, canvasY: number): {
|
|
1202
|
-
x: number;
|
|
1203
|
-
y: number;
|
|
1204
|
-
};
|
|
1205
|
-
/** Destroy the input manager */
|
|
1206
|
-
destroy(): void;
|
|
1207
|
-
private setupPointerEvents;
|
|
1208
|
-
private onPointerDown;
|
|
1209
|
-
private onPointerUp;
|
|
1210
|
-
private onPointerMove;
|
|
1211
|
-
private getCanvasPosition;
|
|
1212
|
-
private setupKeyboardEvents;
|
|
1213
|
-
private onKeyDown;
|
|
1214
|
-
private onKeyUp;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
interface ViewportConfig {
|
|
1218
|
-
designWidth: number;
|
|
1219
|
-
designHeight: number;
|
|
1220
|
-
scaleMode: ScaleMode;
|
|
1221
|
-
orientation: Orientation;
|
|
1222
|
-
}
|
|
1223
|
-
interface ViewportEvents {
|
|
1224
|
-
resize: {
|
|
1225
|
-
width: number;
|
|
1226
|
-
height: number;
|
|
1227
|
-
scale: number;
|
|
1228
|
-
};
|
|
1229
|
-
orientationChange: Orientation;
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* Manages responsive scaling of the game canvas to fit its container.
|
|
1233
|
-
*
|
|
1234
|
-
* Supports three scale modes:
|
|
1235
|
-
* - **FIT** — letterbox/pillarbox to maintain aspect ratio (industry standard)
|
|
1236
|
-
* - **FILL** — fill container, crop edges
|
|
1237
|
-
* - **STRETCH** — stretch to fill (distorts)
|
|
1238
|
-
*
|
|
1239
|
-
* Also handles:
|
|
1240
|
-
* - Orientation detection (landscape/portrait)
|
|
1241
|
-
* - Safe areas (mobile notch)
|
|
1242
|
-
* - ResizeObserver for smooth container resizing
|
|
1243
|
-
*
|
|
1244
|
-
* @example
|
|
1245
|
-
* ```ts
|
|
1246
|
-
* const viewport = new ViewportManager(app, container, {
|
|
1247
|
-
* designWidth: 1920,
|
|
1248
|
-
* designHeight: 1080,
|
|
1249
|
-
* scaleMode: ScaleMode.FIT,
|
|
1250
|
-
* orientation: Orientation.LANDSCAPE,
|
|
1251
|
-
* });
|
|
1252
|
-
*
|
|
1253
|
-
* viewport.on('resize', ({ width, height, scale }) => {
|
|
1254
|
-
* console.log(`New size: ${width}x${height} @ ${scale}x`);
|
|
1255
|
-
* });
|
|
1256
|
-
* ```
|
|
1257
|
-
*/
|
|
1258
|
-
declare class ViewportManager extends EventEmitter<ViewportEvents> {
|
|
1259
|
-
private _app;
|
|
1260
|
-
private _container;
|
|
1261
|
-
private _config;
|
|
1262
|
-
private _target;
|
|
1263
|
-
private _resizeObserver;
|
|
1264
|
-
private _currentOrientation;
|
|
1265
|
-
private _currentWidth;
|
|
1266
|
-
private _currentHeight;
|
|
1267
|
-
private _currentScale;
|
|
1268
|
-
private _destroyed;
|
|
1269
|
-
private _resizeTimeout;
|
|
1270
|
-
constructor(app: Application, container: HTMLElement, config: ViewportConfig, target?: Container);
|
|
1271
|
-
/** Current canvas width in game units */
|
|
1272
|
-
get width(): number;
|
|
1273
|
-
/** Current canvas height in game units */
|
|
1274
|
-
get height(): number;
|
|
1275
|
-
/** Current scale factor */
|
|
1276
|
-
get scale(): number;
|
|
1277
|
-
/** Current orientation */
|
|
1278
|
-
get orientation(): Orientation;
|
|
1279
|
-
/** Design reference width */
|
|
1280
|
-
get designWidth(): number;
|
|
1281
|
-
/** Design reference height */
|
|
1282
|
-
get designHeight(): number;
|
|
1283
|
-
/**
|
|
1284
|
-
* Force a resize calculation. Called automatically on container size change.
|
|
1285
|
-
*/
|
|
1286
|
-
refresh(): void;
|
|
1287
|
-
/**
|
|
1288
|
-
* Destroy the viewport manager.
|
|
1289
|
-
*/
|
|
1290
|
-
destroy(): void;
|
|
1291
|
-
private setupObserver;
|
|
1292
|
-
private onWindowResize;
|
|
1293
|
-
private debouncedRefresh;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
/**
|
|
1297
|
-
* FPS overlay for debugging performance.
|
|
1298
|
-
*
|
|
1299
|
-
* Shows FPS, frame time, and draw call count in the corner of the screen.
|
|
1300
|
-
*
|
|
1301
|
-
* @example
|
|
1302
|
-
* ```ts
|
|
1303
|
-
* const fps = new FPSOverlay(app);
|
|
1304
|
-
* fps.show();
|
|
1305
|
-
* ```
|
|
1306
|
-
*/
|
|
1307
|
-
declare class FPSOverlay {
|
|
1308
|
-
private _app;
|
|
1309
|
-
private _container;
|
|
1310
|
-
private _fpsText;
|
|
1311
|
-
private _visible;
|
|
1312
|
-
private _samples;
|
|
1313
|
-
private _maxSamples;
|
|
1314
|
-
private _lastUpdate;
|
|
1315
|
-
private _tickFn;
|
|
1316
|
-
constructor(app: Application);
|
|
1317
|
-
/** Show the FPS overlay */
|
|
1318
|
-
show(): void;
|
|
1319
|
-
/** Hide the FPS overlay */
|
|
1320
|
-
hide(): void;
|
|
1321
|
-
/** Toggle visibility */
|
|
1322
|
-
toggle(): void;
|
|
1323
|
-
/** Destroy the overlay */
|
|
1324
|
-
destroy(): void;
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
/**
|
|
1328
|
-
* The main entry point for a game built on @energy8platform/game-engine.
|
|
1329
|
-
*
|
|
1330
|
-
* Orchestrates the full lifecycle:
|
|
1331
|
-
* 1. Create PixiJS Application
|
|
1332
|
-
* 2. Initialize SDK (or run offline)
|
|
1333
|
-
* 3. Show CSS preloader → Canvas loading screen with progress bar
|
|
1334
|
-
* 4. Load asset manifest
|
|
1335
|
-
* 5. Transition to the first game scene
|
|
1336
|
-
*
|
|
1337
|
-
* @example
|
|
1338
|
-
* ```ts
|
|
1339
|
-
* import { GameApplication, ScaleMode } from '@energy8platform/game-engine';
|
|
1340
|
-
* import { GameScene } from './scenes/GameScene';
|
|
1341
|
-
*
|
|
1342
|
-
* const game = new GameApplication({
|
|
1343
|
-
* container: '#game',
|
|
1344
|
-
* designWidth: 1920,
|
|
1345
|
-
* designHeight: 1080,
|
|
1346
|
-
* scaleMode: ScaleMode.FIT,
|
|
1347
|
-
* manifest: { bundles: [
|
|
1348
|
-
* { name: 'preload', assets: [{ alias: 'logo', src: 'logo.png' }] },
|
|
1349
|
-
* { name: 'game', assets: [{ alias: 'bg', src: 'background.png' }] },
|
|
1350
|
-
* ]},
|
|
1351
|
-
* loading: { tapToStart: true },
|
|
1352
|
-
* });
|
|
1353
|
-
*
|
|
1354
|
-
* game.scenes.register('game', GameScene);
|
|
1355
|
-
* await game.start('game');
|
|
1356
|
-
* ```
|
|
1357
|
-
*/
|
|
1358
|
-
declare class GameApplication extends EventEmitter<GameEngineEvents> {
|
|
1359
|
-
/** PixiJS Application instance */
|
|
1360
|
-
app: Application;
|
|
1361
|
-
/** Scene manager */
|
|
1362
|
-
scenes: SceneManager;
|
|
1363
|
-
/** Asset manager */
|
|
1364
|
-
assets: AssetManager;
|
|
1365
|
-
/** Audio manager */
|
|
1366
|
-
audio: AudioManager;
|
|
1367
|
-
/** Input manager */
|
|
1368
|
-
input: InputManager;
|
|
1369
|
-
/** Viewport manager */
|
|
1370
|
-
viewport: ViewportManager;
|
|
1371
|
-
/** Scaled world root (holds scenes). Transformed by the ViewportManager to fit the design
|
|
1372
|
-
* resolution; lives below the UI layer on app.stage. */
|
|
1373
|
-
worldRoot: Container;
|
|
1374
|
-
/** Unscaled, screen-space UI layer. Sits above {@link worldRoot} and is NOT touched by the
|
|
1375
|
-
* viewport transform — children fill the real screen (e.g. the host's shell + overlay). */
|
|
1376
|
-
uiLayer: Container;
|
|
1377
|
-
/** SDK instance (null in offline mode) */
|
|
1378
|
-
sdk: CasinoGameSDK | null;
|
|
1379
|
-
/** FPS overlay instance (only when debug: true) */
|
|
1380
|
-
fpsOverlay: FPSOverlay | null;
|
|
1381
|
-
/** Data received from SDK initialization */
|
|
1382
|
-
initData: InitData | null;
|
|
1383
|
-
/** Platform session (SDK + optional DevBridge). null until start() runs. */
|
|
1384
|
-
platformSession: PlatformSession | null;
|
|
1385
|
-
/** Branded game shell (only when config.shell is set). */
|
|
1386
|
-
shell?: _energy8platform_platform_core_shell.GameShell;
|
|
1387
|
-
/** Configuration */
|
|
1388
|
-
readonly config: GameApplicationConfig;
|
|
1389
|
-
private _running;
|
|
1390
|
-
private _destroyed;
|
|
1391
|
-
private _container;
|
|
1392
|
-
constructor(config?: GameApplicationConfig);
|
|
1393
|
-
/** Current game config from SDK (or null in offline mode) */
|
|
1394
|
-
get gameConfig(): GameConfigData | null;
|
|
1395
|
-
/** Current session data */
|
|
1396
|
-
get session(): SessionData | null;
|
|
1397
|
-
/** Current balance */
|
|
1398
|
-
get balance(): number;
|
|
1399
|
-
/** Current currency */
|
|
1400
|
-
get currency(): string;
|
|
1401
|
-
/** Whether the engine is running */
|
|
1402
|
-
get isRunning(): boolean;
|
|
1403
|
-
/**
|
|
1404
|
-
* Start the game engine. This is the main entry point.
|
|
1405
|
-
*
|
|
1406
|
-
* @param firstScene - Key of the first scene to show after loading (must be registered)
|
|
1407
|
-
* @param sceneData - Optional data to pass to the first scene's onEnter
|
|
1408
|
-
*/
|
|
1409
|
-
start(firstScene: string, sceneData?: unknown): Promise<void>;
|
|
1410
|
-
/**
|
|
1411
|
-
* Destroy the engine and free all resources.
|
|
1412
|
-
*/
|
|
1413
|
-
destroy(): Promise<void>;
|
|
1414
|
-
private resolveContainer;
|
|
1415
|
-
private initPixi;
|
|
1416
|
-
private initSDK;
|
|
1417
|
-
private applySDKConfig;
|
|
1418
|
-
private initSubSystems;
|
|
1419
|
-
private loadAssets;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
declare abstract class ReactScene extends Scene {
|
|
1423
|
-
private _pixiRoot;
|
|
1424
|
-
private _contextValue;
|
|
1425
|
-
/** Subclasses implement this to return their React element tree. */
|
|
1426
|
-
abstract render(): ReactElement;
|
|
1427
|
-
/** Access the GameApplication instance. */
|
|
1428
|
-
protected getApp(): GameApplication;
|
|
1429
|
-
onEnter(data?: unknown): Promise<void>;
|
|
1430
|
-
onExit(): Promise<void>;
|
|
1431
|
-
onResize(width: number, height: number): void;
|
|
1432
|
-
onDestroy(): void;
|
|
1433
|
-
private _mountReactTree;
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
interface EngineContextValue {
|
|
1437
|
-
app: GameApplication;
|
|
1438
|
-
sdk: CasinoGameSDK | null;
|
|
1439
|
-
audio: AudioManager;
|
|
1440
|
-
input: InputManager;
|
|
1441
|
-
viewport: ViewportManager;
|
|
1442
|
-
gameConfig: GameConfigData | null;
|
|
1443
|
-
screen: {
|
|
1444
|
-
width: number;
|
|
1445
|
-
height: number;
|
|
1446
|
-
scale: number;
|
|
1447
|
-
};
|
|
1448
|
-
isPortrait: boolean;
|
|
1449
|
-
}
|
|
1450
|
-
declare const EngineContext: react.Context<EngineContextValue | null>;
|
|
1451
|
-
declare function useEngine(): EngineContextValue;
|
|
1452
|
-
|
|
1453
|
-
declare function useSDK(): CasinoGameSDK | null;
|
|
1454
|
-
declare function useAudio(): AudioManager;
|
|
1455
|
-
declare function useInput(): InputManager;
|
|
1456
|
-
declare function useViewport(): {
|
|
1457
|
-
width: number;
|
|
1458
|
-
height: number;
|
|
1459
|
-
scale: number;
|
|
1460
|
-
isPortrait: boolean;
|
|
1461
|
-
};
|
|
1462
|
-
declare function useBalance(): number;
|
|
1463
|
-
declare function useSession(): SessionData | null;
|
|
1464
|
-
declare function useGameConfig<T = GameConfigData>(): T | null;
|
|
1465
|
-
|
|
1466
|
-
export { EngineContext, ReactScene, createPixiRoot, extend, extendCustomElements, extendPixiElements, extendUIElements, useAudio, useBalance, useEngine, useGameConfig, useInput, useSDK, useSession, useViewport };
|
|
1467
|
-
export type { EngineContextValue, PixiRoot };
|