@energy8platform/game-engine 0.3.0 → 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 +139 -44
- package/dist/core.cjs.js +1 -0
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.esm.js +1 -0
- package/dist/core.esm.js.map +1 -1
- package/dist/index.cjs.js +317 -789
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +61 -129
- package/dist/index.esm.js +304 -790
- package/dist/index.esm.js.map +1 -1
- package/dist/ui.cjs.js +637 -1106
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.d.ts +60 -128
- package/dist/ui.esm.js +620 -1107
- package/dist/ui.esm.js.map +1 -1
- package/dist/vite.cjs.js +23 -3
- package/dist/vite.cjs.js.map +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.esm.js +23 -3
- package/dist/vite.esm.js.map +1 -1
- package/package.json +17 -2
- package/src/core/GameApplication.ts +1 -0
- package/src/index.ts +16 -0
- package/src/ui/BalanceDisplay.ts +0 -3
- package/src/ui/Button.ts +71 -130
- package/src/ui/Layout.ts +102 -180
- 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 +58 -489
- package/src/ui/Toast.ts +19 -13
- package/src/ui/index.ts +13 -0
- package/src/vite/index.ts +23 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { Container, ApplicationOptions, Application, Texture, AnimatedSprite, Spritesheet, 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) */
|
|
@@ -1250,7 +1255,7 @@ declare class SpriteAnimation {
|
|
|
1250
1255
|
static getTexturesByPrefix(sheet: Spritesheet, prefix: string): Texture[];
|
|
1251
1256
|
}
|
|
1252
1257
|
|
|
1253
|
-
type ButtonState = '
|
|
1258
|
+
type ButtonState = 'default' | 'hover' | 'pressed' | 'disabled';
|
|
1254
1259
|
interface ButtonConfig {
|
|
1255
1260
|
/** Default texture/sprite for each state (optional — uses Graphics if not provided) */
|
|
1256
1261
|
textures?: Partial<Record<ButtonState, string | Texture>>;
|
|
@@ -1268,48 +1273,38 @@ interface ButtonConfig {
|
|
|
1268
1273
|
animationDuration?: number;
|
|
1269
1274
|
/** Start disabled */
|
|
1270
1275
|
disabled?: boolean;
|
|
1276
|
+
/** Button text */
|
|
1277
|
+
text?: string;
|
|
1278
|
+
/** Button text style */
|
|
1279
|
+
textStyle?: Record<string, unknown>;
|
|
1271
1280
|
}
|
|
1272
1281
|
/**
|
|
1273
|
-
* Interactive button component
|
|
1282
|
+
* Interactive button component powered by `@pixi/ui` FancyButton.
|
|
1274
1283
|
*
|
|
1275
|
-
* 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.
|
|
1276
1286
|
*
|
|
1277
1287
|
* @example
|
|
1278
1288
|
* ```ts
|
|
1279
1289
|
* const btn = new Button({
|
|
1280
1290
|
* width: 200, height: 60, borderRadius: 12,
|
|
1281
|
-
* colors: {
|
|
1291
|
+
* colors: { default: 0x22aa22, hover: 0x33cc33 },
|
|
1292
|
+
* text: 'SPIN',
|
|
1282
1293
|
* });
|
|
1283
1294
|
*
|
|
1284
|
-
* btn.
|
|
1295
|
+
* btn.onPress.connect(() => console.log('Clicked!'));
|
|
1285
1296
|
* scene.container.addChild(btn);
|
|
1286
1297
|
* ```
|
|
1287
1298
|
*/
|
|
1288
|
-
declare class Button extends
|
|
1289
|
-
private
|
|
1290
|
-
private _bg;
|
|
1291
|
-
private _sprites;
|
|
1292
|
-
private _config;
|
|
1293
|
-
/** Called when the button is tapped/clicked */
|
|
1294
|
-
onTap?: () => void;
|
|
1295
|
-
/** Called when the button state changes */
|
|
1296
|
-
onStateChange?: (state: ButtonState) => void;
|
|
1299
|
+
declare class Button extends FancyButton {
|
|
1300
|
+
private _buttonConfig;
|
|
1297
1301
|
constructor(config?: ButtonConfig);
|
|
1298
|
-
/** Current button state */
|
|
1299
|
-
get state(): ButtonState;
|
|
1300
1302
|
/** Enable the button */
|
|
1301
1303
|
enable(): void;
|
|
1302
1304
|
/** Disable the button */
|
|
1303
1305
|
disable(): void;
|
|
1304
1306
|
/** Whether the button is disabled */
|
|
1305
1307
|
get disabled(): boolean;
|
|
1306
|
-
private setState;
|
|
1307
|
-
private render;
|
|
1308
|
-
private onPointerOver;
|
|
1309
|
-
private onPointerOut;
|
|
1310
|
-
private onPointerDown;
|
|
1311
|
-
private onPointerUp;
|
|
1312
|
-
private onPointerTap;
|
|
1313
1308
|
}
|
|
1314
1309
|
|
|
1315
1310
|
interface ProgressBarConfig {
|
|
@@ -1326,7 +1321,9 @@ interface ProgressBarConfig {
|
|
|
1326
1321
|
animationSpeed?: number;
|
|
1327
1322
|
}
|
|
1328
1323
|
/**
|
|
1329
|
-
* Horizontal progress bar
|
|
1324
|
+
* Horizontal progress bar powered by `@pixi/ui` ProgressBar.
|
|
1325
|
+
*
|
|
1326
|
+
* Provides optional smooth animated fill via per-frame `update()`.
|
|
1330
1327
|
*
|
|
1331
1328
|
* @example
|
|
1332
1329
|
* ```ts
|
|
@@ -1336,9 +1333,8 @@ interface ProgressBarConfig {
|
|
|
1336
1333
|
* ```
|
|
1337
1334
|
*/
|
|
1338
1335
|
declare class ProgressBar extends Container {
|
|
1339
|
-
private
|
|
1340
|
-
private
|
|
1341
|
-
private _border;
|
|
1336
|
+
private _bar;
|
|
1337
|
+
private _borderGfx;
|
|
1342
1338
|
private _config;
|
|
1343
1339
|
private _progress;
|
|
1344
1340
|
private _displayedProgress;
|
|
@@ -1349,10 +1345,7 @@ declare class ProgressBar extends Container {
|
|
|
1349
1345
|
/**
|
|
1350
1346
|
* Call each frame if animated is true.
|
|
1351
1347
|
*/
|
|
1352
|
-
update(
|
|
1353
|
-
private drawTrack;
|
|
1354
|
-
private drawBorder;
|
|
1355
|
-
private drawFill;
|
|
1348
|
+
update(_dt: number): void;
|
|
1356
1349
|
}
|
|
1357
1350
|
|
|
1358
1351
|
interface LabelConfig {
|
|
@@ -1426,7 +1419,10 @@ interface PanelConfig {
|
|
|
1426
1419
|
padding?: number;
|
|
1427
1420
|
}
|
|
1428
1421
|
/**
|
|
1429
|
-
* 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.
|
|
1430
1426
|
*
|
|
1431
1427
|
* @example
|
|
1432
1428
|
* ```ts
|
|
@@ -1441,16 +1437,13 @@ interface PanelConfig {
|
|
|
1441
1437
|
* });
|
|
1442
1438
|
* ```
|
|
1443
1439
|
*/
|
|
1444
|
-
declare class Panel extends
|
|
1445
|
-
private
|
|
1446
|
-
private _content;
|
|
1447
|
-
private _config;
|
|
1440
|
+
declare class Panel extends LayoutContainer {
|
|
1441
|
+
private _panelConfig;
|
|
1448
1442
|
constructor(config?: PanelConfig);
|
|
1449
|
-
/**
|
|
1443
|
+
/** Access the content container (children added here participate in layout) */
|
|
1450
1444
|
get content(): Container;
|
|
1451
1445
|
/** Resize the panel */
|
|
1452
1446
|
setSize(width: number, height: number): void;
|
|
1453
|
-
private drawGraphicsBg;
|
|
1454
1447
|
}
|
|
1455
1448
|
|
|
1456
1449
|
interface BalanceDisplayConfig {
|
|
@@ -1571,6 +1564,8 @@ interface ModalConfig {
|
|
|
1571
1564
|
* Modal overlay component.
|
|
1572
1565
|
* Shows content on top of a dark overlay with enter/exit animations.
|
|
1573
1566
|
*
|
|
1567
|
+
* The content container uses `@pixi/layout` for automatic centering.
|
|
1568
|
+
*
|
|
1574
1569
|
* @example
|
|
1575
1570
|
* ```ts
|
|
1576
1571
|
* const modal = new Modal({ closeOnOverlay: true });
|
|
@@ -1611,6 +1606,8 @@ interface ToastConfig {
|
|
|
1611
1606
|
/**
|
|
1612
1607
|
* Toast notification component for displaying transient messages.
|
|
1613
1608
|
*
|
|
1609
|
+
* Uses `@pixi/layout` LayoutContainer for auto-sized background.
|
|
1610
|
+
*
|
|
1614
1611
|
* @example
|
|
1615
1612
|
* ```ts
|
|
1616
1613
|
* const toast = new Toast();
|
|
@@ -1658,7 +1655,7 @@ interface LayoutConfig {
|
|
|
1658
1655
|
breakpoints?: Record<number, Partial<LayoutConfig>>;
|
|
1659
1656
|
}
|
|
1660
1657
|
/**
|
|
1661
|
-
* Responsive layout container
|
|
1658
|
+
* Responsive layout container powered by `@pixi/layout` (Yoga flexbox engine).
|
|
1662
1659
|
*
|
|
1663
1660
|
* Supports horizontal, vertical, grid, and wrap layout modes with
|
|
1664
1661
|
* alignment, padding, gap, and viewport-anchor positioning.
|
|
@@ -1681,17 +1678,15 @@ interface LayoutConfig {
|
|
|
1681
1678
|
* toolbar.addItem(betLabel);
|
|
1682
1679
|
* scene.container.addChild(toolbar);
|
|
1683
1680
|
*
|
|
1684
|
-
* // On resize, update layout position relative to viewport
|
|
1685
1681
|
* toolbar.updateViewport(width, height);
|
|
1686
1682
|
* ```
|
|
1687
1683
|
*/
|
|
1688
1684
|
declare class Layout extends Container {
|
|
1689
|
-
private
|
|
1685
|
+
private _layoutConfig;
|
|
1690
1686
|
private _padding;
|
|
1691
1687
|
private _anchor;
|
|
1692
1688
|
private _maxWidth;
|
|
1693
1689
|
private _breakpoints;
|
|
1694
|
-
private _content;
|
|
1695
1690
|
private _items;
|
|
1696
1691
|
private _viewportWidth;
|
|
1697
1692
|
private _viewportHeight;
|
|
@@ -1709,17 +1704,10 @@ declare class Layout extends Container {
|
|
|
1709
1704
|
* Should be called from `Scene.onResize()`.
|
|
1710
1705
|
*/
|
|
1711
1706
|
updateViewport(width: number, height: number): void;
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
*/
|
|
1715
|
-
layout(): void;
|
|
1716
|
-
private layoutLinear;
|
|
1717
|
-
private layoutGrid;
|
|
1718
|
-
private layoutWrap;
|
|
1707
|
+
private applyLayoutStyles;
|
|
1708
|
+
private applyGridChildWidth;
|
|
1719
1709
|
private applyAnchor;
|
|
1720
1710
|
private resolveConfig;
|
|
1721
|
-
private getItemSize;
|
|
1722
|
-
private static normalizePadding;
|
|
1723
1711
|
}
|
|
1724
1712
|
|
|
1725
1713
|
type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
@@ -1730,32 +1718,26 @@ interface ScrollContainerConfig {
|
|
|
1730
1718
|
height: number;
|
|
1731
1719
|
/** Scroll direction (default: 'vertical') */
|
|
1732
1720
|
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
1721
|
/** Background color (undefined = transparent) */
|
|
1748
|
-
backgroundColor?:
|
|
1749
|
-
/** Background alpha (default: 1) */
|
|
1750
|
-
backgroundAlpha?: number;
|
|
1722
|
+
backgroundColor?: ColorSource;
|
|
1751
1723
|
/** Border radius for the mask (default: 0) */
|
|
1752
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;
|
|
1753
1735
|
}
|
|
1754
1736
|
/**
|
|
1755
|
-
* Scrollable container
|
|
1737
|
+
* Scrollable container powered by `@pixi/ui` ScrollBox.
|
|
1756
1738
|
*
|
|
1757
|
-
*
|
|
1758
|
-
*
|
|
1739
|
+
* Provides touch/drag scrolling, mouse wheel support, inertia, and
|
|
1740
|
+
* dynamic rendering optimization for off-screen items.
|
|
1759
1741
|
*
|
|
1760
1742
|
* @example
|
|
1761
1743
|
* ```ts
|
|
@@ -1763,49 +1745,23 @@ interface ScrollContainerConfig {
|
|
|
1763
1745
|
* width: 600,
|
|
1764
1746
|
* height: 400,
|
|
1765
1747
|
* direction: 'vertical',
|
|
1766
|
-
*
|
|
1767
|
-
* elasticity: 0.3,
|
|
1748
|
+
* elementsMargin: 8,
|
|
1768
1749
|
* });
|
|
1769
1750
|
*
|
|
1770
|
-
* // Add content taller than 400px
|
|
1771
|
-
* const list = new Container();
|
|
1772
1751
|
* for (let i = 0; i < 50; i++) {
|
|
1773
|
-
*
|
|
1774
|
-
* row.y = i * 40;
|
|
1775
|
-
* list.addChild(row);
|
|
1752
|
+
* scroll.addItem(createRow(i));
|
|
1776
1753
|
* }
|
|
1777
|
-
* scroll.setContent(list);
|
|
1778
1754
|
*
|
|
1779
1755
|
* scene.container.addChild(scroll);
|
|
1780
1756
|
* ```
|
|
1781
1757
|
*/
|
|
1782
|
-
declare class ScrollContainer extends
|
|
1783
|
-
private
|
|
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;
|
|
1758
|
+
declare class ScrollContainer extends ScrollBox {
|
|
1759
|
+
private _scrollConfig;
|
|
1802
1760
|
constructor(config: ScrollContainerConfig);
|
|
1803
1761
|
/** Set scrollable content. Replaces any existing content. */
|
|
1804
1762
|
setContent(content: Container): void;
|
|
1805
|
-
/**
|
|
1806
|
-
|
|
1807
|
-
/** Scroll to a specific position (in content coordinates) */
|
|
1808
|
-
scrollTo(x: number, y: number, animate?: boolean): void;
|
|
1763
|
+
/** Add a single item */
|
|
1764
|
+
addItem(...items: Container[]): Container;
|
|
1809
1765
|
/** Scroll to make a specific item/child visible */
|
|
1810
1766
|
scrollToItem(index: number): void;
|
|
1811
1767
|
/** Current scroll position */
|
|
@@ -1813,30 +1769,6 @@ declare class ScrollContainer extends Container {
|
|
|
1813
1769
|
x: number;
|
|
1814
1770
|
y: number;
|
|
1815
1771
|
};
|
|
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
1772
|
}
|
|
1841
1773
|
|
|
1842
1774
|
/**
|
|
@@ -1951,4 +1883,4 @@ declare class DevBridge {
|
|
|
1951
1883
|
}
|
|
1952
1884
|
|
|
1953
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 };
|
|
1954
|
-
export type { AssetBundle, AssetEntry, AssetManifest, AudioConfig, DevBridgeConfig, EasingFunction, GameApplicationConfig, GameEngineEvents, IScene, LayoutAlignment, LayoutAnchor, LayoutConfig, LayoutDirection, LoadingScreenConfig, SceneConstructor, ScrollContainerConfig, ScrollDirection, SpriteAnimationConfig, TransitionConfig, TweenOptions };
|
|
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 };
|